Odoo Help


How to used read_group method in new api ?

Jitendra Prajapati (jpr)
on 8/11/14, 2:04 AM 7,703 views

   I have used following code  but i get traceback : TypeError: read_group() got multiple values for keyword argument 'context

    def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
        """ Override read_group to always display all states. """
        if groupby and groupby[0] == "state":
            states = self.EVALUATION_STATE
            read_group_all_states = [{
                        '__context': {'group_by': groupby[1:]},
                        '__domain': domain + [('state', '=', state_value)],
                        'state': state_value,
                    } for state_value, state_name in states]
            read_group_res = super(hr_evaluation, self).read_group(domain, fields, groupby, offset, limit, orderby, lazy)
            result = []
            for state_value, state_name in states:
                res = filter(lambda x: x['state'] == state_value, read_group_res)
                if not res:
                    res = filter(lambda x: x['state'] == state_value, read_group_all_states)
            return result
            return super(hr_evaluation, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)


it works well with old api 


@prakash : This question related to new api not old api.

Jitendra Prajapati (jpr)
on 8/11/14, 3:15 AM

Is Version 8 ?.. In the latest version https://github.com/odoo/odoo/blob/master/addons/account/report/account_entries_report.py File read_group method is defined with the given below same parameters. Let me know if any issues.

on 8/11/14, 4:52 AM

i konw that but it's all about new api not versioning. u can check new api guideline: https://github.com/nbessi/odoo_new_api_guideline/blob/master/source/environment.rst

Jitendra Prajapati (jpr)
on 8/11/14, 5:11 AM

please see the link http://www.slideshare.net/openobject/odoo-from-v7-to-v8-the-new-api may be help you.

on 8/11/14, 5:22 AM
ilexius GmbH
On 10/12/15, 11:09 AM

In Odoo 9 with the new API I call it like you and it is working




| 5 4 7
Bikaner, India

OpenERP Developer at SunARC Technology

On 8/11/14, 2:26 AM

Try the below parameters in read_group method.

 def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False,lazy=True):
       # your code
       return super(hr_evaluation self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby,lazy)

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 8/11/14, 2:04 AM
Seen: 7703 times
Last updated: 3/18/16, 4:20 AM