Skip to content

Commit

Permalink
[ADD] project_forecast_line_milestone
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsirintanis committed Feb 8, 2024
1 parent b2438cc commit ef1a28f
Show file tree
Hide file tree
Showing 12 changed files with 643 additions and 0 deletions.
76 changes: 76 additions & 0 deletions project_forecast_line_milestone/README.rst
Original file line number Diff line number Diff line change
@@ -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 <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_milestone%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_milestone>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions project_forecast_line_milestone/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions project_forecast_line_milestone/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
1 change: 1 addition & 0 deletions project_forecast_line_milestone/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import project_task
26 changes: 26 additions & 0 deletions project_forecast_line_milestone/models/project_task.py
Original file line number Diff line number Diff line change
@@ -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)
96 changes: 96 additions & 0 deletions project_forecast_line_milestone/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -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
)
1 change: 1 addition & 0 deletions project_forecast_line_milestone/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Nikos Tsirintanis <[email protected]>
1 change: 1 addition & 0 deletions project_forecast_line_milestone/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module recomputes forecast line end dates based on milestone target date of connected projects
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ef1a28f

Please sign in to comment.