コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
1002 ビュー

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
22685
3
8月 25
3327
1
5月 25
3232
1
4月 25
4162
1
4月 25
5007