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.
[ADD] project_forecast_line_priority
- Loading branch information
1 parent
9cc4029
commit 8a4ce3f
Showing
13 changed files
with
645 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,76 @@ | ||
============================== | ||
Project Forecast Line Priority | ||
============================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:0c7a75d90fd3e732909de3a75615d2b034c399f90748a81be1be2979a3d28d44 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |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) | ||
|
||
**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 <[email protected]> | ||
|
||
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. | ||
|
||
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,14 @@ | ||
# 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)", | ||
"license": "AGPL-3", | ||
"category": "Project", | ||
"website": "https://github.com/OCA/project", | ||
"depends": ["project_forecast_line_deadline", "project_task_add_very_high"], | ||
"data": ["views/res_config_settings.xml"], | ||
"installable": 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 @@ | ||
from . import project_task | ||
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,48 @@ | ||
# Copyright 2024 Therp BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from datetime import timedelta | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProjectTask(models.Model): | ||
_inherit = "project.task" | ||
|
||
def write(self, vals): | ||
"""Set forecast_date_planned_end based on priority""" | ||
# If user sets end date manually | ||
if "forecast_date_planned_end" in vals or "date_deadline" in vals: | ||
return super().write(vals) | ||
if "priority" not in vals: | ||
return super().write(vals) | ||
config_model = self.env["ir.config_parameter"] | ||
priority = int(vals.get("priority", 0)) | ||
today = fields.Date.today() | ||
for this in self: | ||
# date deadline is set, so ignore this one | ||
if this.date_deadline: | ||
continue | ||
# if priority is 0, do nothing | ||
if priority < 1: | ||
continue | ||
if priority == 1: | ||
# add weeks to end date | ||
interval = timedelta( | ||
weeks=int( | ||
config_model.get_param( | ||
"project_forecast_line_priority.priority_1" | ||
) | ||
) | ||
) | ||
else: | ||
# priorities 2 and 3 | ||
# add days to end date | ||
interval = timedelta( | ||
days=int( | ||
config_model.get_param( | ||
"project_forecast_line_priority.priority_%s" % priority | ||
) | ||
) | ||
) | ||
vals["forecast_date_planned_end"] = today + interval | ||
return super().write(vals) |
17 changes: 17 additions & 0 deletions
17
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,17 @@ | ||
# 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_1 = fields.Integer( | ||
config_parameter="project_forecast_line_priority.priority_1" | ||
) | ||
forecast_line_priority_2 = fields.Integer( | ||
config_parameter="project_forecast_line_priority.priority_2" | ||
) | ||
forecast_line_priority_3 = fields.Integer( | ||
config_parameter="project_forecast_line_priority.priority_3" | ||
) |
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 @@ | ||
* Nikos Tsirintanis <[email protected]> |
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.