Skip to Content
Menu
This question has been flagged
1 Reply
4687 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.

Avatar
Discard
Best Answer

@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')]}" />
Avatar
Discard

Solve it?