Odoo Help

Anil R. Kesariya (AKE)
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
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
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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)


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