Skip to content

Commit

Permalink
[14.0][IMP][WIP] project_forecast_line: fix backport unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsirintanis authored and thomaspaulb committed Jun 26, 2023
1 parent 86694a5 commit d696a91
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions project_forecast_line/tests/test_forecast_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from freezegun import freeze_time

from odoo.tests.common import Form, TransactionCase, tagged
from odoo.tests.common import Form, SavepointCase, tagged


@tagged("-at_install", "post_install")
class BaseForecastLineTest(TransactionCase):
class BaseForecastLineTest(SavepointCase):
@classmethod
@freeze_time("2022-01-01")
def setUpClass(cls):
Expand Down Expand Up @@ -369,6 +369,10 @@ def test_confirm_order_sale_order_create_project_task_with_forecast_line(self):
so.action_confirm()
line = so.order_line[0]
task = self.env["project.task"].search([("sale_line_id", "=", line.id)])
# Give a project_status to the project
task.project_id.project_status = self.env.ref(
"project_status.project_status_in_progress"
)
forecast_lines = self.env["forecast.line"].search(
[("res_id", "=", task.id), ("res_model", "=", "project.task")]
)
Expand Down Expand Up @@ -409,6 +413,10 @@ def test_timesheet_forecast_lines(self):
with freeze_time("2022-02-14"):
line = so.order_line[0]
task = self.env["project.task"].search([("sale_line_id", "=", line.id)])
# Give a project_status to the project
task.project_id.project_status = self.env.ref(
"project_status.project_status_in_progress"
)
# timesheet 1d
self.env["account.analytic.line"].create(
{
Expand Down Expand Up @@ -530,8 +538,8 @@ def test_task_forecast_lines_consolidated_forecast(self):
#
# Projet 1 is in TODO (not confirmed forecast)
project_1 = self.env["project.project"].create({"name": "TestProject1"})
# set project in stage "to do" to get forecast
project_1.stage_id = self.env.ref("project.project_project_stage_0")
# set project in stage "Pending" to get confirmed forecast
project_1.project_status = self.env.ref("project_status.project_status_pending")
task_values = {
"project_id": project_1.id,
"forecast_role_id": self.role_consultant.id,
Expand All @@ -541,20 +549,22 @@ def test_task_forecast_lines_consolidated_forecast(self):
}
task_values.update({"name": "Task1"})
task_1 = self.env["project.task"].create(task_values)
task_1.user_ids = self.user_consultant
task_1.user_id = self.user_consultant
task_values.update({"name": "Task2"})
task_2 = self.env["project.task"].create(task_values)
task_2.user_ids = self.user_consultant
task_2.user_id = self.user_consultant

# Project 2 is in stage "in progress" to get forecast
project_2 = self.env["project.project"].create({"name": "TestProject2"})
project_2.stage_id = self.env.ref("project.project_project_stage_1")
project_2.project_status = self.env.ref(
"project_status.project_status_in_progress"
)
task_values.update({"project_id": project_2.id, "name": "Task3"})
task_3 = self.env["project.task"].create(task_values)
task_3.user_ids = self.user_consultant
task_3.user_id = self.user_consultant
task_values.update({"name": "Task4"})
task_4 = self.env["project.task"].create(task_values)
task_4.user_ids = self.user_consultant
task_4.user_id = self.user_consultant

# check forecast lines
forecast = self.env["forecast.line"].search(
Expand Down

0 comments on commit d696a91

Please sign in to comment.