How to Add Smart Buttons in Odoo 18
Overview
Smart buttons in Odoo are a valuable tool for improving user productivity by providing direct access to related records or enabling specific actions from a model’s form view. These buttons simplify navigation, helping users quickly retrieve relevant data and perform tasks without leaving the current view.
In this blog, we will walk you through the process of adding smart buttons in Odoo 18, showing you how to make your workflows more efficient and your user interface more intuitive.
Smart Buttons
Smart buttons are visual elements, typically shown as clickable links or buttons, located in the header of a form view. They offer users a quick overview of related records, such as the total number of sale orders or invoices associated with a customer or the tasks linked to a project. By clicking on these buttons, users are seamlessly directed to the relevant records, facilitating efficient data management and quick access to essential information.
Adding Smart Buttons and their data in form view
In order to add a smart button in the header inherit the view and find the xpath. Then add the button named ‘action_get_vehicles_record’ in the view .
Define the button action in the python side as follows:
This function will filter the view to display the vehicles associated with the partner. Now you will create a new smart button in the partner form that features a taxi icon.
Adding record count for Smart Buttons
To achieve this, extend the res.partner model with an additional field and a compute function:
Now After associating some vehicle drivers with the current partner in the Fleet module, clicking the smart button will present the relevant vehicle records.
Conclusion
By implementing these steps, you can seamlessly integrate smart buttons into your Odoo 18 application, improving user experience and optimizing workflow efficiency. Smart buttons offer a convenient way to navigate between related records, making data management faster and more intuitive while maintaining a clean and organized interface.