Adding action buttons

Forms can have buttons to perform actions. These buttons are able to run window actions such as opening another form or running Python functions defined in the model.

They can be placed anywhere inside a form, but for document-style forms, the recommended place for them is the <header> section.

For our application, we will add a button to clear a done task. This button will run the do_clear_done object method:

<header> 
  <button name="do_clear_done" type="object" 
          string="Clear Done" /> 
</header> 

The basic attributes of a button consist of the following:

  • string with the text to display on the button
  • type of action it performs
  • name  is the identifier for that action
  • class is an optional attribute to apply CSS styles, ...

Get Odoo 11 Development Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.