i have a field exist in one2many relation table this field i choose it to be Many2Many field type with coding a function make me display the content of another field exist in another class in line2 on the table one2many : this is how i coded the function inside the class refer to the table one2many relation:
class "work.test" refer to the one2many relation table
class Test(DeactivableMixin, ModelSQL, ModelView, MultiValueMixin):
__name__ = 'work.test' ```
field1 = fields.Function(
fields.Many2Many('work.work', 'test', None, "Status"), 'get_state')
@classmethod
def get_state(cls,institutions, Name):
pool = Pool()
parametr_up = pool.get('process.operation')
res=[]
operation1 = Transaction().context.get('operation1')
institution = 0
for institution in institutions:
institutions = parametr_up.search([
('institution', '=', institution.id),
], limit=1)
if institutions and parametr_up.operation1 :
if institution = 2:
res[institution.id] = institutions[0].operation1.convention
else:
res[institution.id] = None
institution = +1
return res
```
What does NOT work:
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/model/modelsql.py", line 872, in read
row[fname] = getter_result[row['id']]
IndexError: list index out of range