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

I have a model (hospital.patient). The patient form has a page named 'Food' in which I have listed 25 food items as boolean fields (e.g.: bread, butter, egg, etc.).
My requirement is that the only selected boolean fields (True) should be displayed as tags in a separate field in the patient form view.
Please guide me on how I can achieve this. Your support shall be highly appreciated.

아바타
취소
베스트 답변

Hi,

If you need to show only the food items that have ticked the boolean field, then you can set the domain for the field which were you need to select the food tags

example: domain=([('foofd_field_boolean', '=', True)])

the above is just an example domain which takes on the food which are clicked, replace the field name with your correct field


Hope it helps

아바타
취소
작성자

Hello,
can you please elaborate? My code is as below
class FoodlItems(models.Model):
_name = "food.items"

cheese = fields.Boolean(string="चीज (Cheese)")
icecream = fields.Boolean(string="आइस क्रीम (Ice Cream)")

작성자

Sorry my message got posted before i could complete. Please ignore my previous message.
Hello,
can you please elaborate? My code is as below
class FoodlItems(models.Model):
_name = "food.items"

cheese = fields.Boolean(string="Cheese")
icecream = fields.Boolean(string="Ice Cream")
cake = fields.Boolean(string="Cake")

And i want a field which will display only True boolean fields

abc = fields.Char/Text/Many2many(string="Food Items")

Please guide me what field type 'abc' should be in the same model i.e. Char or Text or Many2many, etc.

Thanks

관련 게시물 답글 화면 활동
5
9월 25
22705
3
8월 25
3335
1
5월 25
3246
1
4월 25
4172
1
4월 25
5007