Odoo Help


Using attr attribute form/field (composite and, or)

Fongoh Tayong
on 12/11/15, 7:42 AM 527 views

Good day. 

I am relatively new to odoo. 

This is my idea,

- if draft and pending, btn1 is invisible

-if draft or pending, btn_1 is invisible.

My worry is how to put "and" and "or" in attr.

This is my model

status = fields.Selection(selection=[('draft', 'Creating New Reservation'), ('pending', 'Pending'),('checkedin','Checked In'),('checkedout', 'Checked Out'),('paid', 'Paid'),('cancelled', 'Cancelled')], string="Status of Reservation")

and my form button 

 <button name='btn1_method' string='btn1'  type='object' 
attrs=" {'invisible': [  ('status', '=', 'pending'), ('status', '=', 'draft')]}" />

<button name='btn2_method' string='btn2'  type='object'
attrs=" {'invisible': [  ('status', '=', 'pending'), ('status', '=', 'draft')]}" />

 Please, how do i use make use of and and or in this situation. 

Thanks in advanced.

Axel Mendoza
On 12/11/15, 11:28 AM

@Fongoh Tayong

Domains are a combination of tuples and operators '&' and '|' in a polish notation.

for 'and' is the same domain that you post because and is the default operator between domain tuples. It's the char & (&amp; for xml) and could be represented like this:

<button name='btn1_method' string='btn1'  type='object' 
attrs=" {'invisible': ['&amp;',('status', '=', 'pending'),('status', '=', 'draft')]}" />

for 'or' it uses the char '|' and you could do it like:

<button name='btn2_method' string='btn2'  type='object'
attrs=" {'invisible': ['|',('status', '=', 'pending'), ('status', '=', 'draft')]}" />

Solve it?

Axel Mendoza
on 12/22/15, 3:14 PM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 12/11/15, 7:42 AM
Seen: 527 times
Last updated: 12/11/15, 11:28 AM