2015-06-25 18:20 GMT+02:00 <[email protected]>: > > > Am Donnerstag, 25. Juni 2015 08:16:42 UTC+2 schrieb Jesús Martín Jiménez: >> >> Hi, >> >> >> 2015-06-24 23:56 GMT+02:00 <[email protected]>: >>> >>> Hello, >>> >>> is it possible to get the values of the records of a Many2One field? >>> I tried to iterate but this didn't work (TypeError: 'Many2One' object is >>> not iterable) >> >> >> This is because M2O field is a single record and in order to iterate you >> need a collection of fields. With O2M or M2M would work. >> >> -- >> >> Jesús Martín >> >> Zikzakmedia SL >> C/ de Sant Jaume, 9, baixos, 2ª >> 08720 Vilafranca del Penedès >> ☏ 93 890 21 08 > > > > I get the same Error with a One2Many field: > > Traceback (most recent call last): > File "/trytond/protocols/jsonrpc.py", line 162, in _marshaled_dispatch > response['result'] = dispatch_method(method, params) > File "/trytond/protocols/jsonrpc.py", line 191, in _dispatch > res = dispatch(*args) > File "/trytond/protocols/dispatcher.py", line 158, in dispatch > result = rpc.result(meth(*c_args, **c_kwargs)) > File "/trytond/model/modelview.py", line 620, in wrapper > return func(cls, *args, **kwargs) > File "/trytond/modules/hshn/hshn.py", line 156, in dislike_btn > for r in cls.xxx: > TypeError: 'One2Many' object is not iterable >
It must be an object, not a "cls" in order to be able to browse it. If you paste the code we could help you. BTW, you should use "." in order to get the value of a Many2One field, instead of trying to iterate over it. -- Albert Cervera i Areny Tel. 93 553 18 03 @albertnan www.NaN-tic.com
