From 22cd82477252fcfdfbc5fcf916637f6118bc8d0d Mon Sep 17 00:00:00 2001 From: Thibault Libioulle Date: Thu, 2 Sep 2021 15:53:03 +0200 Subject: [PATCH] [FIX] account: fix invoice count Prior to this commit, the count distinct on move_id called in the read group was not used correctly. This commit uses the move_id:count_distinct result of the read_group, which represents the number of distinct invoices. See task-2469742 PR : #70527 task-2458135 --- addons/account/models/account_analytic_line.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_analytic_line.py b/addons/account/models/account_analytic_line.py index 92f19595a42..58395a38b38 100644 --- a/addons/account/models/account_analytic_line.py +++ b/addons/account/models/account_analytic_line.py @@ -38,7 +38,7 @@ class AccountAnalyticAccount(models.Model): ('analytic_account_id', 'in', self.ids) ] groups = self.env['account.move.line'].read_group(domain, ['move_id:count_distinct'], ['analytic_account_id']) - moves_count_mapping = dict((g['analytic_account_id'][0], g['analytic_account_id_count']) for g in groups) + moves_count_mapping = dict((g['analytic_account_id'][0], g['move_id']) for g in groups) for account in self: account.invoice_count = moves_count_mapping.get(account.id, 0) @@ -51,7 +51,7 @@ class AccountAnalyticAccount(models.Model): ('analytic_account_id', 'in', self.ids) ] groups = self.env['account.move.line'].read_group(domain, ['move_id:count_distinct'], ['analytic_account_id']) - moves_count_mapping = dict((g['analytic_account_id'][0], g['analytic_account_id_count']) for g in groups) + moves_count_mapping = dict((g['analytic_account_id'][0], g['move_id']) for g in groups) for account in self: account.vendor_bill_count = moves_count_mapping.get(account.id, 0)