diff --git a/project_forecast_line_milestone/README.rst b/project_forecast_line_milestone/README.rst new file mode 100644 index 0000000000..6852db3c74 --- /dev/null +++ b/project_forecast_line_milestone/README.rst @@ -0,0 +1,76 @@ +=============================== +Project Forecast Line Milestone +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4a14722e9b48ef743995bc1ad28cf4695fea7f07c61815fb7c0017aa37e0ae69 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_milestone + :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_milestone + :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 milestone target date of connected projects + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Therp BV + +Contributors +~~~~~~~~~~~~ + +* Nikos Tsirintanis + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/project_forecast_line_milestone/__init__.py b/project_forecast_line_milestone/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/project_forecast_line_milestone/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_forecast_line_milestone/__manifest__.py b/project_forecast_line_milestone/__manifest__.py new file mode 100644 index 0000000000..09b5f86d89 --- /dev/null +++ b/project_forecast_line_milestone/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2024 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Project Forecast Line Milestone", + "summary": "Project Forecast Line dates according to Milestone target date", + "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_priority", "project_milestone"], + "installable": True, +} diff --git a/project_forecast_line_milestone/models/__init__.py b/project_forecast_line_milestone/models/__init__.py new file mode 100644 index 0000000000..edf2d36b9c --- /dev/null +++ b/project_forecast_line_milestone/models/__init__.py @@ -0,0 +1 @@ +from . import project_task diff --git a/project_forecast_line_milestone/models/project_task.py b/project_forecast_line_milestone/models/project_task.py new file mode 100644 index 0000000000..b6a1454307 --- /dev/null +++ b/project_forecast_line_milestone/models/project_task.py @@ -0,0 +1,26 @@ +# Copyright 2024 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import api, models + + +class ProjectTask(models.Model): + _inherit = "project.task" + + @api.depends("date_deadline", "milestone_id", "milestone_id.target_date") + def _compute_forecast_date_planned_end(self): + """Override method to use milestone_id.target_date""" + for this in self: + if this.milestone_id.target_date: + this.forecast_date_planned_end = this.milestone_id.target_date + continue + if this.date_deadline: + this.forecast_date_planned_end = this.date_deadline + continue + this.forecast_date_planned_end = this.forecast_date_planned_end + + def _get_forecast_date_planned(self, priority=None): + """Do not set forecast end if there exists a milestone date""" + self.ensure_one() + if self.milestone_id.target_date: + return False + return super()._get_forecast_date_planned(priority=priority) diff --git a/project_forecast_line_milestone/models/res_config_settings.py b/project_forecast_line_milestone/models/res_config_settings.py new file mode 100644 index 0000000000..70c39351f2 --- /dev/null +++ b/project_forecast_line_milestone/models/res_config_settings.py @@ -0,0 +1,96 @@ +# Copyright 2024 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + +TYPE_FORECAST_ENDDATE = [ + ("none", "None"), + ("date", "Date"), + ("delta", "Delta (in days)"), +] + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + forecast_line_priority_0_date = fields.Date( + inverse="_inverse_forecast_line_priority_date_str" + ) + forecast_line_priority_0_date_str = fields.Char( + config_parameter="project_forecast_line_priority.priority_0_date" + ) + forecast_line_priority_1_date = fields.Date( + inverse="_inverse_forecast_line_priority_date_str" + ) + forecast_line_priority_1_date_str = fields.Char( + config_parameter="project_forecast_line_priority.priority_1_date" + ) + forecast_line_priority_2_date = fields.Date( + inverse="_inverse_forecast_line_priority_date_str" + ) + forecast_line_priority_2_date_str = fields.Char( + config_parameter="project_forecast_line_priority.priority_2_date" + ) + forecast_line_priority_3_date = fields.Date( + inverse="_inverse_forecast_line_priority_date_str" + ) + forecast_line_priority_3_date_str = fields.Char( + config_parameter="project_forecast_line_priority.priority_3_date" + ) + forecast_line_priority_0 = fields.Integer( + config_parameter="project_forecast_line_priority.priority_0_delta" + ) + forecast_line_priority_1 = fields.Integer( + config_parameter="project_forecast_line_priority.priority_1_delta" + ) + forecast_line_priority_2 = fields.Integer( + config_parameter="project_forecast_line_priority.priority_2_delta" + ) + forecast_line_priority_3 = fields.Integer( + config_parameter="project_forecast_line_priority.priority_3_delta" + ) + forecast_line_priority_0_selection = fields.Selection( + TYPE_FORECAST_ENDDATE, + default="none", + config_parameter="project_forecast_line_priority.priority_0_selection", + required=True, + ) + forecast_line_priority_1_selection = fields.Selection( + TYPE_FORECAST_ENDDATE, + default="none", + config_parameter="project_forecast_line_priority.priority_1_selection", + required=True, + ) + forecast_line_priority_2_selection = fields.Selection( + TYPE_FORECAST_ENDDATE, + default="none", + config_parameter="project_forecast_line_priority.priority_2_selection", + required=True, + ) + forecast_line_priority_3_selection = fields.Selection( + TYPE_FORECAST_ENDDATE, + default="none", + config_parameter="project_forecast_line_priority.priority_3_selection", + required=True, + ) + + def _inverse_forecast_line_priority_date_str(self): + """As config_parameters does not accept Date field, + we store the date formated string into a Char config field""" + for setting in self: + if setting.forecast_line_priority_0_date: + setting.forecast_line_priority_0_date_str = fields.Date.to_string( + setting.forecast_line_priority_0_date + ) + if setting.forecast_line_priority_1_date: + setting.forecast_line_priority_1_date_str = fields.Date.to_string( + setting.forecast_line_priority_1_date + ) + if setting.forecast_line_priority_2_date: + setting.forecast_line_priority_2_date_str = fields.Date.to_string( + setting.forecast_line_priority_2_date + ) + if setting.forecast_line_priority_3_date: + setting.forecast_line_priority_3_date_str = fields.Date.to_string( + setting.forecast_line_priority_3_date + ) diff --git a/project_forecast_line_milestone/readme/CONTRIBUTORS.rst b/project_forecast_line_milestone/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..f27151686c --- /dev/null +++ b/project_forecast_line_milestone/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Nikos Tsirintanis diff --git a/project_forecast_line_milestone/readme/DESCRIPTION.rst b/project_forecast_line_milestone/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..6a24e1d85d --- /dev/null +++ b/project_forecast_line_milestone/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module recomputes forecast line end dates based on milestone target date of connected projects diff --git a/project_forecast_line_milestone/static/description/icon.png b/project_forecast_line_milestone/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_forecast_line_milestone/static/description/icon.png differ diff --git a/project_forecast_line_milestone/static/description/index.html b/project_forecast_line_milestone/static/description/index.html new file mode 100644 index 0000000000..9109b5c507 --- /dev/null +++ b/project_forecast_line_milestone/static/description/index.html @@ -0,0 +1,421 @@ + + + + + + +Project Forecast Line Milestone + + + +
+

Project Forecast Line Milestone

+ + +

Beta License: AGPL-3 OCA/project Translate me on Weblate Try me on Runboat

+

This module recomputes forecast line end dates based on milestone target date of connected projects

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Therp BV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/setup/project_forecast_line_milestone/odoo/addons/project_forecast_line_milestone b/setup/project_forecast_line_milestone/odoo/addons/project_forecast_line_milestone new file mode 120000 index 0000000000..27725a0b05 --- /dev/null +++ b/setup/project_forecast_line_milestone/odoo/addons/project_forecast_line_milestone @@ -0,0 +1 @@ +../../../../project_forecast_line_milestone \ No newline at end of file diff --git a/setup/project_forecast_line_milestone/setup.py b/setup/project_forecast_line_milestone/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/project_forecast_line_milestone/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)