diff --git a/sf_manufacturing/models/sale_order.py b/sf_manufacturing/models/sale_order.py index 39066f14..dbd06e6a 100644 --- a/sf_manufacturing/models/sale_order.py +++ b/sf_manufacturing/models/sale_order.py @@ -190,3 +190,16 @@ class SaleOrderLine(models.Model): if vals['supply_method'] == 'purchase' and line.is_incoming_material: raise UserError('当前(%s)产品为客供料,不能选择外购' % ','.join(line.mapped('product_id.name'))) return super(SaleOrderLine, self).write(vals) + + cancel_auto_machining = fields.Boolean('是否取消自动化加工', compute='_compute_cancel_auto_machining', store=True) + cancel_auto_machining_reason = fields.Char('非自动化加工原因') + + def _compute_cancel_auto_machining(self): + for line in self: + line.cancel_auto_machining = True if line.product_id.auto_machining \ + and line.supply_method != 'automation' else False + + @api.onchange('product_id') + def _onchange_product_id_set_supply_method(self): + if self.product_id.auto_machining: + self.supply_method = 'automation'