Merge branch 'feature/修复工单cnc校验bug' into feature/修复工单cnc校验bug_1

# Conflicts:
#	sf_tool_management/models/mrp_workorder.py
This commit is contained in:
yuxianghui
2024-07-24 12:35:31 +08:00
2 changed files with 20 additions and 32 deletions

View File

@@ -827,6 +827,7 @@ class ResMrpWorkOrder(models.Model):
# workorder.state = 'waiting' # workorder.state = 'waiting'
# if workorder.routing_type == 'CNC加工' and workorder.state == 'progress': # if workorder.routing_type == 'CNC加工' and workorder.state == 'progress':
# workorder.state = 'to be detected' # workorder.state = 'to be detected'
# for workorder in self: # for workorder in self:
# if workorder.is_rework is True and workorder.state == 'done': # if workorder.is_rework is True and workorder.state == 'done':
# cnc_work = self.env['mrp.workorder'].search([('routing_type','=','CNC加工'),('production_id','=',workorder.production_id.id)]) # cnc_work = self.env['mrp.workorder'].search([('routing_type','=','CNC加工'),('production_id','=',workorder.production_id.id)])
@@ -865,12 +866,10 @@ class ResMrpWorkOrder(models.Model):
limit=1, order='id asc') limit=1, order='id asc')
if not cnc_workorder.cnc_ids: if not cnc_workorder.cnc_ids:
raise UserError(_('该制造订单还未下发CNC程序请稍后再试')) raise UserError(_('该制造订单还未下发CNC程序请稍后再试'))
# else: else:
# for item in cnc_workorder.cnc_ids: if self.production_id.tool_state in ['1', '2']:
# functional_cutting_tool = self.env['sf.functional.cutting.tool.entity'].search( raise UserError(
# [('tool_name_id.name', '=', item.cutting_tool_name)]) f'制造订单【{self.production_id.name}】功能刀具状态为【{self.production_id.tool_state}】!')
# if not functional_cutting_tool:
# raise UserError(_('该制造订单的CNC程序为%s没有对应的功能刀具' % item.cutting_tool_name))
if self.routing_type == '解除装夹': if self.routing_type == '解除装夹':
''' '''
记录开始时间 记录开始时间

View File

@@ -84,15 +84,15 @@ class CNCprocessing(models.Model):
if production_id: if production_id:
data1 = datas['无效刀'].get(production_id.name) # data1: {'加工面1': [], ...} data1 = datas['无效刀'].get(production_id.name) # data1: {'加工面1': [], ...}
data2 = datas['缺刀'].get(production_id.name) # data2: {'加工面1': [], ...} data2 = datas['缺刀'].get(production_id.name) # data2: {'加工面1': [], ...}
tool_state_remark1 = '' # tool_state_remark1 = ''
tool_state_remark2 = '' tool_state_remark2 = ''
# 对无效刀信息进行处理 # 对无效刀信息进行处理
for key in data1: for key in data1:
if data1.get(key): if data1.get(key):
if tool_state_remark1 != '': # if tool_state_remark1 != '':
tool_state_remark1 = f'{tool_state_remark1}\n{key}无效刀:{data1.get(key)}' # tool_state_remark1 = f'{tool_state_remark1}\n{key}无效刀:{data1.get(key)}'
else: # else:
tool_state_remark1 = f'{key}无效刀:{data1.get(key)}' # tool_state_remark1 = f'{key}无效刀:{data1.get(key)}'
# 无效刀处理逻辑 # 无效刀处理逻辑
# 1、创建制造订单无效刀检测结果记录 # 1、创建制造订单无效刀检测结果记录
logging.info('创建制造订单无效刀检测结果记录!') logging.info('创建制造订单无效刀检测结果记录!')
@@ -105,30 +105,19 @@ class CNCprocessing(models.Model):
'test_results': '返工', 'test_results': '返工',
'handle_result': '待处理' 'handle_result': '待处理'
}) })
# 2、将制造订单状态改为返工
# production_id.write({
# 'state': 'rework'
# })
# 对缺刀信息进行处理 # 对缺刀信息进行处理
if tool_state_remark1 == '': for key in data2:
for key in data2: if data2.get(key):
if data2.get(key) and not data1.get(key): if tool_state_remark2 != '':
if tool_state_remark2 != '': tool_state_remark2 = f'{tool_state_remark2}\n{key}缺刀:{data2.get(key)}'
tool_state_remark2 = f'{tool_state_remark2}\n{key}缺刀:{data2.get(key)}' else:
else: tool_state_remark2 = f'{key}缺刀:{data2.get(key)}'
tool_state_remark2 = f'{key}缺刀:{data2.get(key)}'
# 将备注信息存入制造订单功能刀具状态的备注字段 # 将备注信息存入制造订单功能刀具状态的备注字段
logging.info('修改制造订单功能刀具状态的备注字段') logging.info('修改制造订单功能刀具状态的备注字段')
if production_id.tool_state_remark2 == '': production_id.write({
production_id.write({ 'tool_state_remark': tool_state_remark2,
'tool_state_remark': tool_state_remark2, # 'tool_state_remark2': tool_state_remark1
'tool_state_remark2': tool_state_remark1 })
})
else:
production_id.write({
'tool_state_remark': tool_state_remark2,
'tool_state_remark2': f'{production_id.tool_state_remark}\n{tool_state_remark1}'
})
logging.info('工单cnc程序用刀校验已完成') logging.info('工单cnc程序用刀校验已完成')
@api.model_create_multi @api.model_create_multi