From 284234adf274c51a384bd7d6eec1472bf39b8c04 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Wed, 8 Jan 2025 13:37:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=BB=A3=E7=A0=81=E9=83=A8?= =?UTF-8?q?=E5=88=86=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 35 ++++++++---------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index d26e6c33..114fd2f0 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -275,31 +275,18 @@ class ResMrpWorkOrder(models.Model): def _compute_surface_technics_purchase_ids(self): for order in self: if order.routing_type == '表面工艺' and order.state not in ['cancel']: - # if order.production_id.production_type == '自动化产线加工': - # domain = [('programming_no', '=', order.production_id.programming_no)] - # else:buzhdiao - # domain = [('origin', '=', order.production_id.origin)] - # production_programming = self.env['mrp.production'].search(domain, order='name asc') - # production_list = [production.name for production in production_programming] - # production_no_remanufacture = production_programming.filtered(lambda a: a.is_remanufacture is False) - # technology_design = self.env['sf.technology.design'].search( - # [('process_parameters_id', '=', order.surface_technics_parameters_id.id), - # ('production_id', '=', order.production_id.id)]) - # if technology_design.is_auto is False: - # domain = [('origin', '=', order.production_id.name)] - # else: - domain = [('purchase_type', '=', 'consignment'), ('origin', '=', order.production_id.name), + domain = [('purchase_type', '=', 'consignment'), + ('origin', 'like', '%' + self.production_id.name + '%'), ('state', '!=', 'cancel')] purchase = self.env['purchase.order'].search(domain) - purchase_num = 0 + order.surface_technics_purchase_count = 0 if not purchase: order.surface_technics_purchase_count = 0 for po in purchase: - for line in po.order_line: - if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id: - if line.product_qty == 1: - purchase_num += 1 - order.surface_technics_purchase_count = purchase_num + if any( + line.product_id and line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id + for line in po.order_line): + order.surface_technics_purchase_count = 1 else: order.surface_technics_purchase_count = 0 @@ -1297,7 +1284,7 @@ class ResMrpWorkOrder(models.Model): raise UserError('请先完成该工单的工艺外协再进行操作') # 表面工艺外协,最后一张工单 workorders = self.production_id.workorder_ids - subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True).sorted('sequence') + subcontract_workorders = workorders.filtered(lambda wo: wo.is_subcontract == True and wo.state != 'cancel').sorted('sequence') if self == subcontract_workorders[-1]: # 给下一个库存移动就绪 self.move_subcontract_workorder_ids[0].move_dest_ids._action_done() @@ -1321,8 +1308,10 @@ class ResMrpWorkOrder(models.Model): is_production_id = False rework_workorder = record.production_id.workorder_ids.filtered(lambda p: p.state == 'rework') done_workorder = record.production_id.workorder_ids.filtered(lambda p1: p1.state in ['done']) - if (len(rework_workorder) + len(done_workorder) == len(record.production_id.workorder_ids)) or ( - len(done_workorder) == len(record.production_id.workorder_ids)): + if (len(rework_workorder) + len(done_workorder) == len( + record.production_id.workorder_ids.filtered(lambda wo: wo.state != 'cancel'))) or ( + len(done_workorder) == len( + record.production_id.workorder_ids.filtered(lambda wo: wo.state != 'cancel'))): is_production_id = True if record.routing_type in ['解除装夹'] or ( record.is_rework is True and record.routing_type in ['装夹预调']):