[IMP] add and fix the documentation on some helper methods in read_group. (orm.py)

bzr revid: ged@openerp.com-20140408082029-pmdzkbak0zjvs8jw
This commit is contained in:
Gery Debongnie 2014-04-08 10:20:29 +02:00
parent 6aa003f1ad
commit 568b8c7632
1 changed files with 9 additions and 5 deletions

View File

@ -2199,17 +2199,18 @@ class BaseModel(object):
to the query if order should be computed against m2o field. to the query if order should be computed against m2o field.
:param orderby: the orderby definition in the form "%(field)s %(order)s" :param orderby: the orderby definition in the form "%(field)s %(order)s"
:param aggregated_fields: list of aggregated fields in the query :param aggregated_fields: list of aggregated fields in the query
:param groupby: the current groupby field name :param annotated_groupbys: list of dictionaries returned by _read_group_process_groupby
:param qualified_field: the fully qualified SQL name for the grouped field These dictionaries contains the qualified name of each groupby
(fully qualified SQL name for the corresponding field),
and the (non raw) field name.
:param osv.Query query: the query under construction :param osv.Query query: the query under construction
:param groupby_type: the type of the grouped field
:return: (groupby_terms, orderby_terms) :return: (groupby_terms, orderby_terms)
""" """
orderby_terms = [] orderby_terms = []
groupby_terms = [gb['qualified_field'] for gb in annotated_groupbys] groupby_terms = [gb['qualified_field'] for gb in annotated_groupbys]
groupby_fields = [gb['groupby'] for gb in annotated_groupbys] groupby_fields = [gb['groupby'] for gb in annotated_groupbys]
if not orderby: if not orderby:
return groupby_terms, orderby_terms return groupby_terms, orderby_terms
self._check_qorder(orderby) self._check_qorder(orderby)
for order_part in orderby.split(','): for order_part in orderby.split(','):
@ -2234,6 +2235,10 @@ class BaseModel(object):
return groupby_terms, orderby_terms return groupby_terms, orderby_terms
def _read_group_process_groupby(self, gb, query, context): def _read_group_process_groupby(self, gb, query, context):
"""
Helper method to collect important information about groupbys: raw
field name, type, time informations, qualified name, ...
"""
split = gb.split(':') split = gb.split(':')
field_type = self._all_columns[split[0]].column._type field_type = self._all_columns[split[0]].column._type
gb_function = split[1] if len(split) == 2 else None gb_function = split[1] if len(split) == 2 else None
@ -2353,7 +2358,6 @@ class BaseModel(object):
:rtype: [{'field_name_1': value, ...] :rtype: [{'field_name_1': value, ...]
:raise AccessError: * if user has no read rights on the requested object :raise AccessError: * if user has no read rights on the requested object
* if user tries to bypass access rules for read on the requested object * if user tries to bypass access rules for read on the requested object
""" """
self.check_access_rights(cr, uid, 'read') self.check_access_rights(cr, uid, 'read')
query = self._where_calc(cr, uid, domain, context=context) query = self._where_calc(cr, uid, domain, context=context)