Odoo Help

0

Button for tree veiw

xml
By
Nehal
on 3/7/14, 5:04 AM 1,035 views

Hi,

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

2

Anil R. Kesariya

--Anil R. Kesariya--
4543
| 6 5 8
Gandhinagar, India
--Anil R. Kesariya--
ERP Consultant

Key Skill
-
Technical & Functional Expert
Anil R. Kesariya
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.

 

Regards,

Anil.

 

 

 

0

René Schuster

--René Schuster--
1590
| 5 5 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

states="draft,state1"

EDIT:

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

Regards

Also applied this. Same result as above.

Nehal
on 3/7/14, 5:42 AM
0

Gopakumar N G

--Gopakumar N G--
1198
| 5 3 7
Cochin, India
--Gopakumar N G--

Senior Software Engineer at BroadTech IT Solutions 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

Nehal
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.

Register

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)

Stats

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