Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
6 Ответы
25880 Представления

   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)

Аватар
Отменить
Related Posts Ответы Просмотры Активность
3
мая 20
7771
3
дек. 23
19796
1
мар. 15
8463
2
янв. 20
15650
0
янв. 17
11177