From 8bd1c8a0953bd34d7bef17be6744b357555e8387 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 19 Jun 2025 16:29:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=20bfm=E5=86=85=E9=83=A8?= =?UTF-8?q?=E4=B8=8B=E5=8D=95=E5=8C=85=E5=90=AB=E5=9D=AF=E6=96=99=E5=B0=BA?= =?UTF-8?q?=E5=AF=B8=E6=97=B6=EF=BC=8C=E7=94=9F=E6=88=90=E7=9A=84=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E7=9A=84=E5=8A=A0=E5=B7=A5=E5=8F=82=E6=95=B0-?= =?UTF-8?q?=E4=BD=93=E7=A7=AF=E6=95=B0=E6=8D=AE=E4=B8=8D=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_dlm/models/product_template.py | 17 +++++++++++------ sf_manufacturing/models/product_template.py | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/sf_dlm/models/product_template.py b/sf_dlm/models/product_template.py index e4b15922..b7d54518 100644 --- a/sf_dlm/models/product_template.py +++ b/sf_dlm/models/product_template.py @@ -73,15 +73,20 @@ class ResProductTemplate(models.Model): copy_product_id.product_tmpl_id.active = True model_type = self.env['sf.model.type'].search([], limit=1) attachment = self.attachment_create(item['model_name'], item['model_data']) + # 判断参数中是否包含 坯料尺寸(长、宽、高) + blank_bool = any(value is not None and value != 0 for value in ( + item.get('blank_length'), item.get('blank_width'), item.get('blank_height'))) if all( + key in item for key in ('blank_length', 'blank_width', 'blank_height')) else False vals = { 'name': '%s-%s-%s' % ('P', order_id.name, i), 'blank_type': item.get('blank_type'), - 'model_long': item.get('blank_length') if item.get('blank_length') else item['model_long'] + model_type.embryo_tolerance, - 'model_width': item.get('blank_width') if item.get('blank_width') else item['model_width'] + model_type.embryo_tolerance, - 'model_height': item.get('blank_height') if item.get('blank_height') else item['model_height'] + model_type.embryo_tolerance, - 'model_volume': (item['model_long'] + model_type.embryo_tolerance) * ( - item['model_width'] + model_type.embryo_tolerance) * ( - item['model_height'] + model_type.embryo_tolerance), + 'model_long': item.get('blank_length') if blank_bool else item['model_long'] + model_type.embryo_tolerance, + 'model_width': item.get('blank_width') if blank_bool else item['model_width'] + model_type.embryo_tolerance, + 'model_height': item.get('blank_height') if blank_bool else item['model_height'] + model_type.embryo_tolerance, + 'model_volume': ((item['model_long'] + model_type.embryo_tolerance) * + (item['model_width'] + model_type.embryo_tolerance) * + (item['model_height'] + model_type.embryo_tolerance)) if not blank_bool else ( + item.get('blank_length') * item.get('blank_width') * item.get('blank_height')), 'product_model_type_id': model_type.id, 'model_processing_panel': 'R', 'model_machining_precision': item['model_machining_precision'], diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 5f371aed..30d807d1 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -894,15 +894,20 @@ class ResProductMo(models.Model): if not embryo_redundancy_id: raise UserError('请先配置模型类型内的坯料冗余') product_name = self.generate_product_name(order_id, item, i) + # 判断参数中是否包含 坯料尺寸(长、宽、高) + blank_bool = any(value is not None and value != 0 for value in ( + item.get('blank_length'), item.get('blank_width'), item.get('blank_height'))) if all( + key in item for key in ('blank_length', 'blank_width', 'blank_height')) else False vals = { 'name': product_name, 'blank_type': item.get('blank_type'), - 'model_long': item.get('blank_length') if item.get('blank_length') else self.format_float(item['model_long'] + embryo_redundancy_id.long), - 'model_width': item.get('blank_width') if item.get('blank_width') else self.format_float(item['model_width'] + embryo_redundancy_id.width), - 'model_height': item.get('blank_height') if item.get('blank_height') else self.format_float(item['model_height'] + embryo_redundancy_id.height), - 'model_volume': self.format_float((item['model_long'] + embryo_redundancy_id.long) * ( - item['model_width'] + embryo_redundancy_id.width) * ( - item['model_height'] + embryo_redundancy_id.height)), + 'model_long': item.get('blank_length') if blank_bool else self.format_float(item['model_long'] + embryo_redundancy_id.long), + 'model_width': item.get('blank_width') if blank_bool else self.format_float(item['model_width'] + embryo_redundancy_id.width), + 'model_height': item.get('blank_height') if blank_bool else self.format_float(item['model_height'] + embryo_redundancy_id.height), + 'model_volume': self.format_float(((item['model_long'] + model_type.embryo_tolerance) * + (item['model_width'] + model_type.embryo_tolerance) * + (item['model_height'] + model_type.embryo_tolerance))) if not blank_bool else ( + item.get('blank_length') * item.get('blank_width') * item.get('blank_height')), 'product_model_type_id': model_type.id, 'model_processing_panel': item['processing_panel_detail'], 'model_machining_precision': item['model_machining_precision'],