diff --git a/rma_sale/__manifest__.py b/rma_sale/__manifest__.py index e3d3da72..0c3232d7 100644 --- a/rma_sale/__manifest__.py +++ b/rma_sale/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Return Merchandise Authorization Management - Link with Sales", "summary": "Sale Order - Return Merchandise Authorization (RMA)", - "version": "12.0.1.4.0", + "version": "12.0.1.4.1", "development_status": "Beta", "category": "RMA", "website": "https://github.com/OCA/rma", @@ -12,7 +12,7 @@ "license": "AGPL-3", "depends": [ "rma", - "sale", + "sale_stock", ], "data": [ "views/assets.xml", diff --git a/rma_sale/models/rma.py b/rma_sale/models/rma.py index c647e771..c3a947fc 100644 --- a/rma_sale/models/rma.py +++ b/rma_sale/models/rma.py @@ -81,3 +81,10 @@ class Rma(models.Model): @api.onchange('order_id') def _onchange_order_id(self): self.product_id = self.picking_id = False + + def _prepare_refund(self, invoice_form, origin): + """Inject salesman from sales order (if any)""" + res = super()._prepare_refund(invoice_form, origin) + if self.order_id: + invoice_form.user_id = self.order_id.user_id + return res diff --git a/rma_sale/tests/test_rma_sale.py b/rma_sale/tests/test_rma_sale.py index ddac44b1..ab0198be 100644 --- a/rma_sale/tests/test_rma_sale.py +++ b/rma_sale/tests/test_rma_sale.py @@ -70,3 +70,16 @@ class TestRmaSale(SavepointCase): rma.reception_move_id.picking_id + self.order_out_picking, order.picking_ids, ) + # Refund the RMA + user = self.env["res.users"].create( + { + "login": "test_refund_with_so", + "name": "Test", + } + ) + order.user_id = user.id + rma.action_confirm() + rma.reception_move_id.quantity_done = rma.product_uom_qty + rma.reception_move_id.picking_id.action_done() + rma.action_refund() + self.assertEqual(rma.refund_id.user_id, user)