TypeError: get_context() takes 3 positional arguments but 4 were given

Hello people .
Thanks for the new release 6.0.

Today i started installing tryton version 6.0 in a new virtual environment , then i was about using Cookiecutter to create a new module on the new version 6.0 and i just copied the code (code work fine on 5.8) everything is good until printing the report .

the error :

    Traceback (most recent call last):
          File "/trytond/wsgi.py", line 117, in dispatch_request
            return endpoint(request, **request.view_args)
          File "/trytond/protocols/dispatcher.py", line 47, in rpc
            return methods.get(request.rpc_method, _dispatch)(
          File "/trytond/wsgi.py", line 84, in auth_required
            return wrapped(*args, **kwargs)
          File "/trytond/protocols/wrappers.py", line 156, in wrapper
            return func(request, pool, *args, **kwargs)
          File "/trytond/protocols/dispatcher.py", line 181, in _dispatch
            result = rpc.result(meth(*c_args, **c_kwargs))
          File "/trytond/report/report.py", line 193, in execute
            oext, content = cls._execute(
          File "/trytond/report/report.py", line 206, in _execute
            report_context = cls.get_context(records, header, data)
        TypeError: get_context() takes 3 positional arguments but 4 were given                     

the method i work with to print the report :

    class ClassAReport(Report):   
        def get_context(cls, records, header):
            pool = Pool()
            ClassA = pool.get('urgency.class_a')
            context = super().get_context(records, header)
            classa_id = Transaction().context.get('class_a')
            class_a = ClassA(classa_id) if classa_id else None
            context['class_a'] = class_a
            return context                          

Ps: this method work fine on version 5.8 , i do no why it didn’t on 6.0

The Report.get_context method has changed it requires now 4 arguments instead of 3. So you must adapt your code to support this new argument.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.