Skip to content

Commit

Permalink
[FIX] account: currency of reconci. suggestion
Browse files Browse the repository at this point in the history
When the currency used for a payment/internal transfert is not the same
as the company currency, the prices shown in the reconciliation
suggestions are computed using the company currency.

1) Enable multi-currency.
2) Setup two bank, one in USD, the other in EUR.
3) Leave the company currency to USD.
4) Create an invoice for a partner targeting the EUR bank and
   validate it.
5) Create a bank statement for the EUR bank amounting the **exact**
   value of the invoice for the **same** partner and reconcile it,
   this will create the payment behind the hood.
6) In the reconciliation the invoice appears as suggestion, if the
   currency symbol is correct, the amount is shown as USD.

opw-1937202

closes #30623

closes #31290
  • Loading branch information
Julien00859 committed Feb 26, 2019
1 parent 6530f12 commit 01405ca
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addons/account/models/reconciliation_widget.py
Expand Up @@ -135,11 +135,12 @@ def get_bank_statement_line_data(self, st_line_ids, excluded_ids=None):
else:
aml_ids = matching_amls[line.id]['aml_ids']
bank_statements_left += line.statement_id
target_currency = line.currency_id or line.journal_id.currency_id or line.journal_id.company_id.currency_id

amls = aml_ids and self.env['account.move.line'].browse(aml_ids)
line_vals = {
'st_line': self._get_statement_line(line),
'reconciliation_proposition': aml_ids and self._prepare_move_lines(amls) or [],
'reconciliation_proposition': aml_ids and self._prepare_move_lines(amls, target_currency=target_currency, target_date=line.date) or [],
'model_id': matching_amls[line.id].get('model') and matching_amls[line.id]['model'].id,
'write_off': matching_amls[line.id].get('status') == 'write_off',
}
Expand Down
27 changes: 27 additions & 0 deletions addons/account/tests/test_reconciliation_widget.py
@@ -1,6 +1,7 @@
import logging
import odoo.tests
import time
from odoo.addons.account.tests.test_reconciliation import TestReconciliation

_logger = logging.getLogger(__name__)

Expand All @@ -22,3 +23,29 @@ def test_01_admin_bank_statement_reconciliation(self):
self.phantom_js("/web#statement_ids=" + str(bank_stmt.id) + "&action=bank_statement_reconciliation_view",
"odoo.__DEBUG__.services['web_tour.tour'].run('bank_statement_reconciliation')",
"odoo.__DEBUG__.services['web_tour.tour'].tours.bank_statement_reconciliation.ready", login="admin")


@odoo.tests.tagged('post_install', '-at_install')
class TestReconciliationWidget(TestReconciliation):

This comment has been minimized.

Copy link
@smetl

smetl Apr 12, 2019

Contributor

@Julien00859 It's not a good idea to extend a class containing some tests because you force the TestSuite to execute them twice. In your case, the tests inside TestReconciliation are now executed 2 times in runbot :/

This comment has been minimized.

Copy link
@Julien00859

Julien00859 Apr 12, 2019

Author Member

The TestReconciliation contains a bunch of useful methods I would like to reuse in my test, what's about I move those methods into a mixin that I import in both TestReconciliation and TestReconciliationWidget ?

This comment has been minimized.

Copy link
@smetl

smetl Apr 12, 2019

Contributor

Don't change anything as I will refactor a lot of accounting tests very soon. This comment was only for information purpose ;)


def test_statement_suggestion_other_currency(self):
# company currency is EUR
# payment in USD
invoice = self.create_invoice(invoice_amount=50, currency_id=self.currency_usd_id)

# journal currency in USD
bank_stmt = self.acc_bank_stmt_model.create({
'journal_id': self.bank_journal_usd.id,
'date': time.strftime('%Y-07-15'),
'name': 'payment %s' % invoice.number,
})

bank_stmt_line = self.acc_bank_stmt_line_model.create({'name': 'payment',
'statement_id': bank_stmt.id,
'partner_id': self.partner_agrolait_id,
'amount': 50,
'date': time.strftime('%Y-07-15'),
})

result = self.env['account.reconciliation.widget'].get_bank_statement_line_data(bank_stmt_line.ids)
self.assertEqual(result['lines'][0]['reconciliation_proposition'][0]['amount_str'], '$ 50.00')

0 comments on commit 01405ca

Please sign in to comment.