From 2409dab8b037fa0e1bca617ef85485a6f3ca679e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 5 Mar 2025 14:27:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=9D=9E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/sale_order.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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'