[FIX] purchase_requisition_stock: propagate the group_id in dropshipping

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) <quwo@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
This commit is contained in:
Djamel Touati
2024-04-23 09:20:47 +00:00
parent 488205d679
commit 94032d8d91
2 changed files with 21 additions and 1 deletions
@@ -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)
@@ -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