[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) <len@odoo.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user