-
Notifications
You must be signed in to change notification settings - Fork 30.2k
[IMP] account: dashboard performance #103697
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
Conversation
430e56d to
7fc7b07
Compare
e580999 to
1378190
Compare
1378190 to
d329466
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit confused and I messed up. Or the contrary.
Multi currencies use case to check and discuss ☝️
| curr_cache = {} | ||
| sale_purchase_journals._fill_dashboard_data_count(dashboard_data, 'account.move', 'entries_count', []) | ||
| for journal in sale_purchase_journals: | ||
| currency = journal.currency_id or journal.company_id.currency_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that journal.currency_id doesn't have any sense here, although it appears (I check in Odoo 16) you can effectively set a secondary currency on a sale/purchase journal. 🙃
I don't think it has any interest, except maybe to default the secondary currency of invoices created in that journal, and reporting in this very dashboard... I saw it was like that before, but we should probably consider simplifying that, what do you think?
the proposed change doesn't alter the current behavior, so it's not a blocking point
d329466 to
a878af8
Compare
703f67e to
d6b1dcd
Compare
d6b1dcd to
5cc7ed5
Compare
|
@william-andre @qdp-odoo linked pull request(s) odoo/enterprise#33165 not ready. Linked PRs are not staged until all of them are ready. |
`res.currency` already has some utilitises like `round` or `compare_amounts` but until now we always needed to import `format_amount` from the tools in order to format. This commit unifies the API. Part-of: #103697
Due to performance issues, the computation of the balance in GL was changed (odoo#103697) Since it is computed in `_get_journal_dashboard_bank_running_balance` as the last statement balance (balance_end_real) + transactions (account.bank.statement.line since the last statement), we rename the label on the journal dashboard to "Running Balance". Also, fix the order clause of the "Last Statement" balance as it has a problem when there are 2 statements on the same day. OPW-3265511
Due to performance issues, the computation of the balance in GL was changed (#103697) Since it is computed in `_get_journal_dashboard_bank_running_balance` as the last statement balance (balance_end_real) + transactions (account.bank.statement.line since the last statement), we rename the label on the journal dashboard to "Running Balance". Also, fix the order clause of the "Last Statement" balance as it has a problem when there are 2 statements on the same day. OPW-3265511 closes #119514 Related: odoo/enterprise#40194 Signed-off-by: William André (wan) <wan@odoo.com>
Due to performance issues, the computation of the balance in GL was changed (odoo#103697) Since it is computed in `_get_journal_dashboard_bank_running_balance` as the last statement balance (balance_end_real) + transactions (account.bank.statement.line since the last statement), we rename the label on the journal dashboard to "Running Balance". Also, fix the order clause of the "Last Statement" balance as it has a problem when there are 2 statements on the same day. OPW-3265511 X-original-commit: 383f52a
Due to performance issues, the computation of the balance in GL was changed (odoo#103697) Since it is computed in `_get_journal_dashboard_bank_running_balance` as the last statement balance (balance_end_real) + transactions (account.bank.statement.line since the last statement), we rename the label on the journal dashboard to "Running Balance". Also, fix the order clause of the "Last Statement" balance as it has a problem when there are 2 statements on the same day. OPW-3265511 X-original-commit: 383f52a
Due to performance issues, the computation of the balance in GL was changed (odoo#103697) Since it is computed in `_get_journal_dashboard_bank_running_balance` as the last statement balance (balance_end_real) + transactions (account.bank.statement.line since the last statement), we rename the label on the journal dashboard to "Running Balance". Also, fix the order clause of the "Last Statement" balance as it has a problem when there are 2 statements on the same day. OPW-3265511 X-original-commit: 383f52a
Due to performance issues, the computation of the balance in GL was changed (#103697) Since it is computed in `_get_journal_dashboard_bank_running_balance` as the last statement balance (balance_end_real) + transactions (account.bank.statement.line since the last statement), we rename the label on the journal dashboard to "Running Balance". Also, fix the order clause of the "Last Statement" balance as it has a problem when there are 2 statements on the same day. OPW-3265511 closes #119740 X-original-commit: 383f52a Related: odoo/enterprise#40316 Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Ayob Habib (ayh) <ayh@odoo.com>
Due to performance issues, the computation of the balance in GL was changed (#103697) Since it is computed in `_get_journal_dashboard_bank_running_balance` as the last statement balance (balance_end_real) + transactions (account.bank.statement.line since the last statement), we rename the label on the journal dashboard to "Running Balance". Also, fix the order clause of the "Last Statement" balance as it has a problem when there are 2 statements on the same day. OPW-3265511 closes #119752 X-original-commit: 383f52a Related: odoo/enterprise#40328 Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Ayob Habib (ayh) <ayh@odoo.com>
Due to performance issues, the computation of the balance in GL was changed (#103697) Since it is computed in `_get_journal_dashboard_bank_running_balance` as the last statement balance (balance_end_real) + transactions (account.bank.statement.line since the last statement), we rename the label on the journal dashboard to "Running Balance". Also, fix the order clause of the "Last Statement" balance as it has a problem when there are 2 statements on the same day. OPW-3265511 closes #119764 X-original-commit: 383f52a Related: odoo/enterprise#40334 Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Ayob Habib (ayh) <ayh@odoo.com>

As the number of
account.move,account.move.line,account.bank.statement.lineandaccount.journalis growing, theaccounting dashboard, which is the entry point of the app, gets slower
and slower.
There are multiple issues being addressed in this commit:
that the number of queries run increases linearly with the number of
journals. While the boilerplate around running multiple queries is
negligible compared to the running time of the queries in this case,
some queries take as much time to run for one journal or for many.
To improve this, all the queries are now batched. This has been done
by refactoring the code; all these functions are now called on as many
records as needed1:
_get_journal_bank_account_balance_get_journal_outstanding_payments_account_balance_get_last_bank_statementget_line_graph_datasget_bar_graph_datasget_journal_dashboard_datas(
has_sequence_holesandentries_countrespectively). We don't needto display/compute these fields for all types of journals, but since
they were mentioned by using a
<field/>node in the view, they werecomputed for all journals displayed. Instead of using the
<field/>node, we are now setting the value in the
kanban_dashboardfield.to get the rate in order to be aggregated in the journal's currency.
There are 3 cases:
Before this commit, the second case will still fetch the daily rate
for the document in order to do the conversion, but we actually
already know the conversion; it is stored on the document.
Benchmark
On a
populatedatabase with:res.company(with accounting enabled)account.journalaccount.moveaccount.move.lineaccount.bank.statement.lineaccount.bank.statementNote that the currency conversion was disabled because the populate
database doesn't represent a realistic dataset regarding this. Disabling
it only improves the numbers before the fix.
Note
A lot of the time remaining comes from the aggregation of
draft/unpaid invoices with the correct rate done in python instead of in
SQL. This commit doesn't change the behavior but this could be rethought
from a function point of view.
Footnotes
the old functions have been kept for compatibility, new ones are
suffixed by
_batchedand made private if it wasn't the case. ↩some optimization require the views and indexes to be updated ↩