""
Home Blog How To Create Smart Button In Odoo
How To Create Smart Button In Odoo

How To Create Smart Button In Odoo

A convenient way to trigger specific actions, streamline processes and enhance the overall user experience- Smart Buttons in Odoo. We will be exploring a step-by-step process of creating smart buttons for your Odoo database. This will not only empower you to customize your Odoo system but also optimizes it. 

Let us delve into the world of smart buttons together and unlock new possibilities for your business.

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 records.

position_filled_count = fields.Integer(compute="_compute_applicant_count")
#compute method will compute the count in the smart button

def _compute_applicant_count(self):

                       for res in self:

                       total_len = len(self.env['job_applicant'].search([('job_type', '=', res.id)]))

                       res.position_filled_count = total_len

Steps to creating a Smart Button with example Code Segments

2)   Then, we will write the method in py file:

def button_applicant_backend(self):

           return {

           'name': ('Job Applicants'), #This is form name, which you can edit according to you

           'view_mode': 'tree,form', #Here we give view mode type

           'res_model': 'job_applicant', #Here we will provide model name for the form view

           'type': 'ir.actions.act_window', #This is action which is predefined

           'domain': [('job_type','=',self.id)] #Here we are call required field, with the help of "self" which invokes a record rule

           }

Steps to creating a Smart Button with example Code Segments

3)   Create a form view and tree view and create an action of the form view. While creating the form view, add the smart button in the form

//while creating a form view add the smart button under sheet:

            <div class="oe_button_box">

            <button class=" oe_stat_button" name="button_applicant_backend"

                        type="object" icon="fa-user">

                       <field name="position_filled_count" />

            </button>

             </div>

Steps to creating a Smart Button with example Code Segments

 Subscribe for Odoo tips, technical insights, and more!

Contact us if you have any queries regarding the same or want any Odoo customization, Custom Odoo Module, or Odoo Installation Services from Kanakinfosystems. We have a team of Professional Odoo Developers that provides the best support throughout the process. You can email us at - [email protected] for more details.

Get in touch wit​h us!

Protected by reCAPTCHA, Privacy Policy & Terms of Service apply.
Leave a Comment

Your email address will not be published.

Submit
Your comment is under review by our moderation team.