From c39bac4be4093f58563201e88257a1f898ea850d Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Tue, 4 Mar 2025 08:49:05 +0100 Subject: [PATCH] [IMP] stock_release_channel_shipment_advice_toursolver: link ts task to rc --- .../models/__init__.py | 1 + .../models/shipment_advice.py | 18 ++++++++++++++++++ .../test_shipment_advice_planner_toursolver.py | 1 + 3 files changed, 20 insertions(+) create mode 100644 stock_release_channel_shipment_advice_toursolver/models/shipment_advice.py diff --git a/stock_release_channel_shipment_advice_toursolver/models/__init__.py b/stock_release_channel_shipment_advice_toursolver/models/__init__.py index 5943f65274a..24db19cf91c 100644 --- a/stock_release_channel_shipment_advice_toursolver/models/__init__.py +++ b/stock_release_channel_shipment_advice_toursolver/models/__init__.py @@ -1,2 +1,3 @@ from . import stock_release_channel from . import toursolver_task +from . import shipment_advice diff --git a/stock_release_channel_shipment_advice_toursolver/models/shipment_advice.py b/stock_release_channel_shipment_advice_toursolver/models/shipment_advice.py new file mode 100644 index 00000000000..0cb2ece2051 --- /dev/null +++ b/stock_release_channel_shipment_advice_toursolver/models/shipment_advice.py @@ -0,0 +1,18 @@ +# Copyright 2025 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class ShipmentAdvice(models.Model): + + _inherit = "shipment.advice" + + def create_toursolver_task(self): + self.ensure_one() + res = super().create_toursolver_task() + task = self.toursolver_task_id + rc = self.release_channel_id + task.release_channel_id = rc + task.name = f"{task.name} {rc.name}" + return res diff --git a/stock_release_channel_shipment_advice_toursolver/tests/test_shipment_advice_planner_toursolver.py b/stock_release_channel_shipment_advice_toursolver/tests/test_shipment_advice_planner_toursolver.py index c6effc6d438..8205db3a2f5 100644 --- a/stock_release_channel_shipment_advice_toursolver/tests/test_shipment_advice_planner_toursolver.py +++ b/stock_release_channel_shipment_advice_toursolver/tests/test_shipment_advice_planner_toursolver.py @@ -45,3 +45,4 @@ def test_plan_shipment_toursolver(self): ) self.assertTrue(self.channel.shipment_advice_ids) self.assertEqual(self.channel.shipment_advice_ids, task.shipment_advice_ids) + self.assertEqual(task.release_channel_id, self.channel)