From 73019b135f2ef5836ba0649efbccca0e9a45627b Mon Sep 17 00:00:00 2001 From: asm Date: Thu, 7 Mar 2024 10:33:18 +0100 Subject: [PATCH] [IMP] analytic: Add a function to get the analytic accounts off of analytic_distribution dict, this improvment is to avoid the rewriting the same code all over whenever we wanna get the accounts. opw-3756270 closes odoo/odoo#156866 Related: odoo/enterprise#57159 Signed-off-by: Florian Gilbert (flg) --- addons/analytic/models/analytic_mixin.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/analytic/models/analytic_mixin.py b/addons/analytic/models/analytic_mixin.py index 13c63e286c6..939c6cd9ede 100644 --- a/addons/analytic/models/analytic_mixin.py +++ b/addons/analytic/models/analytic_mixin.py @@ -128,3 +128,8 @@ class AnalyticMixin(models.AbstractModel): ('analytic_distribution_search', leaf[1], leaf[2]) if len(leaf) == 3 and leaf[0] == 'analytic_distribution' and isinstance(leaf[2], (str, tuple, list)) else leaf for leaf in domain ] + + def _get_analytic_account_ids(self) -> list[int]: + """ Get the analytic account ids from the analytic_distribution dict """ + self.ensure_one() + return [int(account_id) for ids in self.analytic_distribution for account_id in ids.split(',')]