diff --git a/rma_account/models/rma_order_line.py b/rma_account/models/rma_order_line.py index 5426bc2a..3230c1a7 100644 --- a/rma_account/models/rma_order_line.py +++ b/rma_account/models/rma_order_line.py @@ -79,6 +79,21 @@ class RmaOrderLine(models.Model): digits=dp.get_precision('Product Unit of Measure'), readonly=True, compute=_compute_qty_refunded, store=True) + @api.onchange('product_id') + def _onchange_product_id(self): + res = super(RmaOrderLine, self)._onchange_product_id() + if res.get('domain') and self.product_id: + res['domain']['invoice_line_id'] = [ + ('product_id', '=', self.product_id.id)] + elif res.get('domain') and self.product_id: + res['domain']['invoice_line_id'] = [()] + elif not res.get('domain') and self.product_id: + res['domain'] = { + 'invoice_line_id': [('product_id', '=', self.product_id.id)]} + else: + res['domain'] = {'invoice_line_id': []} + return res + @api.multi def _prepare_rma_line_from_inv_line(self, line): self.ensure_one()