Odoo Help


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.


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

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

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)


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