Saturday, 25 October 2014

Odoo/OpenERP : Call function on button

There are three ways to add functionality on button in OpenERP/Odoo:

1. Call function directly on button: You can directly call the function defined in model/class using type="object" attribute.


<button string="Check availability" name="check_username_availability" type="object" class="oe_highlight" />

In this case you have to define 'check_username_availablilty' function in model.

2. Using Workflow: Workflow is the most used functionality in OpenERP/Odoo to process flow of the activity. Default type of button is workflow i.e type="workflow".  Workflow itself is an vital topic so can't talk much about this here.

<button string="Accept" name="signal_accept" type="workflow" class="oe_highlight" />

3. Using action: You have to user type="action" if you want to call any action defined in the .xml file. For example if you want to open any wizard you can use following code snippet:

<button name="%(action_id)d" string="Button Label" type="action">

or you can replace %(action_id)d with action id from database.

Reference Links:

Thanks!!!!!!!!!! Enjoy Programming :)

1 comment:

  1. I tried all the 3 methods, but my function is not being called...


Thanks for your valuable comments.