[FIX] stock: remove dynamic domain on stock_rule
This commit is contained in:
committed by
Arnold Moyaux
parent
16f2b3809d
commit
6c4447ef59
@@ -24,12 +24,15 @@ class StockRule(models.Model):
|
||||
})
|
||||
return message_dict
|
||||
|
||||
@api.onchange('action')
|
||||
def _onchange_action_operation(self):
|
||||
domain = {'picking_type_id': []}
|
||||
if self.action == 'manufacture':
|
||||
domain = {'picking_type_id': [('code', '=', 'mrp_operation')]}
|
||||
return {'domain': domain}
|
||||
@api.depends('action')
|
||||
def _compute_picking_type_code_domain(self):
|
||||
remaining = self.browse()
|
||||
for rule in self:
|
||||
if rule.action == 'manufacture':
|
||||
rule.picking_type_code_domain = 'mrp_operation'
|
||||
else:
|
||||
remaining |= rule
|
||||
super(StockRule, remaining)._compute_picking_type_code_domain()
|
||||
|
||||
@api.model
|
||||
def _run_manufacture(self, procurements):
|
||||
|
||||
@@ -22,13 +22,20 @@ class StockRule(models.Model):
|
||||
})
|
||||
return message_dict
|
||||
|
||||
@api.depends('action')
|
||||
def _compute_picking_type_code_domain(self):
|
||||
remaining = self.browse()
|
||||
for rule in self:
|
||||
if rule.action == 'buy':
|
||||
rule.picking_type_code_domain = 'incoming'
|
||||
else:
|
||||
remaining |= rule
|
||||
super(StockRule, remaining)._compute_picking_type_code_domain()
|
||||
|
||||
@api.onchange('action')
|
||||
def _onchange_action(self):
|
||||
domain = {'picking_type_id': []}
|
||||
if self.action == 'buy':
|
||||
self.location_src_id = False
|
||||
domain = {'picking_type_id': [('code', '=', 'incoming')]}
|
||||
return {'domain': domain}
|
||||
|
||||
@api.model
|
||||
def _run_buy(self, procurements):
|
||||
|
||||
@@ -39,10 +39,12 @@ class StockRule(models.Model):
|
||||
required=True)
|
||||
sequence = fields.Integer('Sequence', default=20)
|
||||
company_id = fields.Many2one('res.company', 'Company',
|
||||
default=lambda self: self.env.company)
|
||||
default=lambda self: self.env.company,
|
||||
domain=[('company_id', '?=', 'route_company_id')])
|
||||
location_id = fields.Many2one('stock.location', 'Destination Location', required=True, check_company=True)
|
||||
location_src_id = fields.Many2one('stock.location', 'Source Location', check_company=True)
|
||||
route_id = fields.Many2one('stock.location.route', 'Route', required=True, ondelete='cascade')
|
||||
route_company_id = fields.Many2one(related='route_id.company_id', string='Route Company')
|
||||
procure_method = fields.Selection([
|
||||
('make_to_stock', 'Take From Stock'),
|
||||
('make_to_order', 'Trigger Another Rule'),
|
||||
@@ -54,7 +56,9 @@ class StockRule(models.Model):
|
||||
route_sequence = fields.Integer('Route Sequence', related='route_id.sequence', store=True, readonly=False, compute_sudo=True)
|
||||
picking_type_id = fields.Many2one(
|
||||
'stock.picking.type', 'Operation Type',
|
||||
required=True, check_company=True)
|
||||
required=True, check_company=True,
|
||||
domain=[('code', '?=', 'picking_type_code_domain')])
|
||||
picking_type_code_domain = fields.Char(compute='_compute_picking_type_code_domain')
|
||||
delay = fields.Integer('Delay', default=0, help="The expected date of the created transfer will be computed based on this delay.")
|
||||
partner_address_id = fields.Many2one(
|
||||
'res.partner', 'Partner Address',
|
||||
@@ -101,8 +105,6 @@ class StockRule(models.Model):
|
||||
self.company_id = self.route_id.company_id
|
||||
if self.picking_type_id.warehouse_id.company_id != self.route_id.company_id:
|
||||
self.picking_type_id = False
|
||||
domain = {'company_id': self.route_id.company_id and [('id', '=', self.route_id.company_id.id)] or []}
|
||||
return {'domain': domain}
|
||||
|
||||
def _get_message_values(self):
|
||||
""" Return the source, destination and picking_type applied on a stock
|
||||
@@ -148,6 +150,10 @@ class StockRule(models.Model):
|
||||
rule.rule_message = message
|
||||
(self - action_rules).rule_message = None
|
||||
|
||||
@api.depends('action')
|
||||
def _compute_picking_type_code_domain(self):
|
||||
self.picking_type_code_domain = False
|
||||
|
||||
def _run_push(self, move):
|
||||
""" Apply a push rule on a move.
|
||||
If the rule is 'no step added' it will modify the destination location
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
<group>
|
||||
<group>
|
||||
<field name="active" invisible="1"/>
|
||||
<field name="picking_type_code_domain" invisible="1"/>
|
||||
<field name="action"/>
|
||||
<field name="picking_type_id"/>
|
||||
<field name="location_src_id" options="{'no_create': True}" attrs="{'required': [('action', 'in', ['pull', 'push', 'pull_push'])]}"/>
|
||||
@@ -88,6 +89,7 @@
|
||||
<group name="apply_on" string="Applicability">
|
||||
<field name="route_id"/>
|
||||
<field name="warehouse_id" attrs="{'invisible': [('action', '=', 'push')]}" groups="base.group_no_one"/>
|
||||
<field name="route_company_id" invisible="1"/>
|
||||
<field name="company_id" attrs="{'required': [('action', '=', 'push')]}" groups="base.group_multi_company"/>
|
||||
<field name="sequence" string="Sequence" groups="base.group_no_one"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user