Merge PR #165 into 12.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2020-09-16 12:16:27 +00:00
3 changed files with 21 additions and 1 deletions

View File

@@ -12,7 +12,7 @@
"license": "AGPL-3",
"depends": [
"rma",
"sale",
"sale_stock",
],
"data": [
"views/assets.xml",

View File

@@ -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

View File

@@ -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)