mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[FIX]rma_operating_unit dependencies
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -109,6 +109,22 @@
|
||||
domain="[('supplier','=',True)]"
|
||||
string="Supplier"/>
|
||||
</group>
|
||||
<group>
|
||||
<group name="product" string="Product">
|
||||
<field name="product_id"/>
|
||||
<newline/>
|
||||
<field name="product_tracking" invisible="1"/>
|
||||
<field name="lot_id"
|
||||
groups="stock.group_production_lot"
|
||||
attrs="{'required': [('product_tracking', 'in', ('serial', 'lot'))]}"
|
||||
domain="[('product_id', '=', product_id)]"/>
|
||||
</group>
|
||||
<group name="product_qty" string="Quantity">
|
||||
<field name="product_qty"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
</group>
|
||||
</group>
|
||||
<group name="main_info" string="Origin">
|
||||
<field name="reference_move_id"
|
||||
options="{'no_create': True}"
|
||||
@@ -117,20 +133,6 @@
|
||||
('state', '=', 'done')]"/>
|
||||
</group>
|
||||
<group>
|
||||
<group name="product" string="Product">
|
||||
<field name="product_id"/>
|
||||
<newline/>
|
||||
<field name="product_tracking" invisible="1"/>
|
||||
<field name="lot_id"
|
||||
groups="stock.group_production_lot"
|
||||
attrs="{'required': [('product_tracking', 'in', ('serial', 'lot'))]}"/>
|
||||
</group>
|
||||
<group name="product_qty" string="Quantity">
|
||||
<field name="product_qty"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group name="operation" string="Operation">
|
||||
<field name="operation_id"
|
||||
domain="[('type','=','supplier')]"/>
|
||||
@@ -139,7 +141,7 @@
|
||||
</group>
|
||||
<group name="contact" string="Contact">
|
||||
<field name="requested_by" readonly="1"/>
|
||||
<field name="assigned_to" readonly="1"/>
|
||||
<field name="assigned_to"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
@@ -281,6 +283,22 @@
|
||||
<field name="under_warranty"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<group name="product" string="Product">
|
||||
<field name="product_id"/>
|
||||
<newline/>
|
||||
<field name="product_tracking" invisible="1"/>
|
||||
<field name="lot_id"
|
||||
groups="stock.group_production_lot"
|
||||
attrs="{'required': [('product_tracking', 'in', ('serial', 'lot'))]}"
|
||||
domain="[('product_id', '=', product_id)]"/>
|
||||
</group>
|
||||
<group name="product_qty" string="Quantity">
|
||||
<field name="product_qty"/>
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
<field name="price_unit"/>
|
||||
</group>
|
||||
</group>
|
||||
<group name="main_info" string="Origin">
|
||||
<field name="reference_move_id"
|
||||
options="{'no_create': True}"
|
||||
@@ -289,20 +307,6 @@
|
||||
('state', '=', 'done')]"/>
|
||||
</group>
|
||||
<group>
|
||||
<group name="product" string="Product">
|
||||
<field name="product_id"/>
|
||||
<newline/>
|
||||
<field name="product_tracking" invisible="1"/>
|
||||
<field name="lot_id"
|
||||
groups="stock.group_production_lot"
|
||||
attrs="{'required': [('product_tracking', 'in', ('serial', 'lot'))]}"/>
|
||||
</group>
|
||||
<group name="product_qty" string="Quantity">
|
||||
<field name="product_qty"/>
|
||||
<field name="uom_id" groups="product.group_uom"/>
|
||||
<field name="price_unit"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group name="operation" string="Operation">
|
||||
<field name="operation_id" domain="[('type','=','customer')]"/>
|
||||
<field name="receipt_policy"/>
|
||||
@@ -310,7 +314,7 @@
|
||||
</group>
|
||||
<group name="contact" string="Contact">
|
||||
<field name="requested_by" readonly="1"/>
|
||||
<field name="assigned_to" readonly="1"/>
|
||||
<field name="assigned_to"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
</button>
|
||||
<group name="main_info" position="inside">
|
||||
<field name="invoice_line_id"
|
||||
context="{'rma': True}"
|
||||
options="{'no_create': True}"
|
||||
domain="['|',
|
||||
('invoice_id.partner_id', '=', partner_id),
|
||||
@@ -65,11 +64,7 @@
|
||||
</button>
|
||||
<group name="main_info" position="inside">
|
||||
<field name="invoice_line_id"
|
||||
context="{'rma': True}"
|
||||
options="{'no_create': True}"
|
||||
domain="['|',
|
||||
('invoice_id.partner_id', '=', partner_id),
|
||||
('invoice_id.partner_id', 'child_of', partner_id)]"/>
|
||||
options="{'no_create': True}"/>
|
||||
</group>
|
||||
<field name="operation_id" position="after">
|
||||
<field name="refund_policy"/>
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -18,11 +18,7 @@
|
||||
</div>
|
||||
<group name="main_info" position="inside">
|
||||
<field name="sale_line_id"
|
||||
context="{'rma': True}"
|
||||
options="{'no_create': True}"
|
||||
domain="['|',
|
||||
('order_id.partner_id', '=', partner_id),
|
||||
('order_id.partner_id', 'child_of', partner_id)]"/>
|
||||
options="{'no_create': True}"/>
|
||||
</group>
|
||||
<group name="quantities" position="inside">
|
||||
<group>
|
||||
@@ -31,7 +27,7 @@
|
||||
</group>
|
||||
</group>
|
||||
<field name="delivery_policy" position="after">
|
||||
<field name="sale_type"/>
|
||||
<field name="sale_policy"/>
|
||||
</field>
|
||||
<field name="origin" position="after">
|
||||
<field name="sale_id"
|
||||
@@ -66,7 +62,7 @@
|
||||
</group>
|
||||
</group>
|
||||
<field name="delivery_policy" position="after">
|
||||
<field name="sale_type"/>
|
||||
<field name="sale_policy"/>
|
||||
</field>
|
||||
<notebook position="inside">
|
||||
<page name="sale" string="Sale Lines">
|
||||
|
||||
Reference in New Issue
Block a user