From b4e9b680ec5dca9a14b5712a53a67efab36cef36 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Tue, 30 Jul 2019 08:34:32 +0000 Subject: [PATCH] [FIX] purchase_stock: default to the correct company in new PO When the scheduler needs to create a new PO to resupply a product, it tries to use the 'supplier currency' on the vendor if set, and defaulted to the currency of the current user's company. However the scheduler is run in sudo, so the user is OdooBot, which means that the currency is incorrect if OdooBot is in another company. The company that should be used is the one that is used everywhere else. opw 2041798 closes odoo/odoo#35285 Signed-off-by: Nans Lefebvre (len) --- addons/purchase_stock/models/stock_rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase_stock/models/stock_rule.py b/addons/purchase_stock/models/stock_rule.py index a1f5d03fae5..b2fc19cd342 100644 --- a/addons/purchase_stock/models/stock_rule.py +++ b/addons/purchase_stock/models/stock_rule.py @@ -172,7 +172,7 @@ class StockRule(models.Model): 'partner_id': partner.id, 'picking_type_id': self.picking_type_id.id, 'company_id': values['company_id'].id, - 'currency_id': partner.with_context(force_company=values['company_id'].id).property_purchase_currency_id.id or self.env.user.company_id.currency_id.id, + 'currency_id': partner.with_context(force_company=values['company_id'].id).property_purchase_currency_id.id or values['company_id'].currency_id.id, 'dest_address_id': values.get('partner_id', False), 'origin': origin, 'payment_term_id': partner.with_context(force_company=values['company_id'].id).property_supplier_payment_term_id.id,