Odoo Help


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

Fongoh Tayong
on 12/11/15, 7:42 AM 617 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

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

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: 617 times
Last updated: 12/11/15, 11:28 AM