Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16][account_reconcile_oca] Foreign currency bank journal issue when currency rate changes #779

Open
florian-dacosta opened this issue Jan 15, 2025 · 1 comment
Labels

Comments

@florian-dacosta
Copy link
Contributor

There is a bug with foreign currency statement lines when writing the partner on the liquidity line, explanation and how to reproduce :

  1. Install account_reconcile_oca
    At this stage with a demo database, the company currency is USD and there is just an old rate on EURO currency to convert it to USD.

  2. Create a bank journal with EURO currency

  3. Create a statement line in this EURO bank journal with a 1000 euros amount and go to the reconcile UI.

Image

  1. Go to the EURO currency and add a rate the the date of the statement line (today's date if you did not put a specific date)
    Put 1.1 in the field "USD per unit"

  2. Go back on the reconcile UI, click on the liquidity line and add a partner.
    Then, you have an inconsistency between the accounting entries (account.move.line), where the debit and credit were updated with the current up to date rate, and the lines in the reconcile UI are still with the old rate.

Image

Image

This happen because the write of the partner on the bank statement line triggers a synchronisation to the accounting entries with the default vals of the related accounting entry : https://github.com/OCA/OCB/blob/16.0/addons/account/models/account_bank_statement_line.py#L824
But there are not recompute of the statement line reconcile data.

Then, of course, if you try to reconcile some entries, the validation will fail, etc...

I am not sure what is the best way to fix this.I guess the liquidity lines should be updated in the reconcile data, after the partner update here https://github.com/OCA/account-reconcile/blob/16.0/account_reconcile_oca/models/account_bank_statement_line.py#L507 and the also recompute the suspense line. Or maybe clean all the reconcile data but the user could have started to do some stuff already...
Also, updating other fields of the statement line (like payment ref for instance) would also cause the same issue.

Any idea on the best way to do it ?

@etobella
@pedrobaeza you may also be interested since I saw you merged the PR with the multi-currency fixes...

@victoralmau
Copy link
Member

Reviewing very carefully the problem actually exists, but it is “only” with UI, if we execute the write() method the data is re-defined correctly, and although I have tried to make a test to verify this use case it is quite complex.

If we set a partner (or making another change in another field) some data can be changed, for example debit/credit and precisely in that case that change is not “transferred” to the reconcile_data_info field https://github.com/OCA/account-reconcile/blob/95b38bf186e09ced93bab14af7b1b74f505a864e/account_reconcile_oca/models/account_bank_statement_line.py#L465C9-L465C40 What is the right solution in this case? Honestly I'm not sure, in my opinion you should remove the onchanges and make calls to the write method in UI but that would involve many changes.

victoralmau added a commit to Tecnativa/account-reconcile that referenced this issue Jan 20, 2025
…onization to avoid side effects

We need to define skip_account_move_synchronization in the context to avoid that when writing
the bank statement line, some values can be updated in the account.move.line making the information
inconsistent.

Related to OCA#779
florian-dacosta added a commit to akretion/account-reconcile that referenced this issue Jan 20, 2025
…in amounts with the accounting entries

It may happen in case of changes on statement line that trigger a synchronization with the accounting entries. (see OCA#779 as an example but could happen just changing the amount on the statement line for instance)
florian-dacosta added a commit to akretion/account-reconcile that referenced this issue Jan 20, 2025
…in amounts with the accounting entries

It may happen in case of changes on statement line that trigger a synchronization with the accounting entries. (see OCA#779 as an example but could happen just changing the amount on the statement line for instance)
victoralmau added a commit to Tecnativa/account-reconcile that referenced this issue Jan 21, 2025
…er_id without onchange or subsequent changes with the _synchronize_to_moves() method.

We do not define partner_id with the value of manual_partner_id to prevent _synchronize_to_moves()
from making changes to the account.move.line leaving unintended values and/or data.

Related to OCA#779

TT52634
victoralmau added a commit to Tecnativa/account-reconcile that referenced this issue Jan 21, 2025
…er_id without onchange or subsequent changes with the _synchronize_to_moves() method.

We do not define partner_id with the value of manual_partner_id to prevent _synchronize_to_moves()
from making changes to the account.move.line leaving unintended values and/or data.

Re-define the value of reconcile_data_info if the _synchronize_to_moves() method has changed
anything on the lines.

Related to OCA#779

TT52634
florian-dacosta pushed a commit to akretion/account-reconcile that referenced this issue Jan 21, 2025
…er_id without onchange or subsequent changes with the _synchronize_to_moves() method.

We do not define partner_id with the value of manual_partner_id to prevent _synchronize_to_moves()
from making changes to the account.move.line leaving unintended values and/or data.

Re-define the value of reconcile_data_info if the _synchronize_to_moves() method has changed
anything on the lines.

Related to OCA#779

TT52634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants