Skip to content
Snippets Groups Projects
  1. Sep 17, 2023
  2. Sep 03, 2023
  3. Aug 27, 2023
  4. Aug 20, 2023
  5. Aug 13, 2023
  6. Aug 06, 2023
  7. Jul 30, 2023
  8. Jul 23, 2023
  9. Jul 09, 2023
  10. Jul 02, 2023
  11. Jun 25, 2023
  12. Jun 18, 2023
  13. Jun 11, 2023
  14. Jun 04, 2023
  15. May 28, 2023
  16. May 07, 2023
  17. Apr 26, 2023
  18. Apr 16, 2023
  19. Apr 09, 2023
  20. Apr 06, 2023
    • william-andre's avatar
      [IMP] account: dashboard performances · 0a386932
      william-andre authored
      
      As the number of `account.move`, `account.move.line`,
      `account.bank.statement.line` and `account.journal` is growing, the
      accounting dashboard, which is the entry point of the app, gets slower
      and slower.
      
      There are multiple issues being addressed in this commit:
      * The data for each journal is computed journal by journal. This means
        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 needed[^1]:
        - `_get_journal_bank_account_balance`
        - `_get_journal_outstanding_payments_account_balance`
        - `_get_last_bank_statement`
        - `get_line_graph_datas`
        - `get_bar_graph_datas`
        - `get_journal_dashboard_datas`
      * The gap detection and the entries' count are computed fields
        (`has_sequence_holes` and `entries_count` respectively). We don't need
        to display/compute these fields for all types of journals, but since
        they were mentioned by using a `<field/>` node in the view, they were
        computed for all journals displayed. Instead of using the `<field/>`
        node, we are now setting the value in the `kanban_dashboard` field.
      * Documents in foreign currencies on journals in foreign currencies need
        to get the rate in order to be aggregated in the journal's currency.
        There are 3 cases:
        - Document in journal's currency
        - Company's currency is the same as the journal's
        - Document, company and journal have 3 different currencies
        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 `populate` database with:
      - 4 `res.company` (with accounting enabled)
      - 45 `account.journal`
      - 19k `account.move`
      - 140k `account.move.line`
      - 4k `account.bank.statement.line`
      - 4 `account.bank.statement`
      
                                  | Query count | Query time | Remaining time
      --------------------------- | ----------- | ---------- | --------------
      Before fix                  |         279 |     0.333s |         0.375s
      After fix (without update)  |          40 |     0.120s |         0.170s
      After fix (with update[^2]) |          38 |     0.100s |         0.170s
      
      Note 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.
      
      ________________________________________________________________________
      
      [^1]: the old functions have been kept for compatibility, new ones are
      suffixed by `_batched` and made private if it wasn't the case.
      [^2]: some optimization require the views and indexes to be updated
      
      closes odoo/odoo#103697
      
      Related: odoo/enterprise#33165
      Signed-off-by: default avatarQuentin De Paoli <qdp@odoo.com>
      0a386932
  21. Apr 02, 2023
  22. Mar 26, 2023
  23. Mar 20, 2023
  24. Mar 14, 2023
  25. Mar 12, 2023
  26. Mar 06, 2023
  27. Mar 05, 2023
  28. Feb 26, 2023
  29. Feb 23, 2023
  30. Feb 20, 2023
  31. Feb 13, 2023
  32. Feb 05, 2023
  33. Jan 29, 2023
  34. Jan 22, 2023
  35. Jan 15, 2023
  36. Jan 08, 2023
  37. Jan 01, 2023
  38. Dec 25, 2022
  39. Dec 19, 2022
  40. Dec 18, 2022
Loading