How To Create Smart Button In Odoo
When creating smart buttons in Odoo you must tie together several aspects of Odoo development. Below are the basic steps to creating a smart button with example code segments.
1. Add required fields to the model so you can store your field.
2. Create a form view and tree view and create action of form view.
3. Then after that, your tree view and form view will be like this.
4. We’ll have to write a method in py file.
'name': _('Employee Form'), (This is form view name you can give any name)
'view_type': 'form', (This is view type means this is form or which type form view)
'view_mode': 'tree,form', (Here we give view mode which type created view)
'res_model': 'employee.training', (Here will be model name of form view)
'type': 'ir.actions.act_window', (This is act window which is predefined)
'domain': [('trainee_qualification'(this is field name), 'in', [self.id])],(Here we are calling field name with the help of self which is a record rule)
5. Now we will make a button as well as add button where we want to add this button.
<button class="oe_stat_button" name="button_employee" string="Employee Training" type="object" icon="fa-edit"/>
In the above code,
name = (Name of the function to be called, present in the .py file)
string = (Here, you can provide the name of the button to be printed in the UI)
icon = (This is icon name means which specifies the icon of your button if you need a customicon, you can check it here, "https://docs.huihoo.com/odoo/training/reference-material/odoo-icon-smart-buttons.pdf")
This button has added in employee form and my button name is employee training you can see given above image when we will click on this button then my employee training form and tree view will be open. which view we have made upside.
Contact us if you have any query regarding the same or want any Odoo customization, Custom Odoo Module, Odoo Installation Services from Kanakinfosystems. We have a team of Professional Odoo Developers that provide the best support throughout the entire process. You can Email us at - firstname.lastname@example.org or directly call us on +91-9818211679, 011-42143250 for more details.