From bac440f07a90a3c4c158eda5efc8732e885be08a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Mon, 25 Nov 2024 14:01:16 +0100 Subject: [PATCH] [FIX] sale_procurement_group_by_line: update to odoo Adapt to: - https://github.com/odoo/odoo/commit/4cc2b3bcca613dfb37bb77e5fef6de6e044e3399. - https://github.com/odoo/odoo/commit/17bece3e797913bcba8dd7e07fc8541c0a45e3f7 - https://github.com/odoo/odoo/commit/60f08ffbccca07adba6a5449d22496b14c321901 --- sale_procurement_group_by_line/model/sale.py | 17 ++++++----------- .../test_sale_procurement_group_by_line.py | 4 ++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/sale_procurement_group_by_line/model/sale.py b/sale_procurement_group_by_line/model/sale.py index d825dac3c08..dfd54de2822 100644 --- a/sale_procurement_group_by_line/model/sale.py +++ b/sale_procurement_group_by_line/model/sale.py @@ -40,7 +40,11 @@ def _action_launch_stock_rule(self, previous_product_uom_qty=False): previous_product_uom_qty = {} for line in self: line = line.with_company(line.company_id) - if line.state != "sale" or line.product_id.type not in ("consu", "product"): + if ( + line.state != "sale" + or line.order_id.locked + or line.product_id.type not in ("consu", "product") + ): continue qty = line._get_qty_procurement(previous_product_uom_qty) if ( @@ -88,16 +92,7 @@ def _action_launch_stock_rule(self, previous_product_uom_qty=False): ) procurements.append( - self.env["procurement.group"].Procurement( - line.product_id, - product_qty, - procurement_uom, - line.order_id.partner_shipping_id.property_stock_customer, - line.display_name, - line.order_id.name, - line.order_id.company_id, - values, - ) + line._create_procurement(product_qty, procurement_uom, values) ) # We store the procured quantity in the UoM of the line to avoid # duplicated procurements, specially for dropshipping and kits. diff --git a/sale_procurement_group_by_line/tests/test_sale_procurement_group_by_line.py b/sale_procurement_group_by_line/tests/test_sale_procurement_group_by_line.py index 3f0a0a9e207..a36a6dd7e87 100644 --- a/sale_procurement_group_by_line/tests/test_sale_procurement_group_by_line.py +++ b/sale_procurement_group_by_line/tests/test_sale_procurement_group_by_line.py @@ -96,9 +96,9 @@ def test_02_action_launch_procurement_rule_1(self): self.sale.action_confirm() self.assertEqual(self.sale.state, "sale") self.assertEqual(len(self.line1.move_ids), 1) - self.assertEqual(self.line1.move_ids.name, self.line1.display_name) + self.assertEqual(self.line1.move_ids.name, self.line1.product_id.display_name) self.assertEqual(len(self.line2.move_ids), 1) - self.assertEqual(self.line2.move_ids.name, self.line2.display_name) + self.assertEqual(self.line2.move_ids.name, self.line2.product_id.display_name) def test_03_action_launch_procurement_rule_2(self): group_id = self.proc_group_model.create(