Skip to content

Commit

Permalink
IMP: update product image upon product save based on linked document
Browse files Browse the repository at this point in the history
  • Loading branch information
mboscolo committed Mar 20, 2023
1 parent 5a74565 commit 569c481
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 0 additions & 3 deletions plm/models/product_product.py
Expand Up @@ -954,9 +954,6 @@ def create(self, vals):

def write(self, vals):
for product in self:
for document in product.linkeddocuments:
vals.update({'image_variant_1920': document.preview})
break
if 'is_engcode_editable' not in vals and product.engineering_code not in ['-',False]:
vals['is_engcode_editable'] = False
vals.update(product.checkMany2oneClient(vals))
Expand Down
5 changes: 5 additions & 0 deletions plm/models/product_template.py
Expand Up @@ -187,6 +187,11 @@ def create(self, vals):
return super().create(to_create)

def write(self, vals):
for product in self:
for document in product.product_variant_id.linkeddocuments:
if document.document_type=='3d':
vals.update({'image_1920': document.preview})
break
vals = self.plm_sanitize(vals)
return super(ProductTemplate, self).write(vals)

Expand Down

0 comments on commit 569c481

Please sign in to comment.