Skip to content

Commit 441b82d

Browse files
committed
[IMP] account_financial_report: Don't store analytic_account_ids
On account.move.line, don't store here the analytic accounts as it can be bulky (especially the init on big database).
1 parent 25bc41a commit 441b82d

File tree

2 files changed

+1
-31
lines changed

2 files changed

+1
-31
lines changed

account_financial_report/models/account_move_line.py

+1-26
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,11 @@
11
# Copyright 2019 ACSONE SA/NV (<http://acsone.eu>)
22
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).-
3-
from odoo import api, fields, models
3+
from odoo import api, models
44

55

66
class AccountMoveLine(models.Model):
77
_inherit = "account.move.line"
88

9-
analytic_account_ids = fields.Many2many(
10-
"account.analytic.account", compute="_compute_analytic_account_ids", store=True
11-
)
12-
13-
@api.depends("analytic_distribution")
14-
def _compute_analytic_account_ids(self):
15-
for record in self:
16-
if not record.analytic_distribution:
17-
record.analytic_account_ids = False
18-
else:
19-
record.update(
20-
{
21-
"analytic_account_ids": [
22-
(
23-
6,
24-
0,
25-
self.env["account.analytic.account"]
26-
.browse([int(k) for k in record.analytic_distribution])
27-
.exists()
28-
.ids,
29-
)
30-
]
31-
}
32-
)
33-
349
def init(self):
3510
"""
3611
The join between accounts_partners subquery and account_move_line

account_financial_report/report/general_ledger.py

-5
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ def _get_initial_balance_data(
274274
base_domain += [("move_id.state", "=", "posted")]
275275
else:
276276
base_domain += [("move_id.state", "in", ["posted", "draft"])]
277-
if cost_center_ids:
278-
base_domain += [("analytic_account_ids", "in", cost_center_ids)]
279277
if extra_domain:
280278
base_domain += extra_domain
281279
gl_initial_acc = self._get_gl_initial_acc(
@@ -377,9 +375,6 @@ def _get_period_domain(
377375
domain += [("move_id.state", "=", "posted")]
378376
else:
379377
domain += [("move_id.state", "in", ["posted", "draft"])]
380-
381-
if cost_center_ids:
382-
domain += [("analytic_account_ids", "in", cost_center_ids)]
383378
return domain
384379

385380
def _initialize_data(self, foreign_currency):

0 commit comments

Comments
 (0)