Help

1

How do I make a button invisible if field (m2m) is False?

Avatar
Paolo M

How do I make a field invisible by using attrs {invisible} on a computed many2many field in XML.

attachment_ids = fields.Many2many("ir.attachment", compute="_attachment_list")
@api.multi
def _attachment_list(self):
self.attachment_ids = self.env['ir.attachment'].search([('res_model','=','my.model'),('res_id','=',self.id)])

On my xml I have:

(button)
attrs="{'invisible': [('activity_vendor_id','=', False), ('attachment_ids', '=', False)]}"


I have tried [(6,False,[])] but return an error.





1 Comment
Avatar
Discard
Avatar
Sehrish
-

Hope these tips will help: https://old.reddit.com/r/learnodoo/

2 Answers
0
Avatar
Paolo M
Best Answer

I fixed using another Boolean field associated with the affected field.

Avatar
Discard
0

can you try

attrs="{'invisible': [('activity_vendor_id','=', False), ('attachment_ids', '=', [])]}"


1 Comment
Avatar
Discard
Avatar
Paolo M
-

Does not work