Skip to content

Commit

Permalink
[FIX] account: check exchange rate
Browse files Browse the repository at this point in the history
An issue occurs in the following situation:
- Define a currency exchange rate at day 1 and day 2
- Create an invoice at day 1, and calculate the taxes. Do not set an
  invoice date!
- Validate the invoice at day 2

The exchange rate for taxes is the rate at day 1, while the exchange
rate for other amounts is the rate at day 2.

There is actually no way to know what was the rate applied for the
taxes at invoice validation. There are two solutions:
- recompute the taxes at validation
- force the user to set an invoice date and recompute manually the
  taxes

The first solution might have unexpected effects, therefore the second
solution is applied.

Fixes odoo#13473
opw-688517
  • Loading branch information
nim-odoo committed Oct 10, 2016
1 parent d3c4ab2 commit a1d6c2d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion addons/account/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,11 +807,20 @@ def action_move_create(self):

ctx = dict(self._context, lang=inv.partner_id.lang)

company_currency = inv.company_id.currency_id
if not inv.date_invoice:
# FORWARD-PORT UP TO SAAS-6
if inv.currency_id != company_currency and inv.tax_line:
raise except_orm(
_('Warning!'),
_('No invoice date!'
'\nThe invoice currency is not the same than the company currency.'
' An invoice date is required to determine the exchange rate to apply. Do not forget to update the taxes!'
)
)
inv.with_context(ctx).write({'date_invoice': fields.Date.context_today(self)})
date_invoice = inv.date_invoice

company_currency = inv.company_id.currency_id
# create the analytical lines, one move line per invoice line
iml = inv._get_analytic_lines()
# check if taxes are all computed
Expand Down

0 comments on commit a1d6c2d

Please sign in to comment.