Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
1021 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Autor

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

Autor

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

Publicaciones relacionadas Respuestas Vistas Actividad
5
sept 25
22715
3
ago 25
3337
1
may 25
3248
1
abr 25
4174
1
abr 25
5008