Odoo Help


search_default does not work?..

Andrius Laukavičius
on 8/21/14, 3:27 AM 1,501 views

I created button in partner form to show another models relation with it. It is same button like Opportunities, Meetings, Sales button at partners form showing all its Opportunities, Meetings, Sales etc.

Code looks like this:


        <record id="action_calendar_service" model="ir.actions.act_window">
            <field name="name">Services</field>
            <field name="res_model">calendar.service</field>
            <field name="view_mode">tree,calendar,form</field>
            <field name="view_id" ref="view_calendar_service_tree"/>
            <field name="search_view_id" ref="view_calendar_service_search"/>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to create new service.

inherited view:

        <record id="view_partners_form_service1" model="ir.ui.view">
            <field name="name">view.res.partner.form.crm.inherited1</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="crm.view_partners_form_crm1"/>
            <field eval="18" name="priority"/>
            <field name="arch" type="xml">
                    <button name="schedule_meeting" position="after">
                            class="oe_inline oe_stat_button"
                            attrs="{'invisible': [('customer', '=', False)]}"
                            context="{'search_default_partner_id': active_id}">
                            <field name="service_count" string="Services" widget="statinfo"/>

code in res.partner model:


class res_partner(models.Model):
    _inherit = 'res.partner'

    service_ids = fields.One2many('calendar.service', 'partner_id', 'Calendar Services')
    service_count = fields.Integer('Services', compute='_count_services')

    def _count_services(self):
        self.service_count = len(self.service_ids)

So everything works, except it always opens all 'calendar.service' records without filtering with 'partner_id' (the one that button was pressed from). Is there something I miss?

If I change action id in name attribute for example to opportunity action. Then search_default works and filters it. But if I use it with my view, it does not work for some reason

NOD Baltic, UAB, Andrius Laukavičius
on 9/18/14, 9:13 AM
Andrius Laukavičius
On 9/18/14, 9:34 AM

Finally found what was missing. I needed to add this line:

`<field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/>`

In my model search view. Without that it does not use search_default filter.

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

2 follower(s)


Asked: 8/21/14, 3:27 AM
Seen: 1501 times
Last updated: 3/16/15, 8:10 AM