El jue 25/06/2015, 16:31, <[email protected]> escribió:

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





 Is it possible that you changed your M2O by a O2M without updating your
database afterwards? (trytond -u yourmodulename -d yourdatabasename)

In cases like this it is usually better to provide the code where you
define the field.

Cheers

Reply via email to