Skip to Content
Menu
This question has been flagged
2 Replies
3097 Views

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
Discard
Author

Thanks🙏

I used ManytoOne to cteate a list

Best Answer

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
Discard
Best Answer

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
Discard