Adding buttons to forms
Buttons are used on form view to handle user actions. We added a button in the form view in the previous recipe, but there are quite a few different types of buttons that we can use. This recipe will add another button that will help the user to open another view. It will also put the following code in the recipe's header
element.
How to do it...
Add a button that refers to an action:
<button type="action" name="%(base.action_partner_category_form)d" string="Open partner categories" />
How it works...
The button's type
attribute determines the semantics of the other fields, so we'll first take a look at the possible values:
action
: This makes the button call an action as defined in their.actions.*
namespace. Thename
attribute needs to contain the action's database ID, which you can conveniently have Odoo look up with a Python-format string that contains the XML ID of the action...