From 34e858ffe49ca5ac9a477ff7b58728b2be178adb Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 9 Aug 2024 11:31:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=A8=E9=9D=A2=E5=B7=A5?= =?UTF-8?q?=E8=89=BA=E6=9C=8D=E5=8A=A1=E4=BA=A7=E5=93=81=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 10 +++++++--- sf_manufacturing/models/product_template.py | 4 +++- sf_manufacturing/models/stock.py | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index ed4786cd..6568fba2 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -137,9 +137,13 @@ class ResMrpWorkOrder(models.Model): @api.depends('name', 'production_id.name') def _compute_surface_technics_picking_ids(self): - for order in self: - picking_ids = self.env['stock.picking'].search([('id', 'in', order.picking_ids.ids)]) - order.surface_technics_picking_count = len(picking_ids) + for workorder in self: + if workorder.routing_type == '表面工艺': + picking_ids = self.env['stock.picking'].search( + [('surface_technics_parameters_id', '=', workorder.surface_technics_parameters_id)], order='id asc') + workorder.surface_technics_picking_count = len(picking_ids) + else: + workorder.surface_technics_picking_count = 0 def action_view_surface_technics_picking(self): self.ensure_one() diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 41392409..f8afb0be 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -755,7 +755,9 @@ class ResProductMo(models.Model): # 产品名称唯一性校验 for item in templates: if len(self.search([('name', '=', item.name)])) > 1: - raise ValidationError('产品名称【%s】已存在' % item.name) + raise UserError('产品名称【%s】已存在' % item.name) + if len(self.search([('server_product_process_parameters_id', '=', item.server_product_process_parameters_id)])) > 1: + raise UserErro('表面工艺参数为【%s】的产品已存在' % item.server_product_process_parameters_id.name) if "create_product_product" not in self._context: templates._create_variant_ids() diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 76248171..55f9428d 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -661,6 +661,7 @@ class ReStockMove(models.Model): return { 'name': self.env['stock.picking']._get_name_Res(rescode), 'origin': item.name, + 'surface_technics_parameters_id': sorted_workorders.surface_technics_parameters_id.id, 'company_id': self.mapped('company_id').id, 'user_id': False, 'move_type': self.mapped('group_id').move_type or 'direct',