From 7df349883d24c104b3003547f3ac1d79954236bb Mon Sep 17 00:00:00 2001 From: "Nasreddin Boulif (bon)" Date: Tue, 27 Jul 2021 20:03:03 +0000 Subject: [PATCH] [FIX] account: Fallback on self.env.user language if not user_id on PO Steps to reproduce: - Install purchase and accounting apps - Set the database to a language that is not English - Create a purchase order - Remove purchase representative from PO (otherwise, no issue) - Action -> Create Vendor Bill - From the vendor bill, print invoice Issue: The pdf is in English (country names, date labels, etc...) Cause: If invoice type is `in_invoice` or `in_refund`, it will use the `invoice_user_id` language (object.invoice_user_id.sudo().lang). In the above case, there is no invoice_user_id on invoice. Solution: While preparing invoice values, set invoice_user_id to self.env.user.id if not user_id on PO. opw-2510134 closes odoo/odoo#74671 X-original-commit: 4b7569ce641a6fb20d5df676bf0b315d9b9d485d Signed-off-by: bon-odoo --- addons/purchase/models/purchase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 2c26d013745..59ef2f525e4 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -578,7 +578,7 @@ class PurchaseOrder(models.Model): 'move_type': move_type, 'narration': self.notes, 'currency_id': self.currency_id.id, - 'invoice_user_id': self.user_id and self.user_id.id, + 'invoice_user_id': self.user_id and self.user_id.id or self.env.user.id, 'partner_id': partner_invoice_id, 'fiscal_position_id': (self.fiscal_position_id or self.fiscal_position_id.get_fiscal_position(partner_invoice_id)).id, 'payment_reference': self.partner_ref or '',