Skip to Content
Menu
This question has been flagged
2 Replies
18920 Views

I know  the basic of the read_group() that it accept three required arguments domain, fields and group by and some other optional arguments like limit, lazy, offset etc but i can't figure out why we use and where to check it's result.

thanks in advance.

Avatar
Discard
Best Answer

Hi,
The below explanation will help you.

  • read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True

    """You Get the list of records in list view grouped by the given ``groupby`` fields. :param list domain: :ref:`A search domain <reference/orm/domains>`. Use an empty list to match all records. :param list fields: list of fields present in the list view specified on the object. Each element is either 'field' (field name, using the default aggregation), or 'field:agg' (aggregate field with aggregation function 'agg'), or 'name:agg(field)' (aggregate field with 'agg' and return it as 'name'). The possible aggregation functions are the ones provided by PostgreSQL (https://www.postgresql.org/docs/current/static/functions-aggregate.html) and 'count_distinct', with the expected meaning. :param list groupby: list of groupby descriptions by which the records will be grouped. A groupby description is either a field (then it will be grouped by that field) or a string 'field:groupby_function'. Right now, the only functions supported are 'day', 'week', 'month', 'quarter' or 'year', and they only make sense for date/datetime fields. :param int offset: optional number of records to skip :param int limit: optional max number of records to return :param str orderby: optional ``order by`` specification, for overriding the natural sort ordering of the groups, see also :py:meth:`~osv.osv.osv.search` (supported only for many2one fields currently) :param bool lazy: if true, the results are only grouped by the first groupby and the remaining groupbys are put in the __context key. If false, all the groupbys are done in one call. :return: list of dictionaries(one dictionary for each record) containing: * the values of fields grouped by the fields in ``groupby`` argument * __domain: list of tuples specifying the search criteria * __context: dictionary with argument like ``groupby`` :rtype: [{'field_name_1': value, ...] :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 """


Thanks & Regards


Avatar
Discard

A default aggregation function is mentioned in the code comment. What is that?

Author Best Answer

sunny sheth thanks ,,,,

Avatar
Discard

Welcome,

Can you upvote / Positive Vote to my Answer?

Author

i am not able to up vote it shows some message whenever i tap to upvote.