Skip to content

Commit

Permalink
[FIX] Unit test updating milestone with no project
Browse files Browse the repository at this point in the history
[FIX] Unit test updating milestone with no project

[FIX] Unit test updating milestone with no project

[CHG] Test on force compute

[FIX] Unit test updating milestone with no project

[FIX] Unit test updating milestone with no project

[FIX] Active field on project.milestone
  • Loading branch information
lanto-razafindrabe committed Jun 11, 2024
1 parent 74014a6 commit 6da0242
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions project_milestone_spent_hours/models/project_milestone.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,25 @@
class ProjectMilestone(models.Model):
_inherit = "project.milestone"

active = fields.Boolean("Active", default=True)
total_hours = fields.Float(
compute="_compute_total_hours",
string="Total Hours",
compute_sudo=True,
store=True,
)

def write(self, vals):
res = super(ProjectMilestone, self).write(vals)
if "project_id" in vals:
self._remove_task_milestones(vals["project_id"])
return res

def _remove_task_milestones(self, project_id):
self.with_context(active_test=False).mapped("project_task_ids").filtered(
lambda milestone: not project_id or milestone.project_id.id != project_id
).write({"milestone_id": False})

@api.depends(
"project_task_ids",
"project_task_ids.active",
Expand Down

0 comments on commit 6da0242

Please sign in to comment.