[9.0][IMP] rma_sale and rma_account: consider product when filtering sources on rma lines

This commit is contained in:
Lois Rilo
2018-05-23 19:13:03 +02:00
parent 30bda4a7fc
commit 51c4ff72f4
2 changed files with 30 additions and 0 deletions

View File

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

View File

@@ -64,6 +64,21 @@ class RmaOrderLine(models.Model):
sales_count = fields.Integer(
compute=_compute_sales_count, string='# of Sales')
@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']['sale_line_id'] = [
('product_id', '=', self.product_id.id)]
elif res.get('domain') and self.product_id:
res['domain']['sale_line_id'] = [()]
elif not res.get('domain') and self.product_id:
res['domain'] = {
'sale_line_id': [('product_id', '=', self.product_id.id)]}
else:
res['domain'] = {'sale_line_id': []}
return res
@api.onchange('operation_id')
def _onchange_operation_id(self):
res = super(RmaOrderLine, self)._onchange_operation_id()