Studio Book V17: Adding a New Button

Let's incorporate buttons to execute specific actions using the Studio module. The process of creating a new button differs from other Studio features as it involves some XML coding. Firstly, enable the debug mode by accessing it through the general settings or by adding the term ?debug=1 in the URL after the “web”, as illustrated below:

odoo-studio

With the debug mode enabled, the next step involves creating a server action to execute a specific function when the new button is clicked.

Navigate to "Server Actions" under the Technical menu in Settings. Note that this menu is visible only when the developer mode is activated.

odoo-studio

Click the 'New' button to initiate the creation of a new Server Action, and proceed to fill in the necessary fields as prompted.

odoo-studio

Fields on the form:

  • Action Name- Assign a name that succinctly identifies the purpose of your action.
  • TypeType of Server action.
  1. Update Record- If your intention is to update a record in the corresponding view, such as setting a field's value, choose this action. Subsequently, you'll need to specify the particular field for the update.
  2. Create Activity- Opt for this option if you intend to add an activity upon clicking the button.
  3. Send Email Select this action if you wish to send an email with the button click. Subsequently, you'll need to specify the Email Template and Send Email As to be used for this action.
  4. Send SMS Utilize this option if you aim to send an SMS upon clicking the button. Following this, you'll need to specify the SMS template and Send SMS As for this action.
  5. Add Followers Opt for this action if you intend to add followers to the selected record. Subsequently, you'll need to include the followers in the "Followers to add" field.
  6. Remove Followers Opt for this action if you intend to remove followers from the selected record. Subsequently, you'll need to include the followers in the "Followers to remove" field.
  7. Create Record Choose this action if you intend to create a new record upon clicking the button. Following this, you'll need to specify the Record to Create, Name and the link Field.
  8. Execute Code Opt this if you wish to perform calculations or complex operations upon button click. Following this, you'll need to write the corresponding code to execute the desired operation.
  9. Send Webhook Notification If you want to trigger a POST request to an external system, also known as a webhook, choose the action that allows you to send an HTTP request. Specify the necessary details such as the URL of the external system's webhook endpoint, and any required fields to be sent in the request body.
  10. Execute Existing Actions Opt for this action if you aim to execute a set of child actions. Following this, you'll need to specify the child server actions that should be carried out as part of the parent action. This allows for the streamlined execution of multiple actions in a cohesive manner
  11. Model Select the model to which you want to add a button.
  12. Allowed Groups Specify the user groups that have the authority to execute the server action. Leave this field empty if you want to permit execution by any user, regardless of their group affiliation.
odoo-studio

Complete all the required fields, and subsequently, save the server action. You can identify the server action's ID in the URL, as demonstrated below.

odoo-studio

Copy the ID of the server action. Following that, proceed to the specific view where you wish to incorporate your button, such as the sales order form view, and access the studio.

There are two distinct approaches to incorporating buttons into the interface.

  1. Using XML code
  2. Within the studio screen, navigate to the "View" menu, and subsequently, select the "XML" tab for further customization, as depicted below.

    odoo-studio

The XML code for the chosen view is visible on the left side. Within the header tag, you can find the code corresponding to the buttons already present in that view.

odoo-studio

Define the new button within the

section, similar to the example provided below. Include the ID of the created server action as the name attribute for the button.

odoo-studio
odoo-studio

Upon completing the aforementioned steps, your button will be visible in the view.

odoo-studio

Clicking on it will trigger the execution of the defined server action as shown below.

odoo-studio
  1. Using ‘Add a button’
  2. Click ‘Add a button’ inside the Studio view of the Sale Order view.

    odoo-studio

    Next, assign a label to the button, specify the type of action, and designate the action to be executed.

    odoo-studio

The button has been included in the view, appearing as illustrated below.

odoo-studio

In conclusion, Studio Book V17 empowers users to effortlessly integrate customized buttons through XML coding, enhancing the execution of specific actions within the platform. This streamlined process adds versatility and functionality to tailored views.

whatsapp
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message