From 3ff9c48ba90960ba62b5b4d275b59058a329eb55 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Mon, 16 Jan 2023 13:41:10 +0000 Subject: [PATCH] [FIX] sale: use partner's lang on creating invoices This commit adds lang context on preparing invoice lines. Othwerwise we may get lines in user's lang instead of partner lang. For example, it's needed in sale_subscription module: https://github.com/odoo/enterprise/blob/e5e168d596aaefcd842fc553890e474aff3322f2/sale_subscription/models/sale_order_line.py#L235-L236 https://github.com/odoo/enterprise/blob/e5e168d596aaefcd842fc553890e474aff3322f2/sale_subscription/models/sale_order_line.py#L262 STEPS: - Use English as your user language - Set a language different from English on a customer C - Create a subscription product P - Create a SO for C with P - Create the invoice opw-3104785 closes odoo/odoo#110152 X-original-commit: 6dee103df5e5f64d8edf871d4e1a284ef4d21725 Signed-off-by: Ivan Elizaryev (iel) --- addons/sale/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index 24c08a96438..e7e42a0335f 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -1078,7 +1078,7 @@ class SaleOrder(models.Model): invoice_vals_list = [] invoice_item_sequence = 0 # Incremental sequencing to keep the lines order on the invoice. for order in self: - order = order.with_company(order.company_id) + order = order.with_company(order.company_id).with_context(lang=order.partner_invoice_id.lang) invoice_vals = order._prepare_invoice() invoiceable_lines = order._get_invoiceable_lines(final)