From 7ffa1c0ebc181ad3d2e1fedb69f4683fadf02d6c Mon Sep 17 00:00:00 2001 From: ntsirintanis Date: Thu, 11 Apr 2024 16:01:56 +0200 Subject: [PATCH] fixup! fixup! [MIG] project_forecast_line: Migration to 16.0 --- .../models/forecast_line_mixin.py | 2 +- .../tests/test_forecast_line.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/project_forecast_line/models/forecast_line_mixin.py b/project_forecast_line/models/forecast_line_mixin.py index fba9db3c3a..b4da827c4f 100644 --- a/project_forecast_line/models/forecast_line_mixin.py +++ b/project_forecast_line/models/forecast_line_mixin.py @@ -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) diff --git a/project_forecast_line/tests/test_forecast_line.py b/project_forecast_line/tests/test_forecast_line.py index 07a2b86dcd..3e3e4fb1cc 100644 --- a/project_forecast_line/tests/test_forecast_line.py +++ b/project_forecast_line/tests/test_forecast_line.py @@ -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( @@ -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( @@ -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( @@ -424,9 +427,6 @@ 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 = ( @@ -434,6 +434,9 @@ def test_timesheet_forecast_lines(self): ) # 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"): @@ -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")