Odoo Help


How to add custom module search to "Advanced Search" in existing Module?

Daniel Gaudreault
on 10/24/13, 2:54 PM 1,925 views

I am trying to figure out how to add the ability to add the custom module to the advanced filter so that we can search for customer that have a particular series of dongle associated with them.

Here is my res_parter.py

from osv import fields, osv   

class res_partner(osv.osv):
    """ Inherits partner and adds CRM information in the partner form """
    _inherit = 'res.partner'

    def _dongle_count(self, cr, uid, ids, field_name, arg, context=None):
        res = dict(map(lambda x: (x,0), ids))
        # The current user may not have access rights for sale orders
            for partner in self.browse(cr, uid, ids, context):
                res[partner.id] = len(partner.sale_order_ids)
        return res

    _columns = {
        'dongle_count': fields.function(_dongle_count, string='# of Dongles', type='integer'),
        'dongle_ids': fields.one2many('dongle', 'partner_id', 'Dongles')


and my res_partner_view.xml

<?xml version="1.0"?>
        <record id="act_res_partner_2_dongle" model="ir.actions.act_window">
            <field name="name">Dongles</field>
            <field name="res_model">dongle</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="context">{'search_default_partner_id': active_id}</field>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to create a dongle for this customer.


        <!-- Partner kanban view inhert -->

        <record id="res_partner_view_buttons" model="ir.ui.view">
            <field name="name">res.partner.view.buttons</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="priority" eval="20"/>
            <field name="arch" type="xml">
                <xpath expr="//div[@name='buttons']" position="inside">
                    <button name="%(act_res_partner_2_dongle)d" type="action"
                        attrs="{'invisible': [('customer', '=', False)]}"/>


After looking at the various other modules that include this, I can't seem to figure out where/what else I am supposed to add to make my new module show up in the advanced search drop down.

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

0 follower(s)


Asked: 10/24/13, 2:54 PM
Seen: 1925 times
Last updated: 3/16/15, 8:10 AM