Odoo Help

1 Answer

Aktiv software

--Aktiv software--
| 5 3 7
Ahmedabad, 印度
--Aktiv software--

 Aktiv software

  • Skype : shah.jainesh

  • email : Sales@Aktivsoftware.com

Aktiv software
18-1-19 上午6:54

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.


Ask a Question
Keep Informed
1 follower(s)
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