diff --git a/project_workload/__manifest__.py b/project_workload/__manifest__.py index 8b4d7f55..a42124b8 100644 --- a/project_workload/__manifest__.py +++ b/project_workload/__manifest__.py @@ -21,6 +21,7 @@ "views/project_task_workload_view.xml", "views/project_task_view.xml", "views/project_project_view.xml", + "views/project_task_workload_unit_view.xml", "views/menu_view.xml", ], } diff --git a/project_workload/models/project_workload_unit.py b/project_workload/models/project_workload_unit.py index b5ed9644..d75a8991 100644 --- a/project_workload/models/project_workload_unit.py +++ b/project_workload/models/project_workload_unit.py @@ -3,7 +3,7 @@ # @author Florian Mounier # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import fields, models +from odoo import api, fields, models class ProjectWorkloadUnit(models.Model): @@ -18,8 +18,21 @@ class ProjectWorkloadUnit(models.Model): ) task_id = fields.Many2one("project.task", "Task", related="workload_id.task_id") project_id = fields.Many2one( - "project.project", "Project", related="workload_id.project_id" + "project.project", + "Project", + related="workload_id.project_id", + store=True, ) + done = fields.Boolean(compute="_compute_done", store=True) + + def is_done(self): + self.ensure_one() + return self.task_id.stage_id.is_closed + + @api.depends("task_id.stage_id.is_closed") + def _compute_done(self): + for record in self: + record.done = record.is_done() def name_get(self): result = [] diff --git a/project_workload/views/menu_view.xml b/project_workload/views/menu_view.xml index 7bf00df1..cd58d3c8 100644 --- a/project_workload/views/menu_view.xml +++ b/project_workload/views/menu_view.xml @@ -9,4 +9,12 @@ groups="project_workload.group_project_workload" /> + + diff --git a/project_workload/views/project_task_workload_unit_view.xml b/project_workload/views/project_task_workload_unit_view.xml new file mode 100644 index 00000000..f5628bda --- /dev/null +++ b/project_workload/views/project_task_workload_unit_view.xml @@ -0,0 +1,66 @@ + + + + + project.workload.unit + + + + + + + + + + + + + + project.workload.unit + + + + + + + + + + + + + + + + + Workload + ir.actions.act_window + project.workload.unit + tree + + [] + {'search_default_my_load': 1, 'search_default_groupby_week': 1} + + + diff --git a/project_workload_timesheet/models/project_workload_unit.py b/project_workload_timesheet/models/project_workload_unit.py index 3a8f39b5..8fe0f318 100644 --- a/project_workload_timesheet/models/project_workload_unit.py +++ b/project_workload_timesheet/models/project_workload_unit.py @@ -31,13 +31,17 @@ class ProjectWorkloadUnit(models.Model): compute="_compute_progress", help="The progress of the task", ) - done = fields.Boolean( - "Done", + force_done = fields.Boolean( + "Force Done", ) task_stage_id = fields.Many2one( related="task_id.stage_id", string="Task Stage", readonly=False ) + @api.depends("force_done") + def is_done(self): + return super().is_done() or self.force_done + @api.depends("timesheet_ids.unit_amount") def _compute_timesheeted_hours(self): for record in self: @@ -82,7 +86,7 @@ def action_timesheet_time(self): return True def action_timesheet_done(self): - self.done = True + self.force_done = True def _get_timesheeting_task(self): # For overrides