1、优化工单状态方法

This commit is contained in:
yuxianghui
2024-07-26 16:25:16 +08:00
parent dbaad85670
commit 66caeee1cd
2 changed files with 19 additions and 13 deletions

View File

@@ -806,8 +806,6 @@ class ResMrpWorkOrder(models.Model):
if workorder.production_id.is_rework is True: if workorder.production_id.is_rework is True:
if re_work or cnc_workorder: if re_work or cnc_workorder:
workorder.state = 'waiting' workorder.state = 'waiting'
if workorder.production_id.tool_state in ['1', '2'] and workorder.state != 'pending':
workorder.state = 'waiting'
elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'rework', 'cancel']: elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'rework', 'cancel']:
pre_workorder = self.env['mrp.workorder'].search( pre_workorder = self.env['mrp.workorder'].search(
@@ -850,11 +848,19 @@ class ResMrpWorkOrder(models.Model):
# else: # else:
# if workorder.state not in ['cancel', 'rework']: # if workorder.state not in ['cancel', 'rework']:
# workorder.state = 'rework' # workorder.state = 'rework'
if workorder.production_id.state == 'pending_cam': # 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
if workorder.production_id.tool_state in ['1', '2']: if workorder.production_id.tool_state in ['1', '2']:
work_ids = workorder.production_id.workorder_ids.filtered( if workorder.routing_type == '装夹预调':
lambda a: a.routing_type == '装夹预调' and a.state in ['ready', 'waiting']) if workorder.state in ['ready']:
work_ids.state = 'waiting' workorder.state = 'waiting'
continue
elif workorder.state == 'pending' and self.search(
[('production_id', '=', workorder.production_id.id),
('sequence', '=', workorder.sequence - 1),
('state', 'in', ['done', 'rework'])]):
workorder.state = 'waiting'
continue
logging.info('工序:%s' % workorder.sequence) logging.info('工序:%s' % workorder.sequence)
logging.info('工单最终状态:%s' % workorder.state) logging.info('工单最终状态:%s' % workorder.state)

View File

@@ -105,12 +105,12 @@ class CNCprocessing(models.Model):
'test_results': '返工', 'test_results': '返工',
'handle_result': '待处理' 'handle_result': '待处理'
}) })
if not production_id.is_rework: # if not production_id.is_rework:
production_id.write({ # production_id.write({
'is_rework': True # 'is_rework': True
}) # })
production_id.workorder_ids.filtered( # production_id.workorder_ids.filtered(
lambda a: a.processing_panel == key and not a.is_rework).write({'is_rework': True}) # lambda a: a.processing_panel == key and not a.is_rework).write({'is_rework': True})
# 对缺刀信息进行处理 # 对缺刀信息进行处理
for key in data2: for key in data2:
if data2.get(key): if data2.get(key):