From 741f2ad8b2882ed396a42668922aacdf5fc2bf7b Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Mon, 11 Nov 2024 14:50:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 38 ++++++++++++------- sf_manufacturing/models/product_template.py | 4 +- .../models/sf_production_common.py | 1 + sf_manufacturing/models/stock.py | 4 ++ .../views/mrp_production_addional_change.xml | 2 +- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- 7 files changed, 37 insertions(+), 20 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index ad08be25..8cdde7e1 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -257,10 +257,22 @@ class MrpProduction(models.Model): # 工艺确认 def technology_confirm(self): + process_parameters = [] + special_design = self.technology_design_ids.filtered( + lambda a: a.routing_tag == 'special' and a.process_parameters_id is not False) + for special in special_design: + if special.process_parameters_id: + product_production_process = self.env['product.template'].search( + [('server_product_process_parameters_id', '=', special.process_parameters_id.id)]) + if not product_production_process: + if special.process_parameters_id not in process_parameters: + process_parameters.append(special.process_parameters_id.display_name) + if process_parameters: + raise UserError(_("【工艺设计】-【参数】为%s的在【产品】中不存在,请先创建", ", ".join(process_parameters))) # 判断同一个加工面的标准工序的顺序是否依次排序 + error_panel = [] technology_design = self.technology_design_ids.filtered(lambda a: a.routing_tag == 'standard').sorted( key=lambda m: m.sequence) - error_panel = [] for index, design in enumerate(technology_design): routing_type = design.route_id.routing_type if index < len(technology_design) - 1: @@ -269,18 +281,19 @@ class MrpProduction(models.Model): next_design_routing_type = next_design.route_id.routing_type logging.info('当前工序和加工面: %s-%s' % (design.route_id.name, design.panel)) logging.info('下一个工序和加工面: %s-%s' % (next_design.route_id.name, next_design.panel)) - if design.panel != next_design.panel: - if index == 0: - raise UserError('【加工面】为%s的标准工序里含有其他加工面的工序,请调整后重试' % design.panel) - if routing_type not in ['解除装夹']: - raise UserError('【加工面】为%s的标准工序顺序有误,请调整后重试' % design.panel) - if design.panel == next_design.panel: - if (routing_type == '装夹预调' and next_design_routing_type == '解除装夹') or ( - routing_type == 'CNC加工' and next_design_routing_type == '装夹预调'): - if design.panel not in error_panel: - error_panel.append(design.panel) + if design.panel is not False: + if design.panel != next_design.panel: + if index == 0: + raise UserError('【加工面】为%s的标准工序里含有其他加工面的工序,请调整后重试' % design.panel) + if routing_type not in ['解除装夹']: + raise UserError('【加工面】为%s的标准工序顺序有误,请调整后重试' % design.panel) + if design.panel == next_design.panel: + if (routing_type == '装夹预调' and next_design_routing_type == '解除装夹') or ( + routing_type == 'CNC加工' and next_design_routing_type == '装夹预调'): + if design.panel not in error_panel: + error_panel.append(design.panel) else: - if not error_panel: + if not error_panel and not process_parameters: return { 'name': _('工艺确认'), 'type': 'ir.actions.act_window', @@ -293,7 +306,6 @@ class MrpProduction(models.Model): }} if error_panel: raise UserError(_("【加工面】为%s的标准工序顺序有误,请调整后重试", ", ".join(error_panel))) - return True def action_check(self): diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 6684a8df..71aa05f8 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError from odoo.modules import get_resource_path -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_manufacturing/models/sf_production_common.py b/sf_manufacturing/models/sf_production_common.py index 234996da..dc9ff2a3 100644 --- a/sf_manufacturing/models/sf_production_common.py +++ b/sf_manufacturing/models/sf_production_common.py @@ -14,3 +14,4 @@ class SfProductionProcessParameter(models.Model): domain = [('process_id', '=', routing.surface_technics_id.id)] return self._search(domain, limit=limit, access_rights_uid=name_get_uid) return super()._name_search(name, args, operator, limit, name_get_uid) + diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index ae0a7d95..c0bd4e06 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -392,6 +392,9 @@ class StockRule(models.Model): logging.info('production_process:%s' % p.name) process_parameter = production.product_id.model_process_parameters_ids.filtered( lambda pm: pm.process_id.id == p.id) + product_production_process = self.env['product.template'].search( + [('server_product_process_parameters_id', '=', + process_parameter.id)]) if process_parameter: i += 1 route_production_process = self.env[ @@ -401,6 +404,7 @@ class StockRule(models.Model): technology_design_values.append( self.env['sf.technology.design'].json_technology_design_str(k, route_production_process, + product_production_process, i)) productions.technology_design_ids = technology_design_values diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index fea04fe6..d012fb18 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -346,7 +346,7 @@ - +