装夹工单返工

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