kpg
kpg

Reputation: 7966

Using invisible attribute with '&' in Odoo view

I am trying to make a button in an Odoo view invisible when two conditions are both met.I am able to make the field invisible when either of the conditions are met like this:

 attrs="{'invisible': [('status', '!=', 'validated'),('api_result', '!=', 'Valid')]}"

I want the button to be visible only when status == "validated" && api_result == "Valid" But when I try to introduce the "&" I get an error. There's a long traceback which I'm not attaching now because I assume there is something wrong with my syntax:

 attrs="{'invisible': ['&',('status', '!=', 'validated'),('api_result', '!=', 'Valid')]}"

I admit that I find the syntax 'challenging' and haven't been able to find any clear documentation, so I would appreciate a pointer.

Upvotes: 1

Views: 918

Answers (1)

Waleed Mohsen
Waleed Mohsen

Reputation: 1055

You can do that using or as below:

 attrs="{'invisible': ['|',('status', '!=', 'validated'),('api_result', '!=', 'Valid')]}"

Upvotes: 1

Related Questions