Adding buttons to forms
Buttons are used in the 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="%(my_hostel.hostel_room_category_action)d" string="Open Hotel Room Category" />
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...