修复返工操作时工单状态及制造订单更新程序

This commit is contained in:
jinling.yang
2024-07-15 17:34:18 +08:00
parent 7885794322
commit a0bd214118
5 changed files with 76 additions and 47 deletions

View File

@@ -824,19 +824,36 @@ class ResMrpWorkOrder(models.Model):
def _compute_state(self):
super()._compute_state()
for workorder in self:
if workorder.routing_type == '装夹预调' and workorder.state not in ['done', 'cancel', 'progress', 'rework']:
re_work = self.env['mrp.workorder'].search(
[('routing_type', '=', '装夹预调'), ('production_id', '=', workorder.production_id.id),
('processing_panel', '=', workorder.processing_panel), ('state', '=', 'rework')])
if re_work:
workorder.state = 'waiting'
elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'cancel', 'progress',
'rework']:
per_work = self.env['mrp.workorder'].search(
[('routing_type', '=', '装夹预调'), ('production_id', '=', workorder.production_id.id),
('processing_panel', '=', workorder.processing_panel), ('is_rework', '=', True)])
if per_work:
workorder.state = 'waiting'
re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
('processing_panel', '=', workorder.processing_panel),
('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
if workorder.state not in ['cancel', 'progress', 'rework']:
logging.info('工序:%s' % workorder.routing_type)
logging.info('状态:%s' % workorder.state)
logging.info('is_rework:%s' % workorder.is_rework)
logging.info('面:%s' % workorder.processing_panel)
logging.info('编程状态:%s' % workorder.production_id.programming_state)
logging.info('制造状态:%s' % workorder.production_id.state)
# if workorder.state =='done' and workorder.is_rework is True:
# workorder.state = 'rework'
# else:
# if re_work:
# workorder.state = 'rework'
if workorder.production_id.state == 'rework':
if (workorder.routing_type == 'CNC加工' and re_work.state == 'done') or (
workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '编程中' and re_work):
logging.info('面111:%s' % workorder.processing_panel)
workorder.state = 'waiting'
# else:
# if workorder.state not in ['cancel', 'rework']:
# workorder.state = 'rework'
# elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'cancel', 'progress',
# 'rework']:
# per_work = self.env['mrp.workorder'].search(
# [('routing_type', '=', '装夹预调'), ('production_id', '=', workorder.production_id.id),
# ('processing_panel', '=', workorder.processing_panel), ('is_rework', '=', True)])
# if per_work:
# workorder.state = 'waiting'
# if workorder.routing_type == 'CNC加工' and workorder.state == 'progress':
# workorder.state = 'to be detected'
# for workorder in self:
@@ -1031,10 +1048,7 @@ class ResMrpWorkOrder(models.Model):
record.write({
'date_planned_finished': tem_date_planned_finished # 保持原值
})
# if record.routing_type == 'CNC加工':
# record.write({
# 'date_finished': tem_date_finished # 保持原值
# })
# if record.routing_type == 'CNC加工' and record.test_results in ['返工', '报废']:
# record.production_id.action_cancel()
# record.production_id.workorder_ids.write({'rfid_code': False, 'rfid_code_old': record.rfid_code})