[IMP] analytic: show all children accounts on plan

On the smart button where you can see the accounts of the plan,
we want to be able to see all accounts of subplans too.
We also change the order of the analytic accounts, by plan's complete name then name.

closes odoo/odoo#102717

X-original-commit: a1f886e7babd6283e01eed686e043aabe72d7dd9
Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
gawa-odoo
2022-10-08 06:20:12 +02:00
parent e331c38ee7
commit 6f707dc833
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ class AccountAnalyticAccount(models.Model):
_name = 'account.analytic.account'
_inherit = ['mail.thread']
_description = 'Analytic Account'
_order = 'code, name asc'
_order = 'plan_id, name asc'
_check_company_auto = True
_rec_names_search = ['name', 'code', 'partner_id']
+3 -2
View File
@@ -10,6 +10,7 @@ class AccountAnalyticPlan(models.Model):
_description = 'Analytic Plans'
_parent_store = True
_rec_name = 'complete_name'
_order = 'complete_name asc'
def _default_color(self):
return randint(1, 11)
@@ -97,7 +98,7 @@ class AccountAnalyticPlan(models.Model):
@api.depends('account_ids', 'children_ids')
def _compute_all_analytic_account_count(self):
for plan in self:
plan.all_account_count = len(plan.account_ids) + len(plan.children_ids.account_ids)
plan.all_account_count = self.env['account.analytic.account'].search_count([('plan_id', "child_of", plan.id)])
@api.depends('children_ids')
def _compute_children_count(self):
@@ -108,7 +109,7 @@ class AccountAnalyticPlan(models.Model):
result = {
"type": "ir.actions.act_window",
"res_model": "account.analytic.account",
"domain": [('id', 'in', self.account_ids.ids)],
"domain": [('plan_id', "child_of", self.id)],
"context": {'default_plan_id': self.id},
"name": _("Analytical Accounts"),
'view_mode': 'list,form',