diff --git a/account_move_base_import/README.rst b/account_move_base_import/README.rst index 8d578ef5..e00c255f 100644 --- a/account_move_base_import/README.rst +++ b/account_move_base_import/README.rst @@ -83,6 +83,7 @@ Contributors * Laurent Mignon * Sébastien Beau * Matthieu Dietrich +* Alexandre Fayolle Maintainer ---------- diff --git a/account_move_base_import/__manifest__.py b/account_move_base_import/__manifest__.py index e37ce448..a65c214c 100644 --- a/account_move_base_import/__manifest__.py +++ b/account_move_base_import/__manifest__.py @@ -6,7 +6,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) { 'name': "Journal Entry base import", - 'version': '10.0.1.0.0', + 'version': '10.0.1.1.0', 'author': "Akretion,Camptocamp,Odoo Community Association (OCA)", 'category': 'Finance', 'depends': ['account'], diff --git a/account_move_base_import/models/account_journal.py b/account_move_base_import/models/account_journal.py index 4053a5a5..5fe8b2aa 100644 --- a/account_move_base_import/models/account_journal.py +++ b/account_move_base_import/models/account_journal.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # © 2011-2016 Akretion -# © 2011-2016 Camptocamp SA +# © 2011-2019 Camptocamp SA # © 2013 Savoir-faire Linux # © 2014 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) @@ -196,6 +196,20 @@ class AccountJournal(models.Model): 'account_id': commission_account_id, 'already_completed': True, } + if (self.currency_id and + self.currency_id != self.company_id.currency_id): + # the commission we are reading is in the currency of the + # journal: use the amount in the amount_currency field, and + # set credit / debit to the value in company currency at + # the date of the move. + currency = self.currency_id.with_context(date=move.date) + company_currency = self.company_id.currency_id + comm_values['amount_currency'] = comm_values['debit'] + comm_values['debit'] = currency.compute( + comm_values['debit'], + company_currency + ) + comm_values['currency_id'] = currency.id move_line_obj.with_context( check_move_validity=False ).create(comm_values) @@ -231,6 +245,19 @@ class AccountJournal(models.Model): if not values.get('account_id', False): values['account_id'] = self.receivable_account_id.id account = self.env['account.account'].browse(values['account_id']) + if (self.currency_id and + self.currency_id != self.company_id.currency_id): + # the debit and credit we are reading are in the currency of the + # journal: use the amount in the amount_currency field, and set + # credit / debit to the value in company currency at the date of + # the move. + currency = self.currency_id.with_context(date=move.date) + company_currency = self.company_id.currency_id + values['amount_currency'] = values['debit'] - values['credit'] + values['debit'] = currency.compute(values['debit'], + company_currency) + values['credit'] = currency.compute(values['credit'], + company_currency) if account.reconcile: values['amount_residual'] = values['debit'] - values['credit'] else: