优化工单
This commit is contained in:
@@ -148,7 +148,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
def _compute_surface_technics_picking_ids(self):
|
||||
for workorder in self:
|
||||
if workorder.routing_type == '表面工艺':
|
||||
domain = [('origin', '=', workorder.production_id.name)]
|
||||
domain = [('origin', '=', workorder.production_id.name), ('state', 'not in', ['cancel'])]
|
||||
previous_workorder = self.env['mrp.workorder'].search(
|
||||
[('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
|
||||
('production_id', '=', workorder.production_id.id)])
|
||||
@@ -339,7 +339,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
|
||||
@api.constrains('blocked_by_workorder_ids')
|
||||
def _check_no_cyclic_dependencies(self):
|
||||
if self.production_id.state not in ['rework', 'technology_to_confirmed', 'pending_cam'] and self.state not in [
|
||||
if self.production_id.state not in ['rework', 'technology_to_confirmed', 'confirmed'] and self.state not in [
|
||||
'rework']:
|
||||
if not self._check_m2m_recursion('blocked_by_workorder_ids'):
|
||||
raise ValidationError(_("您不能创建周期性的依赖关系."))
|
||||
@@ -351,8 +351,9 @@ class ResMrpWorkOrder(models.Model):
|
||||
for workorder in self.blocked_by_workorder_ids:
|
||||
if workorder.state in ['done', 'cancel', 'rework']:
|
||||
continue
|
||||
workorder._plan_workorder(replan)
|
||||
start_date = max(start_date, workorder.date_planned_finished)
|
||||
if workorder.production_id.state not in ['technology_to_confirmed', 'confirmed']:
|
||||
workorder._plan_workorder(replan)
|
||||
start_date = max(start_date, workorder.date_planned_finished)
|
||||
# Plan only suitable workorders
|
||||
if self.state not in ['pending', 'waiting', 'ready']:
|
||||
return
|
||||
@@ -909,8 +910,34 @@ class ResMrpWorkOrder(models.Model):
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
||||
'production_id.tool_state')
|
||||
def _compute_state(self):
|
||||
super()._compute_state()
|
||||
# super()._compute_state()
|
||||
for workorder in self:
|
||||
logging.info(workorder.name)
|
||||
logging.info(workorder.state)
|
||||
logging.info(workorder.sequence)
|
||||
if workorder.state == 'pending':
|
||||
if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
||||
workorder.state = 'ready' if workorder.production_id.reservation_state == 'assigned' else 'waiting'
|
||||
continue
|
||||
if workorder.state not in ('waiting', 'ready'):
|
||||
continue
|
||||
if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
||||
workorder.state = 'pending'
|
||||
if workorder.state in ['waiting']:
|
||||
previous_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('sequence', '=', workorder.sequence - 1)])
|
||||
if previous_workorder.state == 'waiting':
|
||||
workorder.state = 'pending'
|
||||
if workorder.sequence == 1 and workorder.state == 'pending':
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'):
|
||||
continue
|
||||
if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting':
|
||||
workorder.state = 'ready'
|
||||
elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
||||
workorder.state = 'waiting'
|
||||
re_work = self.env['mrp.workorder'].search([('production_id', '=', workorder.production_id.id),
|
||||
('processing_panel', '=', workorder.processing_panel),
|
||||
('is_rework', '=', True), ('state', 'in', ['done', 'rework'])])
|
||||
@@ -990,68 +1017,68 @@ class ResMrpWorkOrder(models.Model):
|
||||
elif workorder.production_id.state == 'scrap':
|
||||
if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
||||
workorder.state = 'waiting'
|
||||
if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
|
||||
workorder_ids = workorder.production_id.workorder_ids
|
||||
work_bo = True
|
||||
for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
|
||||
if not workorder_ids.filtered(
|
||||
lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
|
||||
and a.processing_panel == wo.processing_panel)):
|
||||
work_bo = False
|
||||
break
|
||||
if (workorder.production_id.programming_state == '已编程' and work_bo
|
||||
and not workorder_ids.filtered(lambda a: a.sequence == 0)):
|
||||
# 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
|
||||
if workorder.production_id.tool_state in ['1', '2']:
|
||||
if workorder.state in ['ready']:
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
elif workorder.state in ['waiting']:
|
||||
continue
|
||||
elif workorder.state == 'pending' and workorder == self.search(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('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_ids.filtered(lambda a: a.state == 'rework'):
|
||||
if not 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),
|
||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||
limit=1,
|
||||
order="sequence")
|
||||
if work_id.routing_type == '装夹预调':
|
||||
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
|
||||
elif (workorder.name == '装夹预调' and
|
||||
workorder.state not in ['rework', 'done', 'cancel']):
|
||||
if workorder.state != 'pending':
|
||||
workorder.state = 'pending'
|
||||
if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
if (workorder.production_id.tool_state in ['1', '2']
|
||||
and not workorder.production_id.workorder_ids.filtered(lambda a: a.sequence == 0)
|
||||
and workorder.production_id.programming_state == '编程中' and workorder.name == '装夹预调'):
|
||||
if workorder.state == 'pending' and workorder == self.search(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('routing_type', '=', '装夹预调'),
|
||||
('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||
limit=1,
|
||||
order="sequence"):
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
# if workorder.routing_type == '装夹预调' and workorder.state in ['waiting', 'ready', 'pending']:
|
||||
# workorder_ids = workorder.production_id.workorder_ids
|
||||
# work_bo = True
|
||||
# for wo in workorder_ids.filtered(lambda a: a.routing_type == '装夹预调' and a.state == 'rework'):
|
||||
# if not workorder_ids.filtered(
|
||||
# lambda a: (a.routing_type == '装夹预调' and a.state not in ['rework', 'cancel']
|
||||
# and a.processing_panel == wo.processing_panel)):
|
||||
# work_bo = False
|
||||
# break
|
||||
# if (workorder.production_id.programming_state == '已编程' and work_bo
|
||||
# and not workorder_ids.filtered(lambda a: a.sequence == 0)):
|
||||
# # 当工单对应制造订单的功能刀具状态为 【无效刀】时,先对的第一个装夹预调工单状态设置为 【等待组件】
|
||||
# if workorder.production_id.tool_state in ['1', '2']:
|
||||
# if workorder.state in ['ready']:
|
||||
# workorder.state = 'waiting'
|
||||
# continue
|
||||
# elif workorder.state in ['waiting']:
|
||||
# continue
|
||||
# elif workorder.state == 'pending' and workorder == self.search(
|
||||
# [('production_id', '=', workorder.production_id.id),
|
||||
# ('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_ids.filtered(lambda a: a.state == 'rework'):
|
||||
# if not 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),
|
||||
# ('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||
# limit=1,
|
||||
# order="sequence")
|
||||
# if work_id.routing_type == '装夹预调':
|
||||
# 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
|
||||
# elif (workorder.name == '装夹预调' and
|
||||
# workorder.state not in ['rework', 'done', 'cancel']):
|
||||
# if workorder.state != 'pending':
|
||||
# workorder.state = 'pending'
|
||||
# if workorder.production_id.tool_state in ['1', '2'] and workorder.state == 'ready':
|
||||
# workorder.state = 'waiting'
|
||||
# continue
|
||||
# if (workorder.production_id.tool_state in ['1', '2']
|
||||
# and not workorder.production_id.workorder_ids.filtered(lambda a: a.sequence == 0)
|
||||
# and workorder.production_id.programming_state == '编程中' and workorder.name == '装夹预调'):
|
||||
# if workorder.state == 'pending' and workorder == self.search(
|
||||
# [('production_id', '=', workorder.production_id.id),
|
||||
# ('routing_type', '=', '装夹预调'),
|
||||
# ('state', 'not in', ['rework', 'done', 'cancel'])],
|
||||
# limit=1,
|
||||
# order="sequence"):
|
||||
# workorder.state = 'waiting'
|
||||
# continue
|
||||
|
||||
# 重写工单开始按钮方法
|
||||
def button_start(self):
|
||||
|
||||
Reference in New Issue
Block a user