Skip to content

Commit

Permalink
FIX l10n_it_withholding_tax in multi currency env. Use case: (OCA#451)
Browse files Browse the repository at this point in the history
- Create a USD bank journal
 - Add 2 rates to USD currency: yesterday with rate 0.8; today with rate 0.9
 - Create an USD invoice with date = yesterday
 - Create a bank statement (on USD bank account) today registering a full payment and try to reconcile

Get "Valore di credito o debito errato nella registrazione contabile"
  • Loading branch information
eLBati authored and alessandrocamilli committed Jun 26, 2018
1 parent 5ad6b3d commit 4e9ab33
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions l10n_it_withholding_tax/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

{
'name': 'Italian Withholding Tax',
'version': '10.0.1.0.1',
'version': '10.0.1.0.2',
'category': 'Account',
'author': 'Openforce, Odoo Italia Network, '
'Odoo Community Association (OCA)',
'website': 'https://odoo-community.org/',
'website': 'https://www.odoo-italia.net/',
'license': 'AGPL-3',
"depends": ['account'],
"data": [
Expand Down
7 changes: 6 additions & 1 deletion l10n_it_withholding_tax/models/account.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2015 Alessandro Camilli (<http://www.openforce.it>)
# Copyright 2018 Lorenzo Battistini - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).


Expand Down Expand Up @@ -29,7 +30,11 @@ def create(self, vals):
break
# Limit value of reconciliation
if invoice and invoice.amount_net_pay:
if vals.get('amount') > invoice.amount_net_pay:
# We must consider amount in foreign currency, if present
# Note that this is always executed, for every reconciliation.
# Thus, we must not chnage amount when not in withholding tax case
amount = vals.get('amount_currency') or vals.get('amount')
if amount > invoice.amount_net_pay:
vals.update({'amount': invoice.amount_net_pay})

# Create reconciliation
Expand Down

0 comments on commit 4e9ab33

Please sign in to comment.