Skip to content

Commit

Permalink
[FIX] rma: fix returned quantity in picking return wizard
Browse files Browse the repository at this point in the history
fixes: OCA#418
  • Loading branch information
sbejaoui committed Sep 16, 2024
1 parent d13d941 commit 204665f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions rma/models/rma.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ def _prepare_reception_procurement_vals(self, group=None):
vals["to_refund"] = self.operation_id.action_create_refund == "update_quantity"
if self.move_id:
vals["origin_returned_move_id"] = self.move_id.id
vals["move_orig_ids"] = [(6, 0, self.move_id.ids)]
return vals

def _prepare_reception_procurements(self):
Expand Down
30 changes: 30 additions & 0 deletions rma/tests/test_rma.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,3 +848,33 @@ def test_autoconfirm_email(self):
)
self.assertTrue(rma.name in mail_receipt.subject)
self.assertTrue("products received" in mail_receipt.subject)

def _create_return_wizard(self, picking):
stock_return_picking_form = Form(
self.env["stock.return.picking"].with_context(
active_ids=picking.ids,
active_id=picking.id,
active_model="stock.picking",
)
)
stock_return_picking_form.create_rma = True
stock_return_picking_form.rma_operation_id = self.operation
return stock_return_picking_form.save()

def test_partial_return(self):
origin_delivery = self._create_delivery()
return_wizard = self._create_return_wizard(origin_delivery)
return_line = return_wizard.product_return_moves.filtered(
lambda m, p=self.product: m.product_id == p
)
self.assertEqual(return_line.quantity, 10)
return_line.quantity = 5
picking_action = return_wizard.create_returns()
reception = self.env["stock.picking"].browse(picking_action["res_id"])
move = reception.move_ids.filtered(lambda m, p=self.product: m.product_id == p)
self.assertEqual(move.product_qty, 5)
return_wizard = self._create_return_wizard(origin_delivery)
return_line = return_wizard.product_return_moves.filtered(
lambda m, p=self.product: m.product_id == p
)
self.assertEqual(return_line.quantity, 5)

0 comments on commit 204665f

Please sign in to comment.