diff --git a/project_milestone_time_progress/models/project_milestone.py b/project_milestone_time_progress/models/project_milestone.py index 17ba6f38..950f7a0c 100644 --- a/project_milestone_time_progress/models/project_milestone.py +++ b/project_milestone_time_progress/models/project_milestone.py @@ -16,13 +16,12 @@ class ProjectMilestone(models.Model): @api.depends('estimated_hours', 'total_hours') def _compute_milestone_progress(self): - progress = 0.0 - show_info_message = False for record in self: - if record.estimated_hours: + progress = 0.0 + show_info_message = False + if record.estimated_hours > 0: progress = round( (record.total_hours / record.estimated_hours) * 100, 2) - else: show_info_message = True record.progress = progress record.show_progress_info_message = show_info_message diff --git a/project_milestone_time_progress/tests/test_project_milestone_progress.py b/project_milestone_time_progress/tests/test_project_milestone_progress.py index 4f47e539..39ff5bad 100644 --- a/project_milestone_time_progress/tests/test_project_milestone_progress.py +++ b/project_milestone_time_progress/tests/test_project_milestone_progress.py @@ -9,7 +9,8 @@ class TestMilestoneProgress(SavepointCase): def setUpClass(cls): super().setUpClass() - cls.project = cls.env["project.project"].create({"name": "My Project"}) + cls.project = cls.env["project.project"].create( + {"name": "My Project", "use_milestones": True}) cls.milestone_1 = cls.env["project.milestone"].create( {"name": "My Milestone 1", @@ -49,17 +50,14 @@ def setUpClass(cls): def test_progress_calculation(self): self.assertEqual(self.milestone_1.progress, 25) - # def test_show_progress_info(self): - # self.env["account.analytic.line"].create( - # { - # "name": "My Timesheet 2", - # "task_id": self.task_2.id, - # "unit_amount": 20, - # "project_id": self.project.id, - # } - # ) - # self.assertEqual(self.milestone_2.show_progress_info_message, True) - - - - + def test_show_progress_info(self): + self.env["account.analytic.line"].create( + { + "name": "My Timesheet 2", + "task_id": self.task_2.id, + "unit_amount": 20, + "project_id": self.project.id, + } + ) + self.assertEqual(self.milestone_2.progress, 0) + self.assertEqual(self.milestone_2.show_progress_info_message, False)