1
<field name="Tr"   attrs="{'readonly':['|',('week_end','=',False),('HSup_P1','!=',False),('HSup_P2','!=',False),('HSup_P3','!=',False),('HSup_P4','!=',False)]}"/>

What I want to do is to make this field readonly when week_end is False or HSup_P1, HSup_P2 , HSup_P3 or HSup_P4 are True.

ChesuCR
  • 9,352
  • 5
  • 51
  • 114
Borealis
  • 1,059
  • 2
  • 18
  • 37

1 Answers1

3

This should work:

<field name="Tr" attrs="{'readonly': ['|', '|', ('week_end', '=', False), ('HSup_P1', '!=', False), '|', '|', ('HSup_P2', '!=', False), ('HSup_P3', '!=', False), ('HSup_P4', '!=', False)]}"/>

Take a look at my answer in this post: I don“t understand Normal Polish Notation (NPN or PN). How to build a complex domain in Odoo?

I think it will help you in the future when you have to deal with domains and this Polish Notation.

So if you apply the method I suggest you in the link:

A => ('week_end', '=', False)
B => ('HSup_P1', '!=', False)
C => ('HSup_P2', '!=', False)
D => ('HSup_P3', '!=', False)
E => ('HSup_P4', '!=', False)

What you want:

Step 0. => A or B or C or D or E

Here you can group the letters as you want, since there aren't any priorities, so for example:

Step 1. => A or B or C or D or E
Step 2. => AB or C or D or E
Step 3. => AB or CD or E
Step 4. => AB or CDE

Now, we decompose the made groups, moving their operators to the left side:

Step 4. => or AB CDE
Step 3. => or AB or CD E
Step 2. => or AB or or C D E
Step 1. => or or A B or or C D E

Finally, replace the letters by their respective expressions and the operators too (or by |, and by &amp;), and you'll get the answer I wrote you above.

forvas
  • 9,801
  • 7
  • 62
  • 158