Odoo Help


Button for tree veiw

on 3/7/14, 5:04 AM 1,537 views


Can I assign alternate button in tree view? For example: I want button1 if state is draft, and button2 for state confirm.

Is there any possibility to achieve this ? http://awesomescreenshot.com/09b2gg7h09


Anil R. Kesariya (Jupical Technologies)

--Anil R. Kesariya (Jupical Technologies)--
| 7 6 8
Rajkot, India
--Anil R. Kesariya (Jupical Technologies)--

Odoo Techno Functional Expert

* Engaged with odoo since May - 2012.

* Customise existing module or develop new module base on customer requirement.

* Played key developer role in many past and running projects.

* Expert in requirement gathering of business and transforming requirement into odoo platform.

* Major expertise in core modules, database, report development and theme development.

* Integration expert.

Linkedin  : https://in.linkedin.com/in/anil-kesariya-97b20a66

Anil R. Kesariya (Jupical Technologies)
On 2/3/15, 5:00 AM

Hello Nehal,

Take one selection field for changing the status of your record if haven't take.

For Eg : you have one state field on your model : state : fields.selection([('draft','Draft'),('progress','Progress'),('confirm','Confirm')], "Status")

Simply use the states property of button.

<button name="your_method" type="object" states="draft" string="Apply"/>

<button name="your_method" type="object" states='progress' string="Approved"/>

These button will only appear when your current record will be on that perticuler state.

When you call any method from button update the status of record so your button will be appear only on specific state.

These is how you can achive the feature.

Alternate Solution :

User Attrs property , you can hide your button based on such condition.

Hope this will help you.








René Schuster

--René Schuster--
| 5 6 8
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster
On 3/7/14, 5:36 AM

Use the states attribute inside the button tag:

<button name="your_action_id1" string="Button 1" type="action/object" states="draft"/> <button name="your_action_id2" string="Button 2" type="action/object" states="confirm"/>

The button name is the action to perfom. Depending on the type this can either be a ir_action defined in your xml ("action"), or a python function (type="object")

Note: the states attributes value can also be a comma seperated list of states



If your button executes python code: Use one button and differ the action inside the code depending on the state or a button context.


Also applied this. Same result as above.

on 3/7/14, 5:42 AM

Gopakumar N G

--Gopakumar N G--
| 5 4 7
Cochin, India
--Gopakumar N G--

Project Lead at Bizweaver Technologies Pvt. Ltd.

Gopakumar N G
On 3/7/14, 5:15 AM

You can use the attrs, for example attrs="{'invisible' : [('state', '!=', 'draft')]}" will hide the button when state is draft.

I have already applied attrs. But in this case the space is allocated for both while I want the same space allocated for both. I mean to say 2 diff column is used. See the screenshot: http://awesomescreenshot.com/09b2gg7h09

on 3/7/14, 5:23 AM

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

0 follower(s)


Asked: 3/7/14, 5:04 AM
Seen: 1537 times
Last updated: 3/16/15, 8:10 AM