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.
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.
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
|Asked: 3/7/14, 5:04 AM|
|Seen: 847 times|
|Last updated: 3/16/15, 8:10 AM|