# HG changeset patch # User Etienne Ferriere <etienne.ferriere@xcg-consulting.fr> # Date 1623336995 -7200 # Thu Jun 10 16:56:35 2021 +0200 # Branch 11.0-tomerge # Node ID 82fbb8fb0aed6b0e732ebb0ac2650fce38154a85 # Parent b422df8b2dfe0c85ebff3039a9e03c89df2eabb3 Added a method able to return the technical names of all the analytic fields of a class. diff --git a/MetaAnalytic.py b/MetaAnalytic.py --- a/MetaAnalytic.py +++ b/MetaAnalytic.py @@ -141,6 +141,18 @@ @AddMethod(superclass) @api.model + def get_analytic_field_names(self): + + field_names = [] + analytic_osv = self.env["analytic.structure"] + for model_name, prefix, suffix in all_analytic: + for ordering in analytic_osv.get_dimensions_names(model_name): + field_names.append("%s%s_%s" % (prefix, ordering, suffix)) + + return field_names + + @AddMethod(superclass) + @api.model def fields_get(self, allfields=None, attributes=None): """Override this method to rename analytic fields.""" diff --git a/NEWS.rst b/NEWS.rst --- a/NEWS.rst +++ b/NEWS.rst @@ -12,6 +12,8 @@ - code_name - code_description - parent_column +Added a method able to return the technical names of all the analytic fields of +a class. .. _2.2: diff --git a/README.rst b/README.rst --- a/README.rst +++ b/README.rst @@ -101,6 +101,10 @@ .. _AnalyticFields: +This metaclass adds a method able to return the technical names of all the +analytic fields of the inheriting class: +.. get_analytic_field_names + Add analytic fields to a model ------------------------------