工单状态优化

This commit is contained in:
yuxianghui
2024-11-21 17:02:32 +08:00
parent 1d66c1dbea
commit fff22a74b1

View File

@@ -1050,11 +1050,11 @@ class ResMrpWorkOrder(models.Model):
# 如果工单的工序没有进行排序则跳出循环
if workorder.production_id.workorder_ids.filtered(lambda wk: wk.sequence == 0):
break
# ===== 对所有按序号排序的非[进行中、完成、返工、取消]状态的工单,除了第一条之外的工单状态都设置为[等待其他工单] =====
# ===== 对所有按序号排序的非[进行中、完成、返工、取消、待检测]状态的工单,除了第一条之外的工单状态都设置为[等待其他工单] =====
min_sequence_wk = min(workorder.production_id.workorder_ids.filtered(
lambda wk: wk.state not in ['done', 'rework', 'cancel']),
key=lambda wk: wk.sequence)
if workorder.state in ['done', 'rework', 'cancel', 'progress']:
if workorder.state in ['done', 'rework', 'cancel', 'progress', 'to be detected']:
continue
else:
if workorder != min_sequence_wk:
@@ -1072,6 +1072,33 @@ class ResMrpWorkOrder(models.Model):
workorder.state = 'ready'
elif workorder.state != 'waiting':
workorder.state = 'waiting'
# =========== 特殊工艺工单处理 ===================
# if workorder.routing_type == '表面工艺' and workorder.is_subcontrac:
# purchase_order = self.env['purchase.order'].search(
# [('origin', 'ilike', workorder.production_id.name)])
# if purchase_order.picking_ids.filtered(lambda p: p.state in ['waiting', 'confirmed', 'assigned']):
# workorder.state = 'waiting'
# continue
if workorder.routing_type == '表面工艺':
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 purchase_orders.state == 'purchase':
workorder.state = 'ready'
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'])])
@@ -1127,25 +1154,6 @@ class ResMrpWorkOrder(models.Model):
# workorder.state = 'ready'
# # if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
# # workorder.state = 'ready'
# if workorder.routing_type == '表面工艺' and workorder.state not in ['done', 'progress']:
# if unclamp_workorder:
# 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 purchase_orders.state == 'purchase':
# workorder.state = 'ready'
# else:
# workorder.state = 'waiting'
# elif workorder.production_id.state == 'scrap':
# if workorder.routing_type == '解除装夹' and unclamp_workorder.test_results == '报废':
# workorder.state = 'waiting'