From 0042165b6084b7e8d085b3d4fcb0b1aa4a13e298 Mon Sep 17 00:00:00 2001 From: Matteo Boscolo Date: Fri, 22 Nov 2024 13:20:39 +0100 Subject: [PATCH] fix singleton error --- plm/models/ir_attachment.py | 6 ++++-- plm_auto_internalref/models/product_template.py | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/plm/models/ir_attachment.py b/plm/models/ir_attachment.py index 97a1cc70..3c7f3ca0 100755 --- a/plm/models/ir_attachment.py +++ b/plm/models/ir_attachment.py @@ -3241,14 +3241,16 @@ def GetCloneDocumentValues(self, args): """ return the new attributes to be used for cloning the document """ - _old_product_attrs, old_attachment_attrs, new_product_attrs = args + old_product_attrs, old_attachment_attrs, new_product_attrs = args out_attachment_value = json.loads(old_attachment_attrs) new_product_attrs = json.loads(new_product_attrs) if hasattr(self, "customGetCloneDocumentValues"): # # If you implement the customGetCloneDocumentValues this call will be used to customize the value of the new cloned document from the client clone action # - out_attachment_value=self.customGetCloneDocumentValues(out_attachment_value) + out_attachment_value=self.customGetCloneDocumentValues(out_attachment_value, + json.loads(old_product_attrs), + new_product_attrs) else: # out_attachment_value['engineering_code'] = f"{new_product_attrs['engineering_code']}-{self.env['ir.sequence'].next_by_code('ir.attachment.progress')}" diff --git a/plm_auto_internalref/models/product_template.py b/plm_auto_internalref/models/product_template.py index 4d6b35f0..b7ae03e6 100755 --- a/plm_auto_internalref/models/product_template.py +++ b/plm_auto_internalref/models/product_template.py @@ -46,11 +46,11 @@ def create(self, vals): return super().create(vals) def write(self, vals): - new_default_code = self.env['product.product'].computeDefaultCode(vals, - self) - if new_default_code : - logging.info('OdooPLM: Default Code set to %s ' % (new_default_code)) - vals['default_code'] = new_default_code + for product_template_id in self: + new_default_code = self.env['product.product'].computeDefaultCode(vals, + product_template_id) + if new_default_code : + vals['default_code'] = new_default_code return super(ProductTemplateExtension, self).write(vals)