From fff22a74b1797ba0c6a5d278a82dc4d2fc0c3895 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 21 Nov 2024 17:02:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 50 ++++++++++++++---------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 518afd7d..2ddc94ce 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -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'