Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
1003 Переглядів

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

Related Posts Відповіді Переглядів Дія
5
вер. 25
22685
3
серп. 25
3327
1
трав. 25
3232
1
квіт. 25
4162
1
квіт. 25
5007