From 569c481efd6c48be671cb96e50cb34e38d719631 Mon Sep 17 00:00:00 2001 From: Matteo Boscolo Date: Mon, 20 Mar 2023 13:20:59 +0100 Subject: [PATCH] IMP: update product image upon product save based on linked document --- plm/models/product_product.py | 3 --- plm/models/product_template.py | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plm/models/product_product.py b/plm/models/product_product.py index 9d61b9ea..4fac7a8f 100755 --- a/plm/models/product_product.py +++ b/plm/models/product_product.py @@ -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)) diff --git a/plm/models/product_template.py b/plm/models/product_template.py index 933b7569..d512ccf1 100755 --- a/plm/models/product_template.py +++ b/plm/models/product_template.py @@ -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)