[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) <vfe@odoo.com>
Signed-off-by: Fockedey Martin (mafo) <mafo@odoo.com>
This commit is contained in:
mafo-odoo
2022-07-28 03:50:57 +02:00
parent 1ebba3ea27
commit 73481b6c86
3 changed files with 5 additions and 4 deletions
+2 -2
View File
@@ -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
@@ -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
+1 -1
View File
@@ -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,
})