Skip to content

Commit

Permalink
[16.0] rma: Automatically confirms RMA receptions upon RMA confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
sbejaoui committed Dec 16, 2024
1 parent 4c747d9 commit 1d5bce5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions rma/models/rma.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,9 @@ def _create_receipt(self):
if procurements:
self.env["procurement.group"].run(procurements)
self.reception_move_id.picking_id.action_assign()
if self.operation_id.auto_confirm_reception:
self.reception_move_id._set_quantities_to_reservation()
self.reception_move_id._action_done()

def action_create_receipt(self):
self.ensure_one()
Expand Down
4 changes: 4 additions & 0 deletions rma/models/rma_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class RmaOperation(models.Model):
help="If checked, allows the return of a product different from the one "
"originally ordered. Used if the delivery is created automatically",
)
auto_confirm_reception = fields.Boolean(
help="Enable this option to automatically confirm the reception when the RMA is"
" confirmed."
)
action_create_delivery = fields.Selection(
[
("manual_on_confirm", "Manually on Confirm"),
Expand Down
13 changes: 13 additions & 0 deletions rma/tests/test_rma_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,16 @@ def test_rma_replace_pick_ship(self):
self.assertIn(
self.warehouse.out_type_id, out_pickings.mapped("picking_type_id")
)

def test_16(self):
rma = self._create_rma(self.partner, self.product, 1, self.rma_loc)
rma.action_confirm()
self.assertEqual(rma.reception_move_id.state, "assigned")
self.assertEqual(rma.reception_move_id.picking_id.state, "assigned")

def test_17(self):
self.operation.auto_confirm_reception = True
rma = self._create_rma(self.partner, self.product, 1, self.rma_loc)
rma.action_confirm()
self.assertEqual(rma.reception_move_id.state, "done")
self.assertEqual(rma.reception_move_id.picking_id.state, "done")
5 changes: 4 additions & 1 deletion rma/views/rma_operation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
<group>
<field
name="different_return_product"
widget="boolean_toggle"
attrs="{'invisible': [('action_create_receipt', '=', False)]}"
/>
<field
name="auto_confirm_reception"
attrs="{'invisible': [('action_create_receipt', '=', False)]}"
/>
</group>
Expand Down

0 comments on commit 1d5bce5

Please sign in to comment.