Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test debug #329

Open
wants to merge 7 commits into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions project_milestone_time_progress/models/project_milestone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)