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.
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
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.
Hi Dress Far,
Create a smart button in your view file, you can refer the below code:
smart_button_view_file.xml
<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" />
      </button>
</div>
-> Will count the records on smart button.
rec_count = fields.Integer('Count', compute='count_func')
@api.model
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.
object_model_view.xml
 <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>
    <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)" 
name="value"/>
    </record>
The above code will fetch the records of a particular id.
You can apply your model names here.
Hope this will help you.
Thanks.
| 相關帖文 | 回覆 | 瀏覽次數 | 活動 | |
|---|---|---|---|---|
|  | 2 8月 16  | 7741 | ||
|  | 1 8月 16  | 8782 | ||
|  | 2 5月 21  | 7285 | ||
|  | 1 11月 24  | 3255 | ||
|  | 0 6月 21  | 3048 |