From 553b774dc89ba812f9d4bcdc6c9326a9ee61b1df Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 9 Feb 2023 13:24:02 +0000 Subject: [PATCH 1/2] [FIX] account_financial_report: endless installation Installing the module in a DB with more than 50000 accounts and groups made the install stall. It turns out this method's implementation produced almost endless recursion. it was also depending on some fields that never were used. Now it depends on the parent path, so when one group is moved to another parent, its computed accounts are recomputed, and parents' too, recursively. Now, the method is much more performant, and the module gets installed in the same DB in 30s. @moduon MT-1900 Co-authored-by: Eduardo De Miguel --- account_financial_report/models/account_group.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/account_financial_report/models/account_group.py b/account_financial_report/models/account_group.py index 238dda22..43734c96 100644 --- a/account_financial_report/models/account_group.py +++ b/account_financial_report/models/account_group.py @@ -16,6 +16,7 @@ class AccountGroup(models.Model): ) compute_account_ids = fields.Many2many( "account.account", + recursive=True, compute="_compute_group_accounts", string="Compute accounts", store=True, @@ -58,16 +59,11 @@ class AccountGroup(models.Model): group.level = group.parent_id.level + 1 @api.depends( - "code_prefix_start", "account_ids", - "account_ids.code", - "group_child_ids", - "group_child_ids.account_ids.code", + "group_child_ids.compute_account_ids", ) def _compute_group_accounts(self): - account_obj = self.env["account.account"] - accounts = account_obj.search([]) - for group in self: - prefix = group.code_prefix_start if group.code_prefix_start else group.name - gr_acc = accounts.filtered(lambda a: a.code.startswith(prefix)).ids - group.compute_account_ids = [(6, 0, gr_acc)] + for one in self: + one.compute_account_ids = ( + one.account_ids | one.group_child_ids.compute_account_ids + ) From 6985b50809288c02a695a027622060dd17f35ae7 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 9 Feb 2023 13:27:23 +0000 Subject: [PATCH 2/2] [BUILD] copier update --- .copier-answers.yml | 3 ++- .github/workflows/pre-commit.yml | 2 +- .github/workflows/test.yml | 2 +- .pre-commit-config.yaml | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index 43664cb6..f19cb642 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,10 +1,11 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: v1.12.0 +_commit: v1.14.1 _src_path: gh:oca/oca-addons-repo-template ci: GitHub dependency_installation_mode: PIP generate_requirements_txt: true github_check_license: true +github_ci_extra_env: {} github_enable_codecov: true github_enable_makepot: true github_enable_stale_action: true diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index a2c9e249..23e6e58d 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -11,7 +11,7 @@ on: jobs: pre-commit: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a3c680f0..f1b2b9fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: fi done test: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 container: ${{ matrix.container }} name: ${{ matrix.name }} strategy: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 23d6e613..2d1a86ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -101,7 +101,7 @@ repos: - id: pyupgrade args: ["--keep-percent-format"] - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort name: isort except __init__.py