跳至内容
菜单
此问题已终结
6 回复
25885 查看

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

   @api.model
    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)
                result.append(res[0])
            return result
        else:
            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.

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.

编写者

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

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

最佳答案

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

形象
丢弃
最佳答案

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)

形象
丢弃
相关帖文 回复 查看 活动
3
5月 20
7778
3
12月 23
19797
1
3月 15
8463
2
1月 20
15654
0
1月 17
11179