コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
3091 ビュー

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.

アバター
破棄
著作者

Thanks🙏

I used ManytoOne to cteate a list

最善の回答

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

アバター
破棄
最善の回答

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 ?


アバター
破棄