1、处理大批量修改cnc编程单的工单状态时,导致工单状态的自动计算方法进行递归而产生的栈溢出问题
This commit is contained in:
@@ -36,9 +36,11 @@ class MrpProduction(models.Model):
|
|||||||
def _compute_tool_state_remark(self):
|
def _compute_tool_state_remark(self):
|
||||||
for item in self:
|
for item in self:
|
||||||
if item.workorder_ids:
|
if item.workorder_ids:
|
||||||
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工'))
|
work_ids = []
|
||||||
if workorder_ids.filtered(lambda a: a.tool_state_remark):
|
for workorder_id in item.workorder_ids:
|
||||||
work_ids = workorder_ids.filtered(lambda a: a.tool_state == '1' and a.state not in ['rework'])
|
if workorder_id.tool_state == '1':
|
||||||
|
work_ids.append(workorder_id)
|
||||||
|
if work_ids:
|
||||||
tool_state_remark = ''
|
tool_state_remark = ''
|
||||||
for work_id in work_ids:
|
for work_id in work_ids:
|
||||||
if tool_state_remark == '':
|
if tool_state_remark == '':
|
||||||
@@ -54,10 +56,16 @@ class MrpProduction(models.Model):
|
|||||||
for item in self:
|
for item in self:
|
||||||
if item.workorder_ids:
|
if item.workorder_ids:
|
||||||
tool_state = item.tool_state
|
tool_state = item.tool_state
|
||||||
workorder_ids = item.workorder_ids.filtered(lambda a: a.state not in ('rework', '返工'))
|
work_ids_1 = []
|
||||||
if workorder_ids.filtered(lambda a: a.tool_state == '2'):
|
work_ids_2 = []
|
||||||
|
for workorder_id in item.workorder_ids:
|
||||||
|
if workorder_id.tool_state == '2':
|
||||||
|
work_ids_2.append(workorder_id)
|
||||||
|
elif workorder_id.tool_state == '1':
|
||||||
|
work_ids_1.append(workorder_id)
|
||||||
|
if work_ids_2:
|
||||||
item.tool_state = '2'
|
item.tool_state = '2'
|
||||||
elif workorder_ids.filtered(lambda a: a.tool_state == '1'):
|
elif work_ids_1:
|
||||||
item.tool_state = '1'
|
item.tool_state = '1'
|
||||||
else:
|
else:
|
||||||
item.tool_state = '0'
|
item.tool_state = '0'
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
for cnc_id in cnc_ids:
|
for cnc_id in cnc_ids:
|
||||||
if cnc_id.cutting_tool_name not in tool_state_remark:
|
if cnc_id.cutting_tool_name not in tool_state_remark:
|
||||||
tool_state_remark.append(cnc_id.cutting_tool_name)
|
tool_state_remark.append(cnc_id.cutting_tool_name)
|
||||||
item.tool_state_remark = f"{item.processing_panel}缺刀:{tool_state_remark}]"
|
item.tool_state_remark = f"{item.processing_panel}缺刀:{tool_state_remark}"
|
||||||
else:
|
else:
|
||||||
item.tool_state_remark = None
|
item.tool_state_remark = None
|
||||||
|
|
||||||
|
|||||||
@@ -263,8 +263,17 @@ class FunctionalCuttingToolEntity(models.Model):
|
|||||||
if self.tool_name_id.name:
|
if self.tool_name_id.name:
|
||||||
cnc_processing_ids = self.env['sf.cnc.processing'].search(
|
cnc_processing_ids = self.env['sf.cnc.processing'].search(
|
||||||
[('tool_state', '=', '1'), ('cutting_tool_name', '=', self.tool_name_id.name)])
|
[('tool_state', '=', '1'), ('cutting_tool_name', '=', self.tool_name_id.name)])
|
||||||
|
production_ids = []
|
||||||
if cnc_processing_ids:
|
if cnc_processing_ids:
|
||||||
cnc_processing_ids.sudo().write({'tool_state': '0'})
|
for item in cnc_processing_ids:
|
||||||
|
if item.workorder_id and item.workorder_id.production_id not in production_ids:
|
||||||
|
production_ids.append(item.workorder_id.production_id)
|
||||||
|
if production_ids:
|
||||||
|
# 对同一制造订单的工单的cnc编程单的功能刀具状态进行变更,并调用工单的功能刀具状态计算方法
|
||||||
|
for production_id in production_ids:
|
||||||
|
cnc_ids = cnc_processing_ids.filtered(lambda a: a.workorder_id.production_id == production_id)
|
||||||
|
cnc_ids.sudo().write({'tool_state': '0'})
|
||||||
|
cnc_ids.workorder_id._compute_tool_state()
|
||||||
|
|
||||||
def tool_inventory_displacement_out(self):
|
def tool_inventory_displacement_out(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user