Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how to use & and | in attrs

By
willie ho
on 7/6/15, 4:24 AM 557 views

i need to make a attrs to a button when ((a = true and state = done) or (a= false and state = available)

what should i put in the button to make it works?

i tried

<button name = "button_a" string ="Button A" attrs="{'invisible':[('&',('a','=',True),('state','=','done')),('&',('a','=',False),('state','=','available'))]}"/>

and it says there is error 

1

Temur

--Temur--
2896
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 7/6/15, 4:53 AM

actually you've two errors:

1. you can't use special character & in XML directly, you should write it with it's xml code (we discussed it here)

2. conditional statement is not a valid prefix notation statement, you should write the statement in the prefix notation (we discussed it here)

correct the two errors and you're done:

<button name = "button_a" string ="Button A" attrs="{'invisible':['|','&amp;',('a','=',True),('state','=','done'),'&amp;',('a','=',False),('state','=','available')]}"/> 
1

Anil R. Kesariya

--Anil R. Kesariya--
4321
| 6 5 8
Gandhinagar, India
--Anil R. Kesariya--
ERP Consultant

Key Skill
-
Technical & Functional Expert
Anil R. Kesariya
On 7/6/15, 4:50 AM

Hi

Here you go!

By default & Operator applied so no need to use & operator

<button name = "button_a" string ="Button A" attrs="{'invisible':['|', '&',('a','=',True),('state','=','done'),'&',('a','=',False),('state','=','available')]}"/> 

Hope, This will help you

Rgds,

Anil.

0

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 7/6/15, 5:04 AM

Use the Polish notation

About your question:

(A and B) or (C and D) 

should converted to the polish notation as

or and A B and C D

in your example:

['|','&',('a','=',True),('state','=','done'),'&',('a','=',False),('state','=','available')] 

in xml (see @Temur post)

['|','&amp;',('a','=',True),('state','=','done'),'&amp;',('a','=',False),('state','=','available')]

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/6/15, 4:24 AM
Seen: 557 times
Last updated: 7/7/15, 9:21 PM