From 94032d8d91497b70be7a4311a3dfa82d2ed5ba2c Mon Sep 17 00:00:00 2001 From: Djamel Touati Date: Wed, 3 Apr 2024 13:58:15 +0000 Subject: [PATCH] [FIX] purchase_requisition_stock: propagate the group_id in dropshipping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the issue: - Create a storable product “P1”: - Route: dropship - Vendor: Azure interior and deco addict - Create a sales order with one unit of P1 - Confirm the sales order - A purchase order is generated with a dropship-picking (linked to the SO) - Create an alternative PO and confirm it Problem: The alternative PO is linked to the SO, but the dropship-picking is not linked. This is because the procurement is not propagated when creating the alternative PO. opw-3828132 closes odoo/odoo#162815 X-original-commit: 727eae85cf532e2b7057a5645550e67875c37d62 Signed-off-by: Quentin Wolfs (quwo) Signed-off-by: Djamel Touati (otd) --- .../tests/test_purchase_requisition_stock.py | 17 +++++++++++++++++ .../purchase_requisition_create_alternative.py | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/addons/purchase_requisition_stock/tests/test_purchase_requisition_stock.py b/addons/purchase_requisition_stock/tests/test_purchase_requisition_stock.py index 8e08c5cc4ad..7130b112d35 100644 --- a/addons/purchase_requisition_stock/tests/test_purchase_requisition_stock.py +++ b/addons/purchase_requisition_stock/tests/test_purchase_requisition_stock.py @@ -314,3 +314,20 @@ class TestPurchaseRequisitionStock(TestPurchaseRequisitionCommon): # Quantity should be reserved in the internal transfer's move self.assertEqual(int_move.quantity, 10, "Quantity should be reserved in the original internal move.") self.assertEqual(int_move.move_orig_ids.id, in_picking.move_ids.id, "Both moves should be correctly chained together.") + + def test_group_id_alternative_po(self): + """ Check that the group_id is propagated in the alternative PO""" + pg1 = self.env['procurement.group'].create({}) + orig_po = self.env['purchase.order'].create({ + 'partner_id': self.res_partner_1.id, + 'group_id': pg1.id + }) + # Creates an alternative PO + action = orig_po.action_create_alternative() + alt_po_wizard_form = Form(self.env['purchase.requisition.create.alternative'].with_context(**action['context'])) + alt_po_wizard_form.partner_id = self.res_partner_1 + alt_po_wizard_form.copy_products = True + alt_po_wizard = alt_po_wizard_form.save() + alt_po_id = alt_po_wizard.action_create_alternative()['res_id'] + alt_po = self.env['purchase.order'].browse(alt_po_id) + self.assertEqual(alt_po.group_id, orig_po.group_id) diff --git a/addons/purchase_requisition_stock/wizard/purchase_requisition_create_alternative.py b/addons/purchase_requisition_stock/wizard/purchase_requisition_create_alternative.py index 23fd18b4586..898d838c6b2 100644 --- a/addons/purchase_requisition_stock/wizard/purchase_requisition_create_alternative.py +++ b/addons/purchase_requisition_stock/wizard/purchase_requisition_create_alternative.py @@ -9,7 +9,10 @@ class PurchaseRequisitionCreateAlternative(models.TransientModel): def _get_alternative_values(self): vals = super(PurchaseRequisitionCreateAlternative, self)._get_alternative_values() - vals['picking_type_id'] = self.origin_po_id.picking_type_id.id + vals.update({ + 'picking_type_id': self.origin_po_id.picking_type_id.id, + 'group_id': self.origin_po_id.group_id.id, + }) return vals @api.model