콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
3114 화면

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 ?


아바타
취소