summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorsofiagvaladze <sgv@odoo.com>2020-11-30 20:30:31 +0000
committersofiagvaladze <sgv@odoo.com>2020-12-09 13:47:52 +0000
commit7473ad44f960aa3609faafe0cee8e12a392b43a9 (patch)
tree63e4e651b795b75679fe33024c01329432027349 /addons
parent1ddbcb4860ee220e9f826e8b6f6b85b6c22fb2b7 (diff)
[FIX] hr_expense: Fix traceback caused by empty currency_id
One can leave the currency_id empty and that causes Traceback error Task - 2409942 closes odoo/odoo#62648 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/hr_expense/models/hr_expense.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py
index fa2aecad30a..b173c7cd3ec 100644
--- a/addons/hr_expense/models/hr_expense.py
+++ b/addons/hr_expense/models/hr_expense.py
@@ -77,6 +77,7 @@ class HrExpense(models.Model):
company_currency_id = fields.Many2one('res.currency', string="Report Company Currency", related='sheet_id.currency_id', store=True, readonly=False)
total_amount_company = fields.Monetary("Total (Company Currency)", compute='_compute_total_amount_company', store=True, currency_field='company_currency_id')
company_id = fields.Many2one('res.company', string='Company', required=True, readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=lambda self: self.env.company)
+ # TODO make required in master (sgv)
currency_id = fields.Many2one('res.currency', string='Currency', readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=lambda self: self.env.company.currency_id)
analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', check_company=True)
analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic Tags', states={'post': [('readonly', True)], 'done': [('readonly', True)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]")
@@ -576,7 +577,7 @@ Or send your receipts at <a href="mailto:%(email)s?subject=Lunch%%20with%%20cust
], ['total_amount', 'currency_id', 'state'], ['state', 'currency_id'], lazy=False)
for expense in expenses:
state = expense['state']
- currency = self.env['res.currency'].browse(expense['currency_id'][0])
+ currency = self.env['res.currency'].browse(expense['currency_id'][0]) if expense['currency_id'] else target_currency
amount = currency._convert(
expense['total_amount'], target_currency, self.env.company, fields.Date.today())
expense_state[state]['amount'] += amount