From 7dec674d86fd91ceb173e0cd0817f8263f1e68cf Mon Sep 17 00:00:00 2001 From: Lanto Razafindrabe Date: Tue, 23 May 2023 08:07:06 +0300 Subject: [PATCH 1/6] Unit test debug --- .../tests/test_project_milestone_progress.py | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) 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..275d9541 100644 --- a/project_milestone_time_progress/tests/test_project_milestone_progress.py +++ b/project_milestone_time_progress/tests/test_project_milestone_progress.py @@ -49,17 +49,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.estimated_hours, "999") + self.assertEqual(self.milestone_2.show_progress_info_message, True) From 0fb092b0ac6fe21ad1ad9a365759b5fc2ebb61ff Mon Sep 17 00:00:00 2001 From: Lanto Razafindrabe Date: Tue, 23 May 2023 08:19:27 +0300 Subject: [PATCH 2/6] debug unit test --- project_milestone_time_progress/models/project_milestone.py | 2 ++ .../tests/test_project_milestone_progress.py | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/project_milestone_time_progress/models/project_milestone.py b/project_milestone_time_progress/models/project_milestone.py index 17ba6f38..d240784f 100644 --- a/project_milestone_time_progress/models/project_milestone.py +++ b/project_milestone_time_progress/models/project_milestone.py @@ -2,6 +2,7 @@ # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). from odoo import fields, models, api +from odoo.exceptions import UserError class ProjectMilestone(models.Model): @@ -23,6 +24,7 @@ def _compute_milestone_progress(self): progress = round( (record.total_hours / record.estimated_hours) * 100, 2) else: + raise UserError('this is triggered.') 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 275d9541..93e20728 100644 --- a/project_milestone_time_progress/tests/test_project_milestone_progress.py +++ b/project_milestone_time_progress/tests/test_project_milestone_progress.py @@ -58,5 +58,4 @@ def test_show_progress_info(self): "project_id": self.project.id, } ) - self.assertEqual(self.milestone_2.estimated_hours, "999") self.assertEqual(self.milestone_2.show_progress_info_message, True) From 29d073c8f53b9441b2c5855846a2b45cda08f431 Mon Sep 17 00:00:00 2001 From: Lanto Razafindrabe Date: Tue, 23 May 2023 08:36:12 +0300 Subject: [PATCH 3/6] test circleci --- project_milestone_time_progress/models/project_milestone.py | 2 -- .../tests/test_project_milestone_progress.py | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/project_milestone_time_progress/models/project_milestone.py b/project_milestone_time_progress/models/project_milestone.py index d240784f..17ba6f38 100644 --- a/project_milestone_time_progress/models/project_milestone.py +++ b/project_milestone_time_progress/models/project_milestone.py @@ -2,7 +2,6 @@ # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). from odoo import fields, models, api -from odoo.exceptions import UserError class ProjectMilestone(models.Model): @@ -24,7 +23,6 @@ def _compute_milestone_progress(self): progress = round( (record.total_hours / record.estimated_hours) * 100, 2) else: - raise UserError('this is triggered.') 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 93e20728..675c002a 100644 --- a/project_milestone_time_progress/tests/test_project_milestone_progress.py +++ b/project_milestone_time_progress/tests/test_project_milestone_progress.py @@ -58,4 +58,5 @@ def test_show_progress_info(self): "project_id": self.project.id, } ) + self.assertEqual(self.milestone_2.show_info_message, True) self.assertEqual(self.milestone_2.show_progress_info_message, True) From bfa5f5a7e56052321b7462db5c1dee9bd3b9fcf5 Mon Sep 17 00:00:00 2001 From: Lanto Razafindrabe Date: Tue, 23 May 2023 08:46:27 +0300 Subject: [PATCH 4/6] @lanto-razafindrabe test circleci --- .../tests/test_project_milestone_progress.py | 1 - 1 file changed, 1 deletion(-) 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 675c002a..93e20728 100644 --- a/project_milestone_time_progress/tests/test_project_milestone_progress.py +++ b/project_milestone_time_progress/tests/test_project_milestone_progress.py @@ -58,5 +58,4 @@ def test_show_progress_info(self): "project_id": self.project.id, } ) - self.assertEqual(self.milestone_2.show_info_message, True) self.assertEqual(self.milestone_2.show_progress_info_message, True) From e56b21f531c7b9be961aa52e863ee7da0b2f3634 Mon Sep 17 00:00:00 2001 From: Lanto Razafindrabe Date: Tue, 23 May 2023 08:52:08 +0300 Subject: [PATCH 5/6] test circleci --- project_milestone_time_progress/models/project_milestone.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project_milestone_time_progress/models/project_milestone.py b/project_milestone_time_progress/models/project_milestone.py index 17ba6f38..f212d035 100644 --- a/project_milestone_time_progress/models/project_milestone.py +++ b/project_milestone_time_progress/models/project_milestone.py @@ -16,9 +16,9 @@ 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: + progress = 0.0 + show_info_message = False if record.estimated_hours: progress = round( (record.total_hours / record.estimated_hours) * 100, 2) From 3f803195e2fa7f8d815fe38bd3204c3402258519 Mon Sep 17 00:00:00 2001 From: Lanto Razafindrabe Date: Tue, 23 May 2023 10:35:24 +0300 Subject: [PATCH 6/6] TA#52405 [FIX] project_milestone_time_progress : fixing milestone show_progress --- project_milestone_time_progress/models/project_milestone.py | 3 +-- .../tests/test_project_milestone_progress.py | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/project_milestone_time_progress/models/project_milestone.py b/project_milestone_time_progress/models/project_milestone.py index f212d035..950f7a0c 100644 --- a/project_milestone_time_progress/models/project_milestone.py +++ b/project_milestone_time_progress/models/project_milestone.py @@ -19,10 +19,9 @@ def _compute_milestone_progress(self): for record in self: progress = 0.0 show_info_message = False - if record.estimated_hours: + 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 93e20728..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", @@ -58,4 +59,5 @@ def test_show_progress_info(self): "project_id": self.project.id, } ) - self.assertEqual(self.milestone_2.show_progress_info_message, True) + self.assertEqual(self.milestone_2.progress, 0) + self.assertEqual(self.milestone_2.show_progress_info_message, False)