表面工艺采购单确认订单进行限制
This commit is contained in:
@@ -1035,49 +1035,6 @@ class ResMrpWorkOrder(models.Model):
|
||||
'production_id.tool_state', 'production_id.schedule_state', 'sequence',
|
||||
'production_id.programming_state')
|
||||
def _compute_state(self):
|
||||
# super()._compute_state()
|
||||
# for workorder in self:
|
||||
# if workorder.sequence != 1:
|
||||
# previous_workorder = self.env['mrp.workorder'].search(
|
||||
# [('production_id', '=', workorder.production_id.id),
|
||||
# ('sequence', '=', workorder.sequence - 1)])
|
||||
# if workorder.state == 'pending':
|
||||
# if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
||||
# if workorder.production_id.reservation_state == 'assigned' and workorder.production_id.schedule_state == '已排':
|
||||
# if ((workorder.sequence == 1 and not workorder.blocked_by_workorder_ids)
|
||||
# or (workorder.blocked_by_workorder_ids.state in ('done', 'cancel')
|
||||
# and workorder.blocked_by_workorder_ids.test_results not in ['报废', '返工'])
|
||||
# or (previous_workorder.state in ('done', 'cancel')
|
||||
# and not workorder.blocked_by_workorder_ids
|
||||
# and previous_workorder.test_results not in ['报废', '返工'])
|
||||
# ):
|
||||
# workorder.state = 'ready'
|
||||
# continue
|
||||
# if workorder.production_id.schedule_state == '未排' and workorder.state in ('waiting', 'ready'):
|
||||
# if workorder.sequence != 1:
|
||||
# workorder.state = 'pending'
|
||||
# continue
|
||||
# if workorder.state not in ('waiting', 'ready'):
|
||||
# continue
|
||||
# if workorder.state in (
|
||||
# 'waiting') and workorder.sequence == 1 and workorder.production_id.schedule_state == '已排':
|
||||
# workorder.state = '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']:
|
||||
# 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' and workorder.production_id.schedule_state == '已排':
|
||||
# workorder.state = 'ready'
|
||||
# elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
||||
# workorder.state = 'waiting'
|
||||
|
||||
for workorder in self:
|
||||
# 如果工单的工序没有进行排序则跳出循环
|
||||
if workorder.production_id.workorder_ids.filtered(lambda wk: wk.sequence == 0):
|
||||
@@ -1119,7 +1076,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
if workorder.state != 'waiting':
|
||||
workorder.state = 'waiting'
|
||||
continue
|
||||
if workorder.production_id.programming_state == '已编程':
|
||||
if workorder.production_id.programming_state == '已编程' and workorder.technology_design_id.routing_tag != 'special':
|
||||
workorder.state = 'ready'
|
||||
elif workorder.state != 'waiting':
|
||||
workorder.state = 'waiting'
|
||||
@@ -1134,85 +1091,12 @@ class ResMrpWorkOrder(models.Model):
|
||||
if workorder.is_subcontract is False:
|
||||
workorder.state = 'ready'
|
||||
else:
|
||||
# production_programming = self.env['mrp.production'].search(
|
||||
# [('origin', '=', self.production_id.origin)], order='name asc')
|
||||
# production_no_remanufacture = production_programming.filtered(
|
||||
# lambda a: a.is_remanufacture is False)
|
||||
# production_list = [production.name for production in production_programming]
|
||||
# purchase_orders = self.env['purchase.order'].search(
|
||||
# [('origin', 'ilike', ','.join(production_list))])
|
||||
# for line in purchase_orders.order_line:
|
||||
# if (
|
||||
# line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id
|
||||
# and line.product_qty == len(production_no_remanufacture)):
|
||||
# if all(pur_order.state == 'purchase' for pur_order in purchase_orders):
|
||||
# workorder.state = 'ready'
|
||||
# else:
|
||||
# workorder.state = 'waiting'
|
||||
purchase_orders_id = self._get_surface_technics_purchase_ids()
|
||||
if purchase_orders_id:
|
||||
workorder.state = 'ready' if purchase_orders_id.state == 'purchase' else 'waiting'
|
||||
else:
|
||||
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'])])
|
||||
# cnc_workorder = self.env['mrp.workorder'].search(
|
||||
# [('production_id', '=', workorder.production_id.id),
|
||||
# ('processing_panel', '=', workorder.processing_panel),
|
||||
# ('routing_type', '=', 'CNC加工'), ('state', 'in', ['done', 'rework']),
|
||||
# ('test_results', '=', '返工')])
|
||||
# cnc_workorder_pending = self.env['mrp.workorder'].search(
|
||||
# [('production_id', '=', workorder.production_id.id),
|
||||
# ('processing_panel', '=', workorder.processing_panel),
|
||||
# ('routing_type', '=', 'CNC加工'), ('state', 'in', ['pending'])])
|
||||
# unclamp_workorder = self.env['mrp.workorder'].search(
|
||||
# [('production_id', '=', workorder.production_id.id),
|
||||
# ('sequence', '=', workorder.sequence - 1),
|
||||
# ('state', 'in', ['done'])])
|
||||
# if workorder.state not in ['cancel', 'progress', 'rework']:
|
||||
# if workorder.production_id.state == 'rework':
|
||||
# if workorder.routing_type == '装夹预调':
|
||||
# # # 有返工工单
|
||||
# # if re_work:
|
||||
# # 新工单
|
||||
# if workorder.is_rework is False:
|
||||
# if (workorder.production_id.programming_state == '已编程'
|
||||
# and workorder.production_id.is_rework is False):
|
||||
# if re_work or cnc_workorder:
|
||||
# workorder.state = 'ready'
|
||||
# else:
|
||||
# if workorder.production_id.is_rework is True:
|
||||
# if re_work or cnc_workorder:
|
||||
# workorder.state = 'waiting'
|
||||
#
|
||||
# elif workorder.routing_type == 'CNC加工':
|
||||
# pre_workorder = self.env['mrp.workorder'].search(
|
||||
# [('production_id', '=', workorder.production_id.id),
|
||||
# ('processing_panel', '=', workorder.processing_panel),
|
||||
# ('routing_type', '=', '装夹预调'), ('state', '=', 'done')])
|
||||
# if pre_workorder:
|
||||
# if re_work:
|
||||
# workorder.state = 'waiting'
|
||||
# elif workorder.routing_type == '解除装夹':
|
||||
# if cnc_workorder:
|
||||
# if not cnc_workorder_pending or unclamp_workorder.test_results == '报废':
|
||||
# workorder.state = 'waiting'
|
||||
# # else:
|
||||
# # if workorder.production_id.is_rework is True:
|
||||
# # workorder.state = 'waiting'
|
||||
# elif workorder.production_id.state == 'progress':
|
||||
# if (workorder.routing_type == '装夹预调' and workorder.production_id.programming_state == '已编程'
|
||||
# and workorder.is_rework is False and workorder.state not in ['done', 'rework', 'cancel']):
|
||||
# if workorder.production_id.is_rework is False:
|
||||
# if re_work or cnc_workorder or unclamp_workorder:
|
||||
# workorder.state = 'ready'
|
||||
# # if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
|
||||
# # workorder.state = 'ready'
|
||||
# elif workorder.production_id.state == 'scrap':
|
||||
# if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
|
||||
# workorder.state = 'waiting'
|
||||
|
||||
# 重写工单开始按钮方法
|
||||
def button_start(self):
|
||||
|
||||
Reference in New Issue
Block a user