diff --git a/rma/models/rma_order_line.py b/rma/models/rma_order_line.py index d55734f9..a3be5872 100644 --- a/rma/models/rma_order_line.py +++ b/rma/models/rma_order_line.py @@ -214,9 +214,11 @@ class RmaOrderLine(models.Model): ) assigned_to = fields.Many2one( comodel_name='res.users', track_visibility='onchange', + default=lambda self: self.env.uid, ) requested_by = fields.Many2one( comodel_name='res.users', track_visibility='onchange', + default=lambda self: self.env.uid, ) partner_id = fields.Many2one( comodel_name='res.partner', required=True, store=True, @@ -486,7 +488,6 @@ class RmaOrderLine(models.Model): self.write({'state': 'to_approve'}) for rec in self: if rec.product_id.rma_approval_policy == 'one_step': - rec.write({'assigned_to': self.env.uid}) rec.action_rma_approve() return True @@ -536,8 +537,7 @@ class RmaOrderLine(models.Model): self.product_id.categ_id.rma_supplier_operation_id if self.lot_id.product_id != self.product_id: self.lot_id = False - return {'domain': { - 'lot_id': [('product_id', '=', self.product_id.id)]}} + return result @api.onchange('operation_id') def _onchange_operation_id(self): diff --git a/rma/views/rma_order_line_view.xml b/rma/views/rma_order_line_view.xml index befac3b5..78047467 100644 --- a/rma/views/rma_order_line_view.xml +++ b/rma/views/rma_order_line_view.xml @@ -109,6 +109,22 @@ domain="[('supplier','=',True)]" string="Supplier"/> + + + + + + + + + + + + + - - - - - - - - - - - - @@ -139,7 +141,7 @@ - + @@ -281,6 +283,22 @@ + + + + + + + + + + + + + - - - - - - - - - - - - @@ -310,7 +314,7 @@ - + diff --git a/rma_account/models/rma_order_line.py b/rma_account/models/rma_order_line.py index bdb68671..b922e22c 100644 --- a/rma_account/models/rma_order_line.py +++ b/rma_account/models/rma_order_line.py @@ -82,19 +82,19 @@ class RmaOrderLine(models.Model): digits=dp.get_precision('Product Unit of Measure'), readonly=True, compute=_compute_qty_refunded, store=True) - @api.onchange('product_id') + @api.onchange('product_id', 'partner_id') def _onchange_product_id(self): + """Domain for invoice_line_id is computed here to make it dynamic.""" 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': []} + if not res.get('domain'): + res['domain'] = {} + domain = [ + '|', + ('invoice_id.partner_id', '=', self.partner_id.id), + ('invoice_id.partner_id', 'child_of', self.partner_id.id)] + if self.product_id: + domain.append(('product_id', '=', self.product_id.id)) + res['domain']['invoice_line_id'] = domain return res @api.multi diff --git a/rma_account/views/rma_order_line_view.xml b/rma_account/views/rma_order_line_view.xml index 7ec88175..3f50cc0f 100644 --- a/rma_account/views/rma_order_line_view.xml +++ b/rma_account/views/rma_order_line_view.xml @@ -17,7 +17,6 @@ + options="{'no_create': True}"/> diff --git a/rma_operating_unit/__manifest__.py b/rma_operating_unit/__manifest__.py index a9def047..4f5a245d 100644 --- a/rma_operating_unit/__manifest__.py +++ b/rma_operating_unit/__manifest__.py @@ -10,7 +10,7 @@ "license": "LGPL-3", "website": "http://www.eficent.com", "category": "Operating Units", - "depends": ["rma", "operating_unit"], + "depends": ["rma", "stock_operating_unit"], "data": [ "security/rma_security.xml", "views/rma_order_view.xml", diff --git a/rma_sale/models/rma_order_line.py b/rma_sale/models/rma_order_line.py index f344ffee..da30c3b0 100644 --- a/rma_sale/models/rma_order_line.py +++ b/rma_sale/models/rma_order_line.py @@ -66,6 +66,28 @@ class RmaOrderLine(models.Model): sales_count = fields.Integer( compute=_compute_sales_count, string='# of Sales') + @api.onchange('product_id', 'partner_id') + def _onchange_product_id(self): + """Domain for sale_line_id is computed here to make it dynamic.""" + res = super(RmaOrderLine, self)._onchange_product_id() + if not res.get('domain'): + res['domain'] = {} + domain = [ + '|', + ('order_id.partner_id', '=', self.partner_id.id), + ('order_id.partner_id', 'child_of', self.partner_id.id)] + if self.product_id: + domain.append(('product_id', '=', self.product_id.id)) + res['domain']['sale_line_id'] = domain + return res + + @api.onchange('operation_id') + def _onchange_operation_id(self): + res = super(RmaOrderLine, self)._onchange_operation_id() + if self.operation_id: + self.sale_policy = self.operation_id.sale_policy or 'no' + return res + @api.multi def _prepare_rma_line_from_sale_order_line(self, line): self.ensure_one() diff --git a/rma_sale/views/rma_order_line_view.xml b/rma_sale/views/rma_order_line_view.xml index d3d4199f..c82596de 100644 --- a/rma_sale/views/rma_order_line_view.xml +++ b/rma_sale/views/rma_order_line_view.xml @@ -18,11 +18,7 @@ + options="{'no_create': True}"/> @@ -31,7 +27,7 @@ - + - +