优化工艺确认

This commit is contained in:
jinling.yang
2024-11-07 17:59:28 +08:00
parent 01df55ef35
commit d419efa3c3
5 changed files with 79 additions and 22 deletions

View File

@@ -254,6 +254,44 @@ class MrpProduction(models.Model):
if production.tool_state == '2':
production.state = 'rework'
def technology_confirm(self):
# 判断同一个加工面的标准工序的顺序是否依次排序
technology_design = self.technology_design_ids.sorted(key=lambda m: m.sequence)
current_design_index = None
for index, design in enumerate(technology_design.filtered(lambda a: a.routing_tag == 'standard')):
if design == current_design:
current_design_index = index
break # 找到了 current_design跳出循环
# 现在我们有了 current_design 的索引,我们可以找到下一条设计
if current_design_index is not None and current_design_index + 1 < len(technology_design):
next_design = technology_design[current_design_index + 1]
# 下一条设计是 next_design
else:
# 如果 current_design_index 为 None 或者没有下一条设计,则 next_design 为 None
next_design = None
for design in technology_design.filtered(lambda a: a.routing_tag == 'standard'):
routing_type = design.route_id.routing_type
if routing_type in ['装夹预调', 'CNC加工', '解除装夹']:
# standard_designs = [d for d in technology_design_ids if d.routing_tag == 'standard']
# last_design = technology_design[technology_design.index(design) - 1]
next_design = technology_design[2]
for next_design in technology_design:
next_design_routing_type = next_design.route_id.routing_type
logging.info('next_design:%s' % next_design.route_id.name)
logging.info('next_design面:%s' % next_design.panel)
logging.info('design:%s' % design.route_id.name)
logging.info('design面:%s' % design.panel)
if next_design == design:
break
if design.panel != next_design.panel and routing_type not in ['解除装夹']:
raise UserError('【加工面】为%s的标准工序里含有其他加工面的工序,请调整后重试' % design.panel)
if design.panel == next_design.panel:
if (routing_type == '装夹预调' and next_design_routing_type == '解除装夹') or (
routing_type == 'CNC加工' and next_design_routing_type == '装夹预调'):
raise UserError('【加工面】为%s的标准工序顺序有误,请调整后重试' % design.panel)
return True
def action_check(self):
"""
审核启用