[FIX] base,account,product: correct currency convertion when company is get from context
Method `_convert` expect a browserecord, not an integer.
This commit is contained in:
@@ -1203,7 +1203,11 @@ class AccountMoveLine(models.Model):
|
||||
amount_currency = False
|
||||
currency_id = False
|
||||
date = self.env.context.get('date') or fields.Date.today()
|
||||
company = self.env.context.get('company_id', self.env.user.company_id)
|
||||
company_id = self.env.context.get('company_id')
|
||||
if company_id:
|
||||
company = self.env['res.company'].browse(company_id)
|
||||
else:
|
||||
company = self.env.user.company_id
|
||||
if src_currency and src_currency != company_currency:
|
||||
amount_currency = amount
|
||||
amount = src_currency._convert(amount, company_currency, company, date)
|
||||
|
||||
@@ -399,7 +399,10 @@ class ProductTemplate(models.Model):
|
||||
# We fetch the standard price as the superuser
|
||||
templates = self.with_context(force_company=company and company.id or self._context.get('force_company', self.env.user.company_id.id)).sudo()
|
||||
if not company:
|
||||
company = self._context.get('force_company', self.env.user.company_id.id)
|
||||
if self._context.get('force_company'):
|
||||
company = self.env['res.company'].browse(self._context['force_company'])
|
||||
else:
|
||||
company = self.env.user.company_id
|
||||
date = self.env.context.get('date') or fields.Date.today()
|
||||
|
||||
prices = dict.fromkeys(self.ids, 0.0)
|
||||
|
||||
@@ -323,7 +323,11 @@ class MonetaryConverter(models.AbstractModel):
|
||||
|
||||
if options.get('from_currency'):
|
||||
date = options.get('date') or fields.Date.today()
|
||||
company = options.get('company_id') or self.env.user.company_id
|
||||
company_id = options.get('company_id')
|
||||
if company_id:
|
||||
company = self.env['res.company'].browse(company_id)
|
||||
else:
|
||||
company = self.env.user.company_id
|
||||
value = options['from_currency']._convert(value, display_currency, company, date)
|
||||
|
||||
lang = self.user_lang()
|
||||
|
||||
Reference in New Issue
Block a user