合并企业版代码(未测试,先提交到测试分支)
This commit is contained in:
@@ -179,32 +179,32 @@ class ResProductTemplate(models.Model):
|
||||
# product_id.product_tmpl_id.active = False
|
||||
return no_bom_copy_product_id
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
if vals['upload_model_file']:
|
||||
for item in vals['upload_model_file']:
|
||||
attachment = self.env['ir.attachment'].sudo().search([('id', '=', int(item[2][0]))])
|
||||
base64_data = base64.b64encode(attachment.datas)
|
||||
base64_datas = base64_data.decode('utf-8')
|
||||
model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||
report_path = attachment._full_path(attachment.store_fname)
|
||||
vals['model_file'] = self.transition_glb_file(report_path, model_code)
|
||||
self._sanitize_vals(vals)
|
||||
templates = super(ResProductTemplate, self).create(vals_list)
|
||||
if "create_product_product" not in self._context:
|
||||
templates._create_variant_ids()
|
||||
|
||||
# This is needed to set given values to first variant after creation
|
||||
for template, vals in zip(templates, vals_list):
|
||||
related_vals = {}
|
||||
for field_name in self._get_related_fields_variant_template():
|
||||
if vals.get(field_name):
|
||||
related_vals[field_name] = vals[field_name]
|
||||
if related_vals:
|
||||
template.write(related_vals)
|
||||
|
||||
return templates
|
||||
# @api.model_create_multi
|
||||
# def create(self, vals_list):
|
||||
# for vals in vals_list:
|
||||
# if vals['upload_model_file']:
|
||||
# for item in vals['upload_model_file']:
|
||||
# attachment = self.env['ir.attachment'].sudo().search([('id', '=', int(item[2][0]))])
|
||||
# base64_data = base64.b64encode(attachment.datas)
|
||||
# base64_datas = base64_data.decode('utf-8')
|
||||
# model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||
# report_path = attachment._full_path(attachment.store_fname)
|
||||
# vals['model_file'] = self.transition_glb_file(report_path, model_code)
|
||||
# self._sanitize_vals(vals)
|
||||
# templates = super(ResProductTemplate, self).create(vals_list)
|
||||
# if "create_product_product" not in self._context:
|
||||
# templates._create_variant_ids()
|
||||
#
|
||||
# # This is needed to set given values to first variant after creation
|
||||
# for template, vals in zip(templates, vals_list):
|
||||
# related_vals = {}
|
||||
# for field_name in self._get_related_fields_variant_template():
|
||||
# if vals.get(field_name):
|
||||
# related_vals[field_name] = vals[field_name]
|
||||
# if related_vals:
|
||||
# template.write(related_vals)
|
||||
#
|
||||
# return templates
|
||||
|
||||
@api.onchange('upload_model_file')
|
||||
def onchange_model_file(self):
|
||||
|
||||
Reference in New Issue
Block a user