装夹工单返工

This commit is contained in:
guanhuan
2025-01-23 13:55:35 +08:00
parent 39b29960e3
commit 9b49edb290
2 changed files with 30 additions and 0 deletions

View File

@@ -455,6 +455,32 @@ class ResMrpWorkOrder(models.Model):
("technology", "工艺"), ("customer redrawing", "客户改图")], string="原因", tracking=True)
detailed_reason = fields.Text('详细原因')
is_rework = fields.Boolean(string='是否返工', default=False)
rework_flag = fields.Boolean(string='返工标志', compute='_compute_rework_flag')
@api.depends('state', 'production_line_state')
def _compute_rework_flag(self):
for record in self:
if record.state == 'done' and record.routing_type == '装夹预调':
next_workorder = record.production_id.workorder_ids.filtered(
lambda w: w.sequence == record.sequence + 1)
if next_workorder and next_workorder.routing_type == 'CNC加工' and next_workorder.state in ['ready',
'waiting',
'pending'] and next_workorder.production_line_state == '待上产线':
record.rework_flag = False
elif next_workorder and next_workorder.routing_type == '表面工艺' and next_workorder.state in ['ready',
'waiting',
'pending']:
record.rework_flag = False
else:
record.rework_flag = True
else:
record.rework_flag = True
def button_rework(self):
for item in self:
item.state = 'progress'
for time_id in item.time_ids:
time_id.write({'date_end': None})
def button_change_env(self):
self.is_test_env = not self.is_test_env

View File

@@ -163,6 +163,7 @@
<field name='is_delivery' invisible="1"/>
<field name="is_trayed" invisible="1"/>
<field name="is_inspect" invisible="1"/>
<field name="rework_flag" invisible="1"/>
<!-- <field name='is_send_program_again' invisible="1"/>-->
<!-- 工单form页面的开始停工按钮等 -->
<!-- <button name="button_start" type="object" string="开始" class="btn-success" -->
@@ -211,6 +212,9 @@
attrs="{'invisible': ['|', '|', '|', ('routing_type','!=','装夹预调'),('state','!=','progress'), ('is_trayed', '=', False), ('state', 'in', ('done'))]}"/>
<button name="print_method" type="object" string="打印二维码" class="btn-primary"
attrs="{'invisible': ['|',('routing_type','!=','解除装夹'),('state','!=','done')]}"/>
<button type="object" class="oe_highlight jikimo_button_confirm" name="button_rework"
string="返工"
attrs='{"invisible": [("rework_flag","=",True)]}' confirm="是否返工"/>
</xpath>
<xpath expr="//page[1]" position="before">
<page string="开料要求" attrs='{"invisible": [("routing_type","not in",("切割", "线切割", "人工线下加工"))]}'>