1、修复feature/修复工单cnc校验bug

This commit is contained in:
yuxianghui
2024-07-23 15:46:15 +08:00
parent 167c280fa4
commit 1d271d9167
3 changed files with 18 additions and 7 deletions

View File

@@ -122,7 +122,7 @@ class MrpProduction(models.Model):
is_scrap = fields.Boolean('是否报废', default=False) is_scrap = fields.Boolean('是否报废', default=False)
@api.depends( @api.depends(
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'tool_state',
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state') 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state')
def _compute_state(self): def _compute_state(self):
for production in self: for production in self:
@@ -182,6 +182,9 @@ class MrpProduction(models.Model):
for wo in for wo in
production.workorder_ids): production.workorder_ids):
production.state = 'rework' production.state = 'rework'
# 如果制造订单的功能刀具为【无效刀】则制造订单状态改为返工
if production.tool_state == '2':
production.state = 'rework'
def action_check(self): def action_check(self):
""" """

View File

@@ -101,7 +101,7 @@
<field name="part_drawing"/> <field name="part_drawing"/>
<field name="tool_state"/> <field name="tool_state"/>
<field name="tool_state_remark" string="备注" attrs="{'invisible': [('tool_state', '!=', '1')]}"/> <field name="tool_state_remark" string="备注" attrs="{'invisible': [('tool_state', '!=', '1')]}"/>
<field name="tool_state_remark2" string="备注" attrs="{'invisible': [('tool_state', '!=', '2')]}"/> <field name="tool_state_remark2" invisible="1"/>
</xpath> </xpath>
<xpath expr="//header//button[@name='action_cancel']" position="replace"> <xpath expr="//header//button[@name='action_cancel']" position="replace">
<button name="action_cancel" type="object" string="取消" data-hotkey="z" <button name="action_cancel" type="object" string="取消" data-hotkey="z"

View File

@@ -33,6 +33,10 @@ class CNCprocessing(models.Model):
""" """
根据传入的工单信息查询是否有需要的功能刀具如果没有则生成CAM工单程序用刀计划 根据传入的工单信息查询是否有需要的功能刀具如果没有则生成CAM工单程序用刀计划
""" """
logging.info('开始进行工单cnc程序用刀校验')
logging.info(f'cnc_processing_ids:{cnc_processing_ids}')
if not cnc_processing_ids:
return False
cam_id = self.env['sf.cam.work.order.program.knife.plan'] cam_id = self.env['sf.cam.work.order.program.knife.plan']
production_ids = [] # 制造订单集 production_ids = [] # 制造订单集
datas = {'缺刀': {}, '无效刀': {}} # 缺刀/无效刀集 datas = {'缺刀': {}, '无效刀': {}} # 缺刀/无效刀集
@@ -45,7 +49,7 @@ class CNCprocessing(models.Model):
datas['无效刀'].update({production_name: {processing_panel: []}}) datas['无效刀'].update({production_name: {processing_panel: []}})
production_ids.append(cnc_processing.workorder_id.production_id) production_ids.append(cnc_processing.workorder_id.production_id)
else: else:
if processing_panel not in list[datas['缺刀'].get(production_name).keys()]: if processing_panel not in list(datas['缺刀'].get(production_name).keys()):
datas['缺刀'].get(production_name).update({processing_panel: []}) datas['缺刀'].get(production_name).update({processing_panel: []})
datas['无效刀'].get(production_name).update({processing_panel: []}) datas['无效刀'].get(production_name).update({processing_panel: []})
# ====================================== # ======================================
@@ -74,8 +78,9 @@ class CNCprocessing(models.Model):
# 创建CAM申请装刀记录 # 创建CAM申请装刀记录
cam_id.create_cam_work_plan(cnc_processing) cam_id.create_cam_work_plan(cnc_processing)
logging.info('成功调用CAM工单程序用刀计划创建方法') logging.info('成功调用CAM工单程序用刀计划创建方法')
logging.info(datas) logging.info(f'datas:{datas}')
for production_id in production_ids: for production_id in production_ids:
logging.info(f'production_id: {production_id}')
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': [], ...}
@@ -90,6 +95,7 @@ class CNCprocessing(models.Model):
tool_state_remark1 = f'{key}无效刀:{data1.get(key)}' tool_state_remark1 = f'{key}无效刀:{data1.get(key)}'
# 无效刀处理逻辑 # 无效刀处理逻辑
# 1、创建制造订单无效刀检测结果记录 # 1、创建制造订单无效刀检测结果记录
logging.info('创建制造订单无效刀检测结果记录!')
production_id.detection_result_ids.create({ production_id.detection_result_ids.create({
'production_id': production_id.id, 'production_id': production_id.id,
'processing_panel': key, 'processing_panel': key,
@@ -100,9 +106,9 @@ class CNCprocessing(models.Model):
'handle_result': '待处理' 'handle_result': '待处理'
}) })
# 2、将制造订单状态改为返工 # 2、将制造订单状态改为返工
production_id.write({ # production_id.write({
'state': 'rework' # 'state': 'rework'
}) # })
# 对缺刀信息进行处理 # 对缺刀信息进行处理
if tool_state_remark1 == '': if tool_state_remark1 == '':
for key in data2: for key in data2:
@@ -112,6 +118,7 @@ class CNCprocessing(models.Model):
else: else:
tool_state_remark2 = f'{key}缺刀:{data2.get(key)}' tool_state_remark2 = f'{key}缺刀:{data2.get(key)}'
# 将备注信息存入制造订单功能刀具状态的备注字段 # 将备注信息存入制造订单功能刀具状态的备注字段
logging.info('修改制造订单功能刀具状态的备注字段')
if production_id.tool_state_remark2 == '': if production_id.tool_state_remark2 == '':
production_id.write({ production_id.write({
'tool_state_remark': tool_state_remark2, 'tool_state_remark': tool_state_remark2,
@@ -122,6 +129,7 @@ class CNCprocessing(models.Model):
'tool_state_remark': tool_state_remark2, 'tool_state_remark': tool_state_remark2,
'tool_state_remark2': f'{production_id.tool_state_remark1}\n{tool_state_remark1}' 'tool_state_remark2': f'{production_id.tool_state_remark1}\n{tool_state_remark1}'
}) })
logging.info('工单cnc程序用刀校验已完成')
@api.model_create_multi @api.model_create_multi
def create(self, vals): def create(self, vals):