Skip to content

Commit

Permalink
[FIX] rma: same procurement group for reception and delivery
Browse files Browse the repository at this point in the history
The procurement group created for reception was not being correctly assigned to the RMA,
resulting in a different group being generated for the delivery.

This fix ensures that the same procurement group is used for both operations.
  • Loading branch information
sbejaoui committed Aug 29, 2024
1 parent 6197962 commit 702a7d1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions rma/models/rma.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ def _prepare_reception_procurements(self):
group = rma.procurement_group_id
if not group:
group = group_model.create(rma._prepare_procurement_group_vals())
rma.procurement_group_id = group
procurements.append(
group_model.Procurement(
rma.product_id,
Expand Down
15 changes: 15 additions & 0 deletions rma/tests/test_rma.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,3 +848,18 @@ def test_autoconfirm_email(self):
)
self.assertTrue(rma.name in mail_receipt.subject)
self.assertTrue("products received" in mail_receipt.subject)

def test_same_procurement_group_for_reception_and_delivery(self):
rma = self._create_confirm_receive(self.partner, self.product, 10, self.rma_loc)
self.assertTrue(rma.procurement_group_id)
delivery_form = Form(
self.env["rma.delivery.wizard"].with_context(
active_ids=rma.ids,
rma_delivery_type="return",
)
)
delivery_form.product_uom_qty = 2
delivery_wizard = delivery_form.save()
delivery_wizard.action_deliver()
self.assertEqual(rma.delivery_move_ids.group_id, rma.procurement_group_id)
self.assertEqual(rma.delivery_move_ids.group_id, rma.reception_move_id.group_id)
12 changes: 0 additions & 12 deletions rma_sale/models/rma.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,3 @@ def _prepare_refund_line_vals(self):
):
vals["sale_line_ids"] = [(4, line.id)]
return vals

def _prepare_procurement_group_vals(self):
vals = super()._prepare_procurement_group_vals()
if not self.env.context.get("ignore_rma_sale_order") and self.order_id:
vals["sale_id"] = self.order_id.id
return vals

def _prepare_delivery_procurements(self, scheduled_date=None, qty=None, uom=None):
self = self.with_context(ignore_rma_sale_order=True)
return super()._prepare_delivery_procurements(
scheduled_date=scheduled_date, qty=qty, uom=uom
)

0 comments on commit 702a7d1

Please sign in to comment.