diff --git a/rma/models/rma_order_line.py b/rma/models/rma_order_line.py
index 0a4dfab4..1866a2e3 100644
--- a/rma/models/rma_order_line.py
+++ b/rma/models/rma_order_line.py
@@ -209,9 +209,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,
@@ -230,7 +232,7 @@ class RmaOrderLine(models.Model):
product_tracking = fields.Selection(related="product_id.tracking")
lot_id = fields.Many2one(
comodel_name="stock.production.lot", string="Lot/Serial Number",
- readonly=True, states={"new": [("readonly", False)]},
+ readonly=True, states={"draft": [("readonly", False)]},
)
product_qty = fields.Float(
string='Ordered Qty', copy=False,
@@ -481,7 +483,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
@@ -531,8 +532,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 e1bb0630..2bc14d06 100644
--- a/rma/views/rma_order_line_view.xml
+++ b/rma/views/rma_order_line_view.xml
@@ -110,6 +110,22 @@
domain="[('supplier','=',True)]"
string="Supplier"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
@@ -140,7 +142,7 @@
-
+
@@ -279,6 +281,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
@@ -308,7 +312,7 @@
-
+
diff --git a/rma_account/models/rma_order_line.py b/rma_account/models/rma_order_line.py
index 375f9583..860bf8bb 100644
--- a/rma_account/models/rma_order_line.py
+++ b/rma_account/models/rma_order_line.py
@@ -79,19 +79,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 166b9c16..799a7a70 100644
--- a/rma_account/views/rma_order_line_view.xml
+++ b/rma_account/views/rma_order_line_view.xml
@@ -17,10 +17,7 @@
+ options="{'no_create': True}"/>
@@ -64,10 +61,7 @@
+ options="{'no_create': True}"/>
diff --git a/rma_sale/models/rma_order_line.py b/rma_sale/models/rma_order_line.py
index 85ca419a..43332104 100644
--- a/rma_sale/models/rma_order_line.py
+++ b/rma_sale/models/rma_order_line.py
@@ -64,19 +64,19 @@ class RmaOrderLine(models.Model):
sales_count = fields.Integer(
compute=_compute_sales_count, string='# of Sales')
- @api.onchange('product_id')
+ @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 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': []}
+ 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')
diff --git a/rma_sale/views/rma_order_line_view.xml b/rma_sale/views/rma_order_line_view.xml
index fe3407ff..c82596de 100644
--- a/rma_sale/views/rma_order_line_view.xml
+++ b/rma_sale/views/rma_order_line_view.xml
@@ -18,10 +18,7 @@
+ options="{'no_create': True}"/>