Ir al contenido
Menú
Se marcó esta pregunta
6 Respuestas
25837 Vistas

   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 

 

Avatar
Descartar
Autor

@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.

Autor

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.

Mejor respuesta

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

Avatar
Descartar
Mejor respuesta

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)

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
3
may 20
7735
3
dic 23
19766
1
mar 15
8435
2
ene 20
15607
0
ene 17
11137