Skip to content

Button

Simple button

<button type="object" name="a_method" string="A simple button" />

Button with icon

<button type="object" name="a_method" string="A simple button"
icon="gtk-execute" />

Primary button

<button type="object" name="a_method" string="A simple button"
icon="gtk-execute" primary="1" />

Danger button

<button type="object" name="a_method" string="A simple button"
icon="gtk-execute" danger="1" />

Primary danger button

<button type="object" name="a_method" string="A simple button"
icon="gtk-execute" primary="1" danger="1" />

Confirm button

<button type="object" name="a_method" string="A simple button"
icon="gtk-execute" confirm="Are you sure?" />

Calling actions

There are three ways to call actions on the server, configured according to the type of the button and the name.

  • workflow: Calls a workflow type action. The name is the signal that will be called.

  • action: Calls an action type action (known as wizards) and in the name, we must put the XML identifier of the action. For example, with the action defined in the giscemisc_monitor module with identifier action_wizard_monitor_ping:

    <record id="action_wizard_monitor_ping" model="ir.actions.act_window">
    <field name="name">Ping</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">wizard.monitor.ping</field>
    <field name="view_type">form</field>
    <field name="view_mode">form</field>
    <field name="target">new</field>
    </record>
    <button string="Ping MOXA" type="action"
    name="%(giscemisc_monitor.action_wizard_monitor_ping)d" />
  • object: Calls an object type action. The name is the method that will be called. and as parameters, it will pass the object’s id and the context.

For example, to call the action_method method of the res.partner object:

<button string="Action method" type="object"
name="action_method" />

And the action_method method of the res.partner object:

def action_method(self, cursor, uid, ids, context=None):
if context is None:
context = {}
# Do something

API

PropertyDescriptionTypeDefaultVersion
typeType of buttonworkflow | action | object | cancelworkflow-
iconIcon for the button. See Iconsstring--
stringText for the buttonstring--
confirmMessage to ask for a confirmation from userstring--
primaryFormat as a primary button. Fill the button with primary color1 | 0--
dangerMark this button as danger color, can be used with primary to fill the background1 | 0--
nameAction to call. See Calling actionsstring--
contextContext to send to the serverdict--