Skip to content

Commit

Permalink
fixup! fixup! [MIG] project_forecast_line: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsirintanis committed Apr 11, 2024
1 parent 549bdc6 commit 7ffa1c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion project_forecast_line/models/forecast_line_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ForecastLineModelMixin(models.Model):

def _get_forecast_lines(self, domain=None):
self.ensure_one()
base_domain = [("res.model", "=", self._name), ("res_id", "=", self.id)]
base_domain = [("res_model", "=", self._name), ("res_id", "=", self.id)]
if domain is not None:
base_domain += domain
return self.env["forecast.line"].search(base_domain)
16 changes: 9 additions & 7 deletions project_forecast_line/tests/test_forecast_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,21 @@ def _create_sale(
):
with Form(self.env["sale.order"]) as form:
form.partner_id = self.customer
form.date_order = "2022-01-10 08:00:00"
form.default_forecast_date_start = default_forecast_date_start
form.default_forecast_date_end = default_forecast_date_end
with form.order_line.new() as line:
line.product_id = self.product_dev_tm
line.product_uom_qty = uom_qty # 1 FTE sold
line.product_uom = self.env.ref("uom.product_uom_day")
so = form.save()
so.date_order = "2022-01-10 08:00:00"
so.default_forecast_date_start = default_forecast_date_start
so.default_forecast_date_end = default_forecast_date_end
return so

@freeze_time("2022-01-01")
def test_draft_sale_order_creates_negative_forecast_forecast(self):
so = self._create_sale("2022-02-07", "2022-02-20")
line = so.order_line[0]
line._onchange_product_id_warning()
self.assertEqual(line.forecast_date_start, date(2022, 2, 7))
self.assertEqual(line.forecast_date_end, date(2022, 2, 20))
forecast_lines = self.env["forecast.line"].search(
Expand Down Expand Up @@ -333,6 +334,7 @@ def test_draft_sale_order_without_dates_no_forecast(self):
"""a draft sale order with no dates on the line does not create forecast"""
so = self._create_sale("2022-02-07", False)
line = so.order_line[0]
line._onchange_product_id_warning()
self.assertEqual(line.forecast_date_start, date(2022, 2, 7))
self.assertEqual(line.forecast_date_end, False)
forecast_lines = self.env["forecast.line"].search(
Expand All @@ -348,6 +350,7 @@ def test_draft_sale_order_forecast_spread(self):
so = self._create_sale("2022-02-07", "2022-04-17", uom_qty=100)

line = so.order_line[0]
line._onchange_product_id_warning()
self.assertEqual(line.forecast_date_start, date(2022, 2, 7))
self.assertEqual(line.forecast_date_end, date(2022, 4, 17))
forecast_lines = self.env["forecast.line"].search(
Expand Down Expand Up @@ -424,16 +427,16 @@ def test_timesheet_forecast_lines(self):
with freeze_time("2022-01-01"):
with Form(self.env["sale.order"]) as form:
form.partner_id = self.customer
form.date_order = "2022-01-10 08:00:00"
form.default_forecast_date_start = "2022-02-14"
form.default_forecast_date_end = "2022-04-17"
with form.order_line.new() as line:
line.product_id = self.product_dev_tm
line.product_uom_qty = (
45 * 2
) # 45 working days in the period, sell 2 FTE
line.product_uom = self.env.ref("uom.product_uom_day")
so = form.save()
so.date_order = "2022-01-10 08:00:00"
so.default_forecast_date_start = "2022-02-14"
so.default_forecast_date_end = "2022-04-17"
so.action_confirm()

with freeze_time("2022-02-14"):
Expand Down Expand Up @@ -696,7 +699,6 @@ def test_task_forecast_lines_consolidated_forecast(self):
task_values.update({"name": "Task2"})
task_2 = ProjectTask.create(task_values)
task_2.user_ids = self.user_consultant

# Project 2 is in stage "in rogress" to get forecast
project_2 = ProjectProject.create({"name": "TestProject2"})
project_2.stage_id = self.env.ref("project.project_project_stage_1")
Expand Down

0 comments on commit 7ffa1c0

Please sign in to comment.