Accept Merge Request #2220: (feature/质检按钮隐藏 -> develop)

Merge Request: 处理 bfm内部下单包含坯料尺寸时,生成的产品的加工参数-体积数据不正确问题

Created By: @禹翔辉
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @禹翔辉
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2220
This commit is contained in:
禹翔辉
2025-06-19 16:34:32 +08:00
committed by Coding
2 changed files with 22 additions and 12 deletions

View File

@@ -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'],

View File

@@ -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'],