1

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.

kpg
  • 7,644
  • 6
  • 34
  • 67
  • 1
    `&` is a special character in XMLs so you have to escape it. If you want to use `&` in Odoo's search domains in XML files just escape it by `&`. You can find a lot of examples in Odoo's code. But you don't need it for this case, because both your domains above are literally the same, because the logical AND operation is the default operation for search criterias. So you can leave it out. The first answer should be correct for your case, use OR instead. – CZoellner Jan 06 '23 at 16:08

1 Answers1

1

You can do that using or as below:

 attrs="{'invisible': ['|',('status', '!=', 'validated'),('api_result', '!=', 'Valid')]}"
Waleed Mohsen
  • 965
  • 6
  • 8