Skip to content

Commit

Permalink
[FIX] sale: translate product description
Browse files Browse the repository at this point in the history
Issue:
In a multi-language environment, the product description in sales
orders defaults to English, regardless of the user's language
preference. This issue occurs when the language of the partner
is not set, leading to a mismatch between the user's expected language
and the displayed language for product descriptions.

Steps to Reproduce:
1. Ensure the database supports multiple languages.
2. Set the user's preferred language to a non-English language.
3. Create a new sale order for a partner whose language is not set.
4. Add a product and observe that its description is displayed in
    English instead of the user's preferred language.

Solution:
Modified the logic to default the product description to the user's
language preference when the partner's language is not specified.

opw-3586451

closes odoo#142227

X-original-commit: 29ace25
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Kawtar Drissi El Bouzaidi (kdeb) <kdeb@odoo.com>
  • Loading branch information
kawkb committed Nov 20, 2023
1 parent 430f51f commit 881e9c4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions addons/sale/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,14 @@ def _compute_no_variant_attribute_values(self):
@api.depends('product_id')
def _compute_name(self):
for line in self:
lang = line.order_partner_id.lang or self.env.user.lang
if not line.product_id:
continue
if not line.order_partner_id.is_public:
line = line.with_context(lang=line.order_partner_id.lang)
line = line.with_context(lang=lang)
name = line._get_sale_order_line_multiline_description_sale()
if line.is_downpayment and not line.display_type:
context = {'lang': line.order_partner_id.lang}
context = {'lang': lang}
dp_state = line._get_downpayment_state()
if dp_state == 'draft':
name = _("%(line_description)s (Draft)", line_description=name)
Expand Down

0 comments on commit 881e9c4

Please sign in to comment.