From 5bb65170724dcd86cebd41a5b37509c6ed145ae6 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 10 Apr 2018 16:20:41 +0200 Subject: [PATCH] [FIX] purchase: Wrong Fiscal position in multicompany Steps to reproduce: -Create company A -Create company B -Admin user with both companies but currently in company B -Create Demo user only with company B -Create fiscal position A to company A -Create fiscal position B to company B -Create vendor with fiscal position A with company A and the same vendor with fiscal position B in company B -Create product and add the vendor created before -Set like Create a draft purchase order -Logging with Demo user -Create sale order with one sale order line with route make to order -Validate sale order Bug: The purchase order created by sale order had the fiscal position company A. Closes #23561 opw:1825098 --- 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 07ccc261d5a..dc8fdb862b9 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -1012,7 +1012,7 @@ class ProcurementRule(models.Model): def _prepare_purchase_order(self, product_id, product_qty, product_uom, origin, values, partner): schedule_date = self._get_purchase_schedule_date(values) purchase_date = self._get_purchase_order_date(product_id, product_qty, product_uom, values, partner, schedule_date) - fpos = self.env['account.fiscal.position'].with_context(company_id=values['company_id'].id).get_fiscal_position(partner.id) + fpos = self.env['account.fiscal.position'].with_context(force_company=values['company_id'].id).get_fiscal_position(partner.id) gpo = self.group_propagation_option group = (gpo == 'fixed' and self.group_id.id) or \