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

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


Odoo CMS - a big picture

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

           }

Odoo CMS - a big picture

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>

Odoo CMS - a big picture
Subscribe


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 - sales@kanakinfosystems.comor call us at +91-9818108884 for more details.

Get InTouch

For More Information on Odoo ERP Consulting Services