From afcf0fba8d7d217af74ca126d7ef52cd4b238496 Mon Sep 17 00:00:00 2001 From: Saran440 Date: Thu, 2 Mar 2023 03:13:28 +0000 Subject: [PATCH] [FIX] purchase: default currency from context closes odoo/odoo#116238 X-original-commit: ba6f90c2d664b7cef7f7ecd619b763ad6fe2138b Signed-off-by: William Henrotin (whe) --- addons/purchase/models/purchase.py | 5 +++-- .../views/purchase_requisition_views.xml | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index bfeecdfcf3e..4c3f4b632b0 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -286,13 +286,14 @@ class PurchaseOrder(models.Model): # are taken with the company of the order # if not defined, with_company doesn't change anything. self = self.with_company(self.company_id) + default_currency = self._context.get("default_currency_id") if not self.partner_id: self.fiscal_position_id = False - self.currency_id = self.env.company.currency_id.id + self.currency_id = default_currency or self.env.company.currency_id.id else: self.fiscal_position_id = self.env['account.fiscal.position']._get_fiscal_position(self.partner_id) self.payment_term_id = self.partner_id.property_supplier_payment_term_id.id - self.currency_id = self.partner_id.property_purchase_currency_id.id or self.env.company.currency_id.id + self.currency_id = default_currency or self.partner_id.property_purchase_currency_id.id or self.env.company.currency_id.id return {} @api.onchange('fiscal_position_id', 'company_id') diff --git a/addons/purchase_requisition/views/purchase_requisition_views.xml b/addons/purchase_requisition/views/purchase_requisition_views.xml index 9f524795473..f6907eab39f 100644 --- a/addons/purchase_requisition/views/purchase_requisition_views.xml +++ b/addons/purchase_requisition/views/purchase_requisition_views.xml @@ -103,12 +103,15 @@
+