增加自动化产线的零件供货路线初始化为自动化产线加工

This commit is contained in:
胡尧
2025-03-06 13:59:14 +08:00
parent 2409dab8b0
commit cb645aa1b9
2 changed files with 10 additions and 5 deletions

View File

@@ -22,6 +22,9 @@ class SaleOrder(models.Model):
def confirm_to_supply_method(self):
self.state = 'supply method'
for line in self.order_line:
if line.product_id.auto_machining:
line.supply_method = 'automation'
def action_confirm(self):
if self._get_forbidden_state_confirm() & set(self.mapped('state')):
@@ -192,14 +195,12 @@ class SaleOrderLine(models.Model):
return super(SaleOrderLine, self).write(vals)
cancel_auto_machining = fields.Boolean('是否取消自动化加工', compute='_compute_cancel_auto_machining', store=True)
cancel_auto_machining_reason = fields.Char('非自动化加工原因')
cancel_auto_machining_reason = fields.Char('更改供货原因')
@api.depends('product_id', 'supply_method')
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'

View File

@@ -21,6 +21,10 @@
<xpath expr="//field[@name='order_line']/tree/field[@name='glb_url']" position="before">
<field name="part_number" optional="show" class="section_and_note_text"/>
</xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='remark']" position="before">
<field name="cancel_auto_machining" invisible="1"/>
<field name="cancel_auto_machining_reason" optional="show" attrs="{'required': [('cancel_auto_machining', '=', True),('state', 'not in', ['draft', 'sent'])]}"/>
</xpath>
<!-- <xpath expr="//header/button[@name='action_cancel']" position="attributes"> -->
<!-- <attribute name="attrs">{'invisible': [('state', '!=', 'draft')]}</attribute> -->