From 89dc3b91bd998f9a993dc5d26b87bf7105ccd604 Mon Sep 17 00:00:00 2001 From: Matteo Boscolo Date: Tue, 24 Sep 2024 21:11:56 +0200 Subject: [PATCH] IMP: layout and fix translation recovery with null product --- plm/__manifest__.py | 2 +- plm/models/plm_mixin.py | 11 ++-- plm/models/product_product.py | 4 +- plm/views/product_product.xml | 113 ++++++++++++++++++---------------- 4 files changed, 68 insertions(+), 62 deletions(-) diff --git a/plm/__manifest__.py b/plm/__manifest__.py index 9166e817..9bd89d0c 100644 --- a/plm/__manifest__.py +++ b/plm/__manifest__.py @@ -20,7 +20,7 @@ ############################################################################## { "name": "Product Lifecycle Management", - "version": "17.0.0.4", + "version": "17.0.0.5", "author": "OmniaSolutions", "website": "https://odooplm.omniasolutions.website", "category": "Manufacturing/Product Lifecycle Management (PLM)", diff --git a/plm/models/plm_mixin.py b/plm/models/plm_mixin.py index d2ed5256..9c095b71 100644 --- a/plm/models/plm_mixin.py +++ b/plm/models/plm_mixin.py @@ -455,11 +455,12 @@ def get_all_translation(self, object_id, fields): get all field translated in all available languages """ out = {} - obj = self.env[self._name].browse([object_id]) - for field_name in fields: - for code in self.env['res.lang'].search([('active','=', True)]).mapped("code"): - propKey = f"{field_name}@-@-@{code}" - out[propKey] = getattr(obj.with_context(lang=code), field_name) + obj = self.env[self._name].search([('id','=',object_id)]) + if obj: + for field_name in fields: + for code in self.env['res.lang'].search([('active','=', True)]).mapped("code"): + propKey = f"{field_name}@-@-@{code}" + out[propKey] = getattr(obj.with_context(lang=code), field_name) return out diff --git a/plm/models/product_product.py b/plm/models/product_product.py index 8e6ab8ad..75925725 100755 --- a/plm/models/product_product.py +++ b/plm/models/product_product.py @@ -59,11 +59,11 @@ class ProductProduct(models.Model): _inherit = ['product.product'] _description ="Product Product" - def onchange(self, values, field_name, field_onchange): + def onchange(self, values, field_names, fields_spec): values = self.plm_sanitize(values) if 'product_tmpl_id' in values: del values['product_tmpl_id'] - return super(ProductProduct, self).onchange(values, field_name, field_onchange) + return super(ProductProduct, self).onchange(values, field_names, fields_spec) def action_show_reference(self): localCtx = self.env.context.copy() diff --git a/plm/views/product_product.xml b/plm/views/product_product.xml index 3eb84e38..196a057a 100755 --- a/plm/views/product_product.xml +++ b/plm/views/product_product.xml @@ -325,68 +325,73 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - -

Standard Description Parameters:

- - + + +

+ - - - - - -
- - -
+
+ + + + + + + + +
+
+ + +