Odoo Help

0

0
1 Answer
0
Avatar

Aktiv software

--Aktiv software--
4109
| 6 3 9
Ahmedabad, الهند
--Aktiv software--

 Aktiv software

  • Skype : shah.jainesh

  • email : Sales@Aktivsoftware.com

Aktiv software
19‏/1‏/2018 6:54 ص

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.

Ask a Question
Writer
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.

Register
Odoo Training Center

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

Test it now