0
votes

I have a 3 char fields and 1 many2many field. Below is code

brand = fields.char ('Brand')

lang = fields.char ('Language')

ref = fields.char ('Reference')

product_ids = fields.Many2many ('product.product', Products')

How can i hide fields based on many2many multiple selection? Example if product A selected selected then BRAND should be visible and when product B selected LANG should be visible, when Product C selected then REF should be visible vice versa.

There can be multiple selection like product A and B selected together then BRAND & LANG both visible.

Please note I dont want to use boolean fields for hiding char fields

2
I think the only solution is make 3 boolean compute field depends on fields product_ids. Then set attrs invisible base on these compute fields - Artiel
What if there are 25 fields? Making boolean for each will unessary increase table schema - Shashank Verma
If you not store these boolean fields, not thing will be increased in your table. But it only make sense on form or some kind of single view, otherwise it would be terrible performance when read data. - Artiel
@Artiel: Store=False. Perfect solution. Thanks.It resolved my query. - Shashank Verma

2 Answers

0
votes

You can add invisible attribute to Char fields if any value is in Many2many it will make field invisible. you can refer this link similar question.

0
votes

Solution suggested by @Artiel works for me. Make multiple boolean fields & keep store =False. This will do the job without increasing table schema.