Odoo Help


Smart Button: HOw to add a domain to view the employee informations from its payslip?

Drees Far
on 8/3/16, 10:07 AM 561 views

Hello everybody!!!

Can anyone help me know how to specify the domain in the action of a smart button when we want to view the employee informations from its payslip?

Thanks a lot in advane.

Best Regards.

Jainesh Shah
On 1/19/18, 6:54 AM

Hi Dress Far,

Create a smart button in your view file, you can refer the below code:


<div class="oe_button_box">
      <button  class="oe_stat_button" style="margin-left:150px;" 
name="%(smart_button)d" type="action" icon="fa-files-o">
             <field string="Smart Button" name="rec_count" 
widget="statinfo" />
-> Will count the records on smart button.
rec_count = fields.Integer('Count', compute='count_func')
def count_func(self):
     for rec in self:
           cnt = self.env['model.model'].search_count([('object_id', 
'=', rec.id)])
           rec.rec_count = cnt
-> create an action in the model view file where you want to pass domain.
 <record id="smart_button" model="ir.actions.act_window">
        <field name="res_model">model.model</field>
        <field name="name">Model Name</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="domain">[('object_id', 'in', [object_id])]</field> 
#object id is M2O field.
        <field name="context">{'object_id':active_id}</field>
    <record id="ir_economic_plan_open" model="ir.values">
        <field eval="'tree_but_open'" name="key2"/>
        <field eval="'model.model'" name="model"/>
        <field name="name">Model Name</field>
        <field eval="'ir.actions.act_window,'+str(smart_button)" 

The above code will fetch the records of a particular id.

You can apply your model names here.

Hope this will help you.


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/3/16, 10:07 AM
Seen: 561 times
Last updated: 1/19/18, 6:54 AM