forked from OCA/project
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][ADD] project_forecast_line_priority
- Loading branch information
1 parent
c43ac38
commit 73d5778
Showing
17 changed files
with
945 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
============================== | ||
Project Forecast Line Priority | ||
============================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:20b0d19ef0ce3823f5848fd27170a48d70bf99d41252891a82b75d8d6c115109 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Alpha | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github | ||
:target: https://github.com/OCA/project/tree/14.0/project_forecast_line_priority | ||
:alt: OCA/project | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/project-14-0/project-14-0-project_forecast_line_priority | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/project&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module recomputes forecast line end dates based on the priority of connected task(s) | ||
|
||
.. IMPORTANT:: | ||
This is an alpha version, the data model and design can change at any time without warning. | ||
Only for development or testing purpose, do not use in production. | ||
`More details on development status <https://odoo-community.org/page/development-status>`_ | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_forecast_line_priority%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Therp BV | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Nikos Tsirintanis <ntsirintanis@therp.nl> | ||
* Gijs-Jan Otten <gjotten@therp.nl@therp.nl> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
.. |maintainer-ntsirintanis| image:: https://github.com/ntsirintanis.png?size=40px | ||
:target: https://github.com/ntsirintanis | ||
:alt: ntsirintanis | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-ntsirintanis| | ||
|
||
This module is part of the `OCA/project <https://github.com/OCA/project/tree/14.0/project_forecast_line_priority>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright 2024 Therp BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Project Forecast Line Priority", | ||
"summary": "Project Forecast Line dates according to task priority", | ||
"version": "14.0.1.0.0", | ||
"author": "Therp BV, Odoo Community Association (OCA)", | ||
"maintainers": ["ntsirintanis"], | ||
"license": "AGPL-3", | ||
"category": "Project", | ||
"website": "https://github.com/OCA/project", | ||
"depends": ["project_forecast_line_deadline", "project_task_add_very_high"], | ||
"data": [ | ||
"data/ir_actions_server.xml", | ||
"views/res_config_settings.xml", | ||
], | ||
"installable": True, | ||
"development_status": "Alpha", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo noupdate="1"> | ||
<record id="action_project_task_priority" model="ir.actions.server"> | ||
<field name="name">Project Task: Update forecast date end</field> | ||
<field name="model_id" ref="project.model_project_task" /> | ||
<field name="binding_model_id" ref="project.model_project_task" /> | ||
<field name="binding_type">action</field> | ||
<field name="state">code</field> | ||
<field name="code"> | ||
model._action_update_forecast_date_end(records) | ||
</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import project_task | ||
from . import res_company | ||
from . import res_config_settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright 2024 Therp BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from datetime import timedelta | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ProjectTask(models.Model): | ||
_inherit = "project.task" | ||
|
||
def _forecast_date_planned_end_depends_list(self): | ||
"""Returns a list of fields to trigger recomputation""" | ||
return super()._forecast_date_planned_end_depends_list() + ["priority"] | ||
|
||
@api.depends(_forecast_date_planned_end_depends_list) | ||
def _compute_forecast_date_planned_end(self): | ||
"""Override method to use recompute based on priority""" | ||
res = super()._compute_forecast_date_planned_end() | ||
for task in self: | ||
task.forecast_date_planned_end = ( | ||
task._get_forecast_date_planned() or task.forecast_date_planned_end | ||
) | ||
return res | ||
|
||
def _update_forecast_lines(self): | ||
"""Override cron method and inject forecast date recomputation""" | ||
for task in self: | ||
forecast_date_planned_end = task._get_forecast_date_planned() | ||
if not forecast_date_planned_end: | ||
continue | ||
task.forecast_date_planned_end = forecast_date_planned_end | ||
return super()._update_forecast_lines() | ||
|
||
@api.model | ||
def _action_update_forecast_date_end(self, tasks): | ||
for task in tasks: | ||
new_forecast_date_planned_end = task._get_forecast_date_planned() | ||
if not new_forecast_date_planned_end: | ||
continue | ||
task.write( | ||
{ | ||
"forecast_date_planned_end": new_forecast_date_planned_end, | ||
} | ||
) | ||
|
||
def _get_forecast_date_planned(self, priority=None): | ||
"""Update forecast date end based on priority""" | ||
self.ensure_one() | ||
if self.date_deadline: | ||
return False | ||
priority = priority or self.priority | ||
if not priority: | ||
# This may happen when a portal user | ||
# is creating a task on portal | ||
priority = "0" | ||
selection = self.company_id["forecast_line_priority_%s_selection" % priority] | ||
if selection == "none": | ||
return False | ||
elif selection == "delta": | ||
return fields.Date.today() + timedelta( | ||
days=int(self.company_id["forecast_line_priority_%s_delta" % priority]) | ||
) | ||
elif selection == "date": | ||
return self.company_id["forecast_line_priority_%s_date" % priority] | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright 2024 Therp BV <https://therp.nl> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from odoo import fields, models | ||
|
||
SELECTION_FORECAST_ENDDATE = [ | ||
("none", "None"), | ||
("date", "Date"), | ||
("delta", "Delta (in days)"), | ||
] | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = "res.company" | ||
|
||
forecast_line_priority_0_date = fields.Date() | ||
forecast_line_priority_1_date = fields.Date() | ||
forecast_line_priority_2_date = fields.Date() | ||
forecast_line_priority_3_date = fields.Date() | ||
forecast_line_priority_0_delta = fields.Integer() | ||
forecast_line_priority_1_delta = fields.Integer() | ||
forecast_line_priority_2_delta = fields.Integer() | ||
forecast_line_priority_3_delta = fields.Integer() | ||
forecast_line_priority_0_selection = fields.Selection( | ||
SELECTION_FORECAST_ENDDATE, | ||
default="none", | ||
) | ||
forecast_line_priority_1_selection = fields.Selection( | ||
SELECTION_FORECAST_ENDDATE, | ||
default="none", | ||
) | ||
forecast_line_priority_2_selection = fields.Selection( | ||
SELECTION_FORECAST_ENDDATE, | ||
default="none", | ||
) | ||
forecast_line_priority_3_selection = fields.Selection( | ||
SELECTION_FORECAST_ENDDATE, | ||
default="none", | ||
) |
53 changes: 53 additions & 0 deletions
53
project_forecast_line_priority/models/res_config_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright 2024 Therp BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
forecast_line_priority_0_date = fields.Date( | ||
related="company_id.forecast_line_priority_0_date", readonly=False | ||
) | ||
forecast_line_priority_1_date = fields.Date( | ||
related="company_id.forecast_line_priority_1_date", readonly=False | ||
) | ||
forecast_line_priority_2_date = fields.Date( | ||
related="company_id.forecast_line_priority_2_date", readonly=False | ||
) | ||
forecast_line_priority_3_date = fields.Date( | ||
related="company_id.forecast_line_priority_3_date", readonly=False | ||
) | ||
forecast_line_priority_0_delta = fields.Integer( | ||
related="company_id.forecast_line_priority_0_delta", readonly=False | ||
) | ||
forecast_line_priority_1_delta = fields.Integer( | ||
related="company_id.forecast_line_priority_1_delta", readonly=False | ||
) | ||
forecast_line_priority_2_delta = fields.Integer( | ||
related="company_id.forecast_line_priority_2_delta", readonly=False | ||
) | ||
forecast_line_priority_3_delta = fields.Integer( | ||
related="company_id.forecast_line_priority_3_delta", readonly=False | ||
) | ||
forecast_line_priority_0_selection = fields.Selection( | ||
related="company_id.forecast_line_priority_0_selection", | ||
readonly=False, | ||
required=True, | ||
) | ||
forecast_line_priority_1_selection = fields.Selection( | ||
related="company_id.forecast_line_priority_1_selection", | ||
readonly=False, | ||
required=True, | ||
) | ||
forecast_line_priority_2_selection = fields.Selection( | ||
related="company_id.forecast_line_priority_2_selection", | ||
readonly=False, | ||
required=True, | ||
) | ||
forecast_line_priority_3_selection = fields.Selection( | ||
related="company_id.forecast_line_priority_3_selection", | ||
readonly=False, | ||
required=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Nikos Tsirintanis <ntsirintanis@therp.nl> | ||
* Gijs-Jan Otten <gjotten@therp.nl@therp.nl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module recomputes forecast line end dates based on the priority of connected task(s) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.