Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
1020 Tampilan

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.

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Penulis

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)")

Penulis

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

Post Terkait Replies Tampilan Aktivitas
5
Sep 25
22715
3
Agu 25
3337
1
Mei 25
3248
1
Apr 25
4174
1
Apr 25
5008