Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
2 Antworten
3102 Ansichten

Has odoo any field that be like python list?


For example for my model i need to have a field that is a list of integers

Then for a record i can modify it if i want

Or i can append some object to it and so on.

Avatar
Verwerfen
Autor

Thanks🙏

I used ManytoOne to cteate a list

Beste Antwort

Hello,

I don't quite understand your use case, but here are two links where you can find information about the fields available in Odoo:

https://www.odoo.com/documentation/16.0/developer/reference/backend/orm.html#fields

https://www.odoo.com/documentation/16.0/applications/productivity/studio/fields.html#fields-and-widgets

I hope it helps you.
Regards

Avatar
Verwerfen
Beste Antwort

Hi,

The only way I found is to :

  • define a field of type Text or Char
  • put in it the json text of the list of integers. It can be obtained by ','.join(map(str, your_int_list)) (I use also for loops : ','.join([str(x) for x in yout_int_list])

To read your field you must do : my_list_of_int = map(int,  myfield.split(',')) if myfield else [] (or, with for loop : [int(x) for x in myfield.split(',')] if myfield else [] )

A little bit painfull but not so tricky. Does anybody has a better idea ?


Avatar
Verwerfen