调整模型上传的流程
This commit is contained in:
@@ -682,14 +682,16 @@ class MrpProduction(models.Model):
|
||||
'model_order_no': cnc.product_id.default_code,
|
||||
'user': cnc.env.user.name,
|
||||
'programme_way': programme_way,
|
||||
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
|
||||
cnc.product_id.model_file).decode('utf-8'),
|
||||
# 'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
|
||||
# cnc.product_id.model_file).decode('utf-8'),
|
||||
'glb_url': cnc.product_id.glb_url,
|
||||
'part_name': cnc.product_id.part_name,
|
||||
'part_number': cnc.product_id.part_number,
|
||||
'machining_drawings': base64.b64encode(cnc.product_id.machining_drawings).decode(
|
||||
'utf-8') if cnc.product_id.machining_drawings else '',
|
||||
'machining_drawings_name': cnc.product_id.machining_drawings_name,
|
||||
'machining_drawings_mimetype': cnc.product_id.machining_drawings_mimetype,
|
||||
'model_id': cnc.product_id.model_id,
|
||||
}
|
||||
# 打印出除了 model_file 之外的所有键值对
|
||||
for key, value in res.items():
|
||||
|
||||
@@ -29,6 +29,7 @@ class ResProductMo(models.Model):
|
||||
model_width = fields.Float('模型宽(mm)', digits=(16, 3))
|
||||
model_height = fields.Float('模型高(mm)', digits=(16, 3))
|
||||
model_volume = fields.Float('模型体积(m³)')
|
||||
model_area = fields.Float('模型表面积(m²)')
|
||||
model_machining_precision = fields.Selection(selection=_get_machining_precision, string='加工精度')
|
||||
model_processing_panel = fields.Char('模型加工面板')
|
||||
model_remark = fields.Char('模型备注说明')
|
||||
@@ -171,6 +172,7 @@ class ResProductMo(models.Model):
|
||||
'压紧方式', domain=[('type', '=', '压紧方式')])
|
||||
|
||||
name = fields.Char('产品名称', compute='_compute_tool_name', store=True, required=False)
|
||||
|
||||
|
||||
@api.constrains('seller_ids')
|
||||
def _check_seller_ids(self):
|
||||
@@ -780,6 +782,13 @@ class ResProductMo(models.Model):
|
||||
part_number = fields.Char(string='零件图号', readonly=True)
|
||||
machining_drawings_name = fields.Char(string='零件图号名称', readonly=True)
|
||||
machining_drawings_mimetype = fields.Char(string='零件图号类型', readonly=True)
|
||||
|
||||
model_url = fields.Char('模型文件地址')
|
||||
glb_url = fields.Char('glb文件地址')
|
||||
area = fields.Float('表面积(m²)')
|
||||
auto_machining = fields.Boolean('自动化加工(模型识别)', default=False)
|
||||
model_id = fields.Char('模型id')
|
||||
|
||||
@api.constrains('tool_length')
|
||||
def _check_tool_length_size(self):
|
||||
if self.tool_length > 1000000:
|
||||
@@ -850,7 +859,7 @@ class ResProductMo(models.Model):
|
||||
copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy()
|
||||
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'])
|
||||
# attachment = self.attachment_create(item['model_name'], item['model_data'])
|
||||
# 获取坯料冗余配置
|
||||
if not item.get('embryo_redundancy'):
|
||||
embryo_redundancy_id = model_type.embryo_tolerance_id
|
||||
@@ -863,9 +872,8 @@ class ResProductMo(models.Model):
|
||||
'model_long': self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
||||
'model_width': self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
||||
'model_height': 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_volume': self.format_float(item['blank_volume']),
|
||||
'model_area': self.format_float(item['blank_area']),
|
||||
'product_model_type_id': model_type.id,
|
||||
'model_processing_panel': item['processing_panel_detail'],
|
||||
'model_machining_precision': item['model_machining_precision'],
|
||||
@@ -873,10 +881,14 @@ class ResProductMo(models.Model):
|
||||
'length': item['model_long'],
|
||||
'width': item['model_width'],
|
||||
'height': item['model_height'],
|
||||
'volume': item['model_long'] * item['model_width'] * item['model_height'],
|
||||
'model_file': '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||
'model_name': attachment.name if attachment else None,
|
||||
'upload_model_file': [(6, 0, [attachment.id])] if attachment else None,
|
||||
'volume': item['model_volume'],
|
||||
'area': item['model_area'],
|
||||
# 'model_file': '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||
'model_url': item['model_url'],
|
||||
'glb_url': item['glb_url'],
|
||||
'model_name': item['model_name'],
|
||||
'auto_machining': item['auto_machining'],
|
||||
# 'upload_model_file': [(6, 0, [attachment.id])] if attachment else None,
|
||||
'list_price': item['price'],
|
||||
'materials_id': self.env['sf.production.materials'].search(
|
||||
[('materials_no', '=', item['texture_code'])]).id,
|
||||
@@ -896,6 +908,7 @@ class ResProductMo(models.Model):
|
||||
'part_name': item.get('part_name') or '',
|
||||
'machining_drawings_name': item.get('machining_drawings_name') or '',
|
||||
'machining_drawings_mimetype': item.get('machining_drawings_mimetype') or '',
|
||||
'model_id': item['model_id'],
|
||||
}
|
||||
tax_id = self.env['account.tax'].sudo().search(
|
||||
[('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')])
|
||||
@@ -978,15 +991,14 @@ class ResProductMo(models.Model):
|
||||
vals = {
|
||||
'name': '%s-%s-%s [%s %s-%s * %s * %s]' % ('R',
|
||||
order_id.name, i, materials_id.name, materials_type_id.name,
|
||||
item['model_long'] + embryo_redundancy_id.long,
|
||||
item['model_width'] + embryo_redundancy_id.width,
|
||||
item['model_height'] + embryo_redundancy_id.height),
|
||||
'length': item['model_long'] + embryo_redundancy_id.long,
|
||||
'width': item['model_width'] + embryo_redundancy_id.width,
|
||||
'height': item['model_height'] + embryo_redundancy_id.height,
|
||||
'volume': (item['model_long'] + embryo_redundancy_id.long) * (
|
||||
item['model_width'] + embryo_redundancy_id.width) * (
|
||||
item['model_height'] + embryo_redundancy_id.height),
|
||||
self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
||||
self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
||||
self.format_float(item['model_height'] + embryo_redundancy_id.height)),
|
||||
'length': self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
||||
'width': self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
||||
'height': self.format_float(item['model_height'] + embryo_redundancy_id.height),
|
||||
'volume': self.format_float(item['blank_volume']),
|
||||
'area': self.format_float(item['blank_area']),
|
||||
'embryo_model_type_id': model_type.id,
|
||||
'list_price': item['price'],
|
||||
'materials_id': materials_id.id,
|
||||
@@ -1078,6 +1090,9 @@ class ResProductMo(models.Model):
|
||||
image_data = fileObj.read()
|
||||
base64_data = base64.b64encode(image_data)
|
||||
return base64_data
|
||||
|
||||
# 增加产品表面积
|
||||
|
||||
|
||||
|
||||
class ResProductFixture(models.Model):
|
||||
|
||||
@@ -51,13 +51,15 @@ class SaleOrder(models.Model):
|
||||
|
||||
order_id = self
|
||||
product = line.product_id
|
||||
# 拼接方法需要的item结构
|
||||
# 拼接方法需要的item结构,成品的模型数据信息就是坯料的数据信息
|
||||
item = {
|
||||
'texture_code': product.materials_id.materials_no,
|
||||
'texture_type_code': product.materials_type_id.materials_no,
|
||||
'model_long': product.length,
|
||||
'model_width': product.width,
|
||||
'model_height': product.height,
|
||||
'blank_volume': product.model_volume,
|
||||
'blank_area': product.model_area,
|
||||
'price': product.list_price,
|
||||
'embryo_redundancy_id': line.embryo_redundancy_id,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user