From 0d8983d4c097b33f5b37039d2cbdc67217509e11 Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Fri, 31 Mar 2023 10:24:56 +0200 Subject: [PATCH] [FIX] - group pickings to plan by picking type instead of the warehouse --- .../wizards/shipment_advice_planner.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/shipment_advice_planner_toursolver/wizards/shipment_advice_planner.py b/shipment_advice_planner_toursolver/wizards/shipment_advice_planner.py index 74c7e88d..499230e0 100644 --- a/shipment_advice_planner_toursolver/wizards/shipment_advice_planner.py +++ b/shipment_advice_planner_toursolver/wizards/shipment_advice_planner.py @@ -28,8 +28,8 @@ class ShipmentAdvicePlanner(models.TransientModel): comodel_name="toursolver.task", string="Toursolver Task", readonly=True ) - def _prepare_shipment_advice_common_vals(self, warehouse): - res = super()._prepare_shipment_advice_common_vals(warehouse) + def _prepare_shipment_advice_common_vals(self, picking_type): + res = super()._prepare_shipment_advice_common_vals(picking_type) res.update( { "toursolver_resource_id": self.toursolver_resource_id.id, @@ -43,26 +43,26 @@ def _plan_shipments_for_method(self): if self.shipment_planning_method != "toursolver": return super()._plan_shipments_for_method() for ( - warehouse, + picking_type, pickings_to_plan, - ) in self._get_picking_to_plan_by_warehouse().items(): - self._init_toursolver_task(warehouse, pickings_to_plan) + ) in self._get_picking_to_plan_by_picking_type().items(): + self._init_toursolver_task(picking_type, pickings_to_plan) return self.env["shipment.advice"] - def _prepare_toursolver_task_vals(self, warehouse, pickings_to_plan): + def _prepare_toursolver_task_vals(self, picking_type, pickings_to_plan): task_model = self.env["toursolver.task"] backend = task_model._get_default_toursolver_backend() return { "toursolver_backend_id": backend.id, - "warehouse_id": warehouse.id, + "warehouse_id": picking_type.warehouse_id.id, "dock_id": self.dock_id.id, "picking_ids": [Command.set(pickings_to_plan.ids)], "delivery_resource_ids": [Command.set(self.delivery_resource_ids.ids)], } - def _init_toursolver_task(self, warehouse, pickings_to_plan): + def _init_toursolver_task(self, picking_type, pickings_to_plan): task_model = self.env["toursolver.task"] # create access is not given to any group return task_model.sudo().create( - self._prepare_toursolver_task_vals(warehouse, pickings_to_plan) + self._prepare_toursolver_task_vals(picking_type, pickings_to_plan) )