From 73481b6c869c7cb4a32299f0700eca409442da09 Mon Sep 17 00:00:00 2001 From: mafo-odoo Date: Mon, 4 Jul 2022 14:33:09 +0000 Subject: [PATCH] [FIX] sale(_*): wrong translation for SOL variant description _* sale_management,sale_stock Steps to reproduce: - Install eCommerce - Enable at least one more language - Get an attribute with translations done (creation mode : never) - Get a product with this attribute - Go to the shop and add the product to the cart - Go to the summary page and change the language - Attributes fields aren't translated Explanation: This commit reverts the fix commit 47777ce1a7ee189c9328f53143abe492e861779e that set the language of this description variants in function of the order partner lang. We move where the language is added in the context so that other cases like website_sale still have the right translations. opw-2790240 closes odoo/odoo#96811 X-original-commit: 9d3ffc9a1d817313764bc4b94f75711fd753fbc3 Signed-off-by: Victor Feyens (vfe) Signed-off-by: Fockedey Martin (mafo) --- addons/sale/models/sale_order_line.py | 4 ++-- addons/sale_management/models/sale_order_line.py | 3 ++- addons/sale_stock/models/sale_order_line.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/sale/models/sale_order_line.py b/addons/sale/models/sale_order_line.py index 46fda7b1133..f359fb922bf 100644 --- a/addons/sale/models/sale_order_line.py +++ b/addons/sale/models/sale_order_line.py @@ -328,13 +328,13 @@ class SaleOrderLine(models.Model): # display the no_variant attributes, except those that are also # displayed by a custom (avoid duplicate description) for ptav in (no_variant_ptavs - custom_ptavs): - name += "\n" + ptav.with_context(lang=self.order_partner_id.lang).display_name + name += "\n" + ptav.display_name # Sort the values according to _order settings, because it doesn't work for virtual records in onchange custom_values = sorted(self.product_custom_attribute_value_ids, key=lambda r: (r.custom_product_template_attribute_value_id.id, r.id)) # display the is_custom values for pacv in custom_values: - name += "\n" + pacv.with_context(lang=self.order_partner_id.lang).display_name + name += "\n" + pacv.display_name return name diff --git a/addons/sale_management/models/sale_order_line.py b/addons/sale_management/models/sale_order_line.py index faffeb2a204..be07a6da722 100644 --- a/addons/sale_management/models/sale_order_line.py +++ b/addons/sale_management/models/sale_order_line.py @@ -18,5 +18,6 @@ class SaleOrderLine(models.Model): if line.product_id and line.order_id.sale_order_template_id: for template_line in line.order_id.sale_order_template_id.sale_order_template_line_ids: if line.product_id == template_line.product_id: - line.name = template_line.with_context(lang=line.order_id.partner_id.lang).name + line._get_sale_order_line_multiline_description_variants() + lang = line.order_id.partner_id.lang + line.name = template_line.with_context(lang=lang).name + line.with_context(lang=lang)._get_sale_order_line_multiline_description_variants() break diff --git a/addons/sale_stock/models/sale_order_line.py b/addons/sale_stock/models/sale_order_line.py index 41b7afff674..b91ff510a67 100644 --- a/addons/sale_stock/models/sale_order_line.py +++ b/addons/sale_stock/models/sale_order_line.py @@ -244,7 +244,7 @@ class SaleOrderLine(models.Model): 'route_ids': self.route_id, 'warehouse_id': self.order_id.warehouse_id or False, 'partner_id': self.order_id.partner_shipping_id.id, - 'product_description_variants': self._get_sale_order_line_multiline_description_variants(), + 'product_description_variants': self.with_context(lang=self.order_id.partner_id.lang)._get_sale_order_line_multiline_description_variants(), 'company_id': self.order_id.company_id, 'product_packaging_id': self.product_packaging_id, })