1、添加制造订单的刀具备注字段自动计算逻辑及方法;2、优化工单状态自动计算方法;
This commit is contained in:
@@ -180,11 +180,27 @@ class ResMrpWorkOrder(models.Model):
|
||||
# 功能刀具状态
|
||||
tool_state = fields.Selection([('0', '正常'), ('1', '缺刀'), ('2', '无效刀')], string='功能刀具状态', default='0',
|
||||
store=True, compute='_compute_tool_state')
|
||||
tool_state_remark = fields.Text(string='功能刀具状态备注(缺刀)', compute='_compute_tool_state_remark', store=True)
|
||||
|
||||
@api.depends('cnc_ids.tool_state')
|
||||
def _compute_tool_state_remark(self):
|
||||
for item in self:
|
||||
if item.cnc_ids:
|
||||
if item.cnc_ids.filtered(lambda a: a.tool_state == '2'):
|
||||
item.tool_state_remark = None
|
||||
elif item.cnc_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
tool_state_remark = f'{item.processing_panel}缺刀:['
|
||||
cnc_ids = item.cnc_ids.filtered(lambda a: a.tool_state == '1')
|
||||
for cnc_id in cnc_ids:
|
||||
tool_state_remark = f"{tool_state_remark}'{cnc_id.cutting_tool_name}'"
|
||||
item.tool_state_remark = f"{tool_state_remark}]"
|
||||
else:
|
||||
item.tool_state_remark = None
|
||||
|
||||
@api.depends('cnc_ids.tool_state')
|
||||
def _compute_tool_state(self):
|
||||
for item in self:
|
||||
if item:
|
||||
if item.cnc_ids:
|
||||
if item.cnc_ids.filtered(lambda a: a.tool_state == '2'):
|
||||
item.tool_state = '2'
|
||||
elif item.cnc_ids.filtered(lambda a: a.tool_state == '1'):
|
||||
@@ -835,9 +851,10 @@ class ResMrpWorkOrder(models.Model):
|
||||
# if workorder.state not in ['cancel', 'rework']:
|
||||
# workorder.state = 'rework'
|
||||
if workorder.production_id.state == 'pending_cam':
|
||||
if workorder.routing_type == '装夹预调' and workorder.state in ['ready', 'waiting']:
|
||||
if workorder.production_id.tool_state in ['1', '2']:
|
||||
workorder.state = 'waiting'
|
||||
if workorder.production_id.tool_state in ['1', '2']:
|
||||
work_ids = workorder.production_id.workorder_ids.filtered(
|
||||
lambda a: a.routing_type == '装夹预调' and a.state in ['ready', 'waiting'])
|
||||
work_ids.state = 'waiting'
|
||||
logging.info('工序:%s' % workorder.sequence)
|
||||
logging.info('工单最终状态:%s' % workorder.state)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user