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

[IMP] account_reconcile_oca: Fix multicurrency journal management #668

Merged
merged 5 commits into from
Sep 4, 2024

Conversation

etobella
Copy link
Member

The main idea of this commit is to show the right currency amount

Should fix #656

@alexis-via

The main idea of this commit is to show the right currency amount
@etobella
Copy link
Member Author

@PaulGoubert

@pedrobaeza pedrobaeza added this to the 16.0 milestone Jun 18, 2024
Copy link

@PaulGoubert PaulGoubert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some issues persist and prevent proper matching. I discussed it with Alexis yesterday, and he will provide you with a detailed report of the problems we identified. Thank you again for your help.

@etobella
Copy link
Member Author

If we can have the exact detail, I can construct the test in order to avoid future regressions 😉

@etobella
Copy link
Member Author

@alexis-via @PaulGoubert Can you test again? I made a lot of changes in order to change all the stuff, but tests are passing and I added a new test with your case (I would like to add some more in order to ensure that all works fine)

@josselin-arica
Copy link

Hola, se esta presentando una observación ya que al momento de conciliar no esta trayendo el importe en moneda, les pasa lo mismo?

@etobella
Copy link
Member Author

@josselin-arica there is a lot of people in this conversation that doesn't speak Spanish. Only on the localization repos you could do that.

Can you send a complete flow of your problem in order to see what happens? You should test in the runbot in order to ensure that it is not a problem of your installation

@josselin-arica
Copy link

Hola estoy probando el módulo en una base nativa (test) y sucede lo siguiente:

  1. He creado un diario con moneda USD
  2. He creado una cuenta en USD para que actúe como contrapartida a la hora de conciliar.
  3. Al momento de conciliar en diario USD creado, y elegir esta cuenta me aparece un mensaje "La cuenta seleccionada en tu asiento diario obliga a proporcionar una moneda secundaria. Debes eliminar la moneda secundaria de la cuenta"
  4. Ese mensaje me aparece siempre que use USD, sin embargo en caso logre conciliar ya que es un mensaje espontaneo, cuando ingreso al asiento contable de la conciliación, en la columna importe en moneda (que esta oculta) no trae el importe.
    Les pasa lo mismo?

@etobella
Copy link
Member Author

@josselin-arica in english please. The first time I answered and explained that you should ask and comment in english.

@josselin-arica
Copy link

Hello, I am testing the module on a native basis (test) and the following happens:

I have created a journal with USD currency
I have created an account in USD to act as a counterparty when reconciling.
When I reconcile in the USD journal created, and choose this account, I get a message "The account selected in your journal entry requires you to provide a secondary currency. You must delete the secondary currency from the account"
This message appears whenever I use USD, however, if I manage to reconcile since it is a spontaneous message, when I enter the reconciliation accounting entry, in the currency amount column (which is hidden) it does not show the currency amount.

Does the same thing happen to you?

@etobella
Copy link
Member Author

Did you test this PR or the latest merged version? @josselin-arica

@etobella
Copy link
Member Author

etobella commented Jul 4, 2024

Well, I needed to do a lot of changes in order to make it work properly.

The main issues is that Odoo was already calculating the exchange rate and this was confusing (also, Odoo ignores the rate we set in order to compute it). I solved it by keeping the logic from Odoo

@legalsylvain @PaulGoubert

@PaulGoubert
Copy link

Well, I needed to do a lot of changes in order to make it work properly.

The main issues is that Odoo was already calculating the exchange rate and this was confusing (also, Odoo ignores the rate we set in order to compute it). I solved it by keeping the logic from Odoo

@legalsylvain @PaulGoubert

@alexis-via

@alexis-via
Copy link
Contributor

I tested the scenario described in my bug report and it now works well ! Thank you @etobella !

I continued with a similar multi-currency scenario and I found another problem. Here is the detailed scenario:

  1. I have a company with currency = EUR
  2. I create a bank journal in currency USD
  3. On the USD currency, I create 3 different rates:
  • D-2 (the day before yesterday): rate = 1.10 € for 1 USD
  • D-1 (yesterday) : rate = 1.15 € for 1 USD
  • D (today) : rate = 1.20 € for 1 USD
  1. I create a vendor bill for partner Ready Mat of 1000 $ dated D-2
  2. I create a vendor bill for partner Ready Mat of 1000 $ dated D-1
  3. I create a bank statement line of -2000$ in my USD bank journal for partner Ready Mat dated D. I link it to the 2 invoices. I get this:

bug42

The problem is that I still have the line in the Bank suspense account of 0,01 €.

@etobella
Copy link
Member Author

The same happens with EE
image

This probably comes from differences of decimals when transforming from USD to EUR and EUR to USD... IMO this case implies that the user needs to define the difference manually

@etobella
Copy link
Member Author

@alexis-via If you approve it, we can proceed with merge and I will port it to 17 😉

@pleirb
Copy link

pleirb commented Jul 21, 2024

Hello, how are you all!

Same situation as @alexis-vía, with notes in foreign currency trying to reconcile in a bank account also in foreign currency, apparently everything is going well:
imagen
But when validating the reconciliation something strange happens, look how the counterparts change:
imagen

On the other hand, if for some reason, the base currency amount differs like in this example:
imagen
When validating I receive this error:

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1632, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/opt/odoo/custom/src/odoo/odoo/service/model.py", line 133, in retrying
    result = func()
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1659, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1863, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "/opt/odoo/auto/addons/website/models/ir_http.py", line 237, in _dispatch
    response = super()._dispatch(endpoint)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
    result = endpoint(**request.params)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 716, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/opt/odoo/auto/addons/web/controllers/dataset.py", line 42, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/auto/addons/web/controllers/dataset.py", line 33, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 468, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 453, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 6609, in onchange
    record._onchange_eval(name, field_onchange[name], result)
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 6320, in _onchange_eval
    method_res = method(self)
  File "/opt/odoo/auto/addons/account_reconcile_oca/models/account_bank_statement_line.py", line 205, in _onchange_add_account_move_line_id
    reconcile_auxiliary_id, lines = self._get_reconcile_line(
  File "/opt/odoo/auto/addons/account_reconcile_oca/models/account_bank_statement_line.py", line 874, in _get_reconcile_line
    reconcile_auxiliary_id, rate = self._compute_exchange_rate(
  File "/opt/odoo/auto/addons/account_reconcile_oca/models/account_bank_statement_line.py", line 920, in _compute_exchange_rate
    "account_id": account.name_get()[0],
IndexError: list index out of range

The above server error caused the following client error:
null

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@pedrobaeza
Copy link
Member

Let's merge it.

/ocabot merge major

Please fw-port it to 17.

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-668-by-pedrobaeza-bump-major, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 1bf6d95 into OCA:16.0 Sep 4, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 586dc0d. Thanks a lot for contributing to OCA. ❤️

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

Successfully merging this pull request may close these issues.

[16.0] account_reconcile_oca: problem on bank account in foreign currency
8 participants