diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index ded46f93..fc037caf 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -848,18 +848,40 @@ class ResMrpWorkOrder(models.Model): # else: # if workorder.state not in ['cancel', 'rework']: # workorder.state = 'rework' - # 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】 - if workorder.production_id.tool_state in ['1', '2']: - if workorder.routing_type == '装夹预调': + if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']: + # 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】 + if workorder.production_id.tool_state in ['1', '2']: if workorder.state in ['ready']: workorder.state = 'waiting' continue - elif workorder.state == 'pending' and self.search( + elif workorder.state in ['waiting']: + continue + elif workorder.state == 'pending' and workorder == self.search( [('production_id', '=', workorder.production_id.id), - ('sequence', '=', workorder.sequence - 1), - ('state', 'in', ['done', 'rework'])]): + ('routing_type', '=', '装夹预调'), + ('state', 'not in', ['rework', 'done', 'cancel'])], + limit=1, + order="sequence"): workorder.state = 'waiting' continue + elif workorder.production_id.tool_state in ['0']: + if workorder.production_id.workorder_ids.filtered(lambda a: a.state == 'rework'): + if not workorder.production_id.workorder_ids.filtered( + lambda a: (a.routing_type not in ['装夹预调'] and + a.state not in ['pending', 'done', 'rework', 'cancel'])): + # 查询工序最小的非完工、非返工的装夹预调工单 + work_id = self.search( + [('production_id', '=', workorder.production_id.id), + ('routing_type', '=', '装夹预调'), + ('state', 'not in', ['rework', 'done', 'cancel'])], + limit=1, + order="sequence") + if workorder == work_id: + if workorder.production_id.reservation_state == 'assigned': + workorder.state = 'ready' + elif workorder.production_id.reservation_state != 'assigned': + workorder.state = 'waiting' + continue logging.info('工序:%s' % workorder.sequence) logging.info('工单最终状态:%s' % workorder.state) diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index 1e496985..dd539fc2 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -53,7 +53,8 @@ class FunctionalCuttingToolEntity(models.Model): safe_inventory_id = fields.Many2one('sf.real.time.distribution.of.functional.tools', string='功能刀具安全库存', readonly=True) - @api.depends('barcode_id.quant_ids', 'functional_tool_status', 'current_shelf_location_id') + @api.depends('barcode_id.quant_ids', 'barcode_id.quant_ids.location_id', 'functional_tool_status', + 'current_shelf_location_id') def _compute_current_location_id(self): for record in self: if record.functional_tool_status == '已拆除': diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py index 6314a90f..965fa03c 100644 --- a/sf_tool_management/models/mrp_workorder.py +++ b/sf_tool_management/models/mrp_workorder.py @@ -106,9 +106,9 @@ class CNCprocessing(models.Model): 'handle_result': '待处理' }) # 修改当前面装夹预调工单的 is_rework 为 True - work_ids = production_id.workorder_ids.filtered( - lambda a: a.routing_type == '装夹预调' and a.processing_panel == key and not a.is_rework) - work_ids.write({'is_rework': True}) + # work_ids = production_id.workorder_ids.filtered( + # lambda a: a.routing_type == '装夹预调' and a.processing_panel == key and not a.is_rework) + # work_ids.write({'is_rework': True}) # 对缺刀信息进行处理 for key in data2: if data2.get(key):