Help

8

change search behavior

Avatar
Andreas Maertens

Hi everybody,

is there a way to change standard search behavior? The users expectations of a search field are different from what OpenERP does as I think. Whenever I confront a user with this behavior he tells me that it's strange.

If I type in search fields stuff like "Mainboard | Asus" I expect to find all names with "Mainboards" and "Asus". You all know I find all Names with "Mainboards" and all Names with "Asus".

I know about the possibility to use advanced searches but changing that behavior will serve customers expectations and make working with openerp easier.

Does anyone knows a way to change that? Couldn't find something in expressions.py or orm.py

Thanks in advance

5 Comments
Avatar
Discard
Avatar
Andreas Maertens
-

Thanks Ray, that sounds like a handy solution.

Avatar
Ashmsh.M
-

how can be change the advance search labels ; eg: Active is changed to Present where did i edit the view

Avatar
Andreas Maertens
-

I've found the source handle the "OR" behavior. In "web/addons/web/source/src/js/search.js" search for " if (domains.length === 1) { return domains[0]; } for (var i = domains.length; --i;) { domains.unshift(['|']); }"

Avatar
Andreas Maertens
-

Thank you, that looks very interesting.

Avatar
Dhrupesh
-

Hello Andres,

You can change search behaviour , override def _search method .

Thanks,

5 Answers
3
Avatar
Andreas Maertens
Best Answer

I could improve search behavior by adding more "search criteria" to the "search.view" In an addon I added following inherited views to improve searches. This is mainly the same as the module of Grover Menacho does but without the dynamic his module provides.

    <record id="rcs_product_search_form" model="ir.ui.view">
        <field name="inherit_id" ref="base.view_res_partner_filter"/>
        <field name="name">res.partner.select</field>
        <field name="model">res.partner</field>
        <field name="arch" type="xml">
            <field name="name" position="before">
               <field name="street2" string="full-text"
                      filter_domain="[
                            '|',('name','ilike',self),
                            '|',('parent_id','ilike',self),
                            '|',('ref','=',self),
                            '|',('street','ilike',self),
                            '|',('street2','ilike',self),
                            '|',('zip','ilike',self),
                            '|',('city','ilike',self),
                            '|',('email','ilike',self),
                            '|',('phone','ilike',self),
                            '|',('fax','ilike',self),
                            '|',('mobile','ilike',self),
                            '|',('lang','ilike',self),
                            '|',('website','ilike',self),
                            '|',('country_id.name','ilike',self),
                            ('ean13','ilike',self)
                            ]" />
            </field>
            <field name="name" position="after">
                <field name="parent_id" filter_domain="[('parent_id','ilike',self)]"/>
                <field name="ref" filter_domain="[('ref','ilike',self)]"/>
                <field name="street" filter_domain="['|',('street','ilike',self),('street2','ilike',self)]"/>
                <field name="zip" filter_domain="[('zip','ilike',self)]"/>
                <field name="city" filter_domain="[('city','ilike',self)]"/>
                <field name="email" filter_domain="[('email','ilike',self)]"/>
                <field name="phone" filter_domain="[('phone','ilike',self)]"/>
                <field name="fax" filter_domain="[('fax','ilike',self)]"/>
                <field name="mobile" filter_domain="[('mobile','ilike',self)]"/>
                <field name="lang" filter_domain="[('lang','ilike',self)]"/>
                <field name="website" filter_domain="[('website','ilike',self)]"/>
                <field name="country_id" filter_domain="[('country_id.name','ilike',self)]"/>
                <field name="ean13" filter_domain="[('ean13','ilike',self)]"/>
            </field>
        </field>
    </record>

and

        <record id="rcs_product_search_form_view" model="ir.ui.view">
        <field name="inherit_id" ref="product.product_search_form_view"/>
        <field name="name">product.search.form</field>
        <field name="model">product.product</field>
        <field name="arch" type="xml">
            <field name="name" position="before">
               <field name="description" string="full-text"
                      filter_domain="[
                            '|',('name','ilike',self),
                            '|',('description','ilike',self),
                            '|',('default_code','ilike',self),
                            '|',('seller_id','ilike',self),
                            '|',('seller_product_code','ilike',self),
                            '|',('description_sale','ilike',self),
                            ('producer_id.name','ilike',self),
                            ]" />
            </field>
            <field name="name" position="after">
                <field name="default_code" filter_domain="[('default_code','ilike',self)]"/>
                <field name="seller_id" filter_domain="[('seller_id','ilike',self)]"/>
                <field name="seller_product_code" filter_domain="[('seller_product_code','ilike',self)]"/>
                <field name="description_sale" filter_domain="[('description_sale','ilike',self)]"/>
                <field name="producer_id" filter_domain="[('producer_id','ilike',self)]"/>
            </field>
        </field>
    </record>
Avatar
Discard
2
Avatar
Grover Menacho
Best Answer

Hello.

I'm starting with Launchpad so I'm not sure if I did it well anyways you can find a module that improves search of products here:

https://code.launchpad.net/~hmen/openobject-poiesis/extra-addons-poiesis

I hope this can help you.

5 Comments
Avatar
Discard
Avatar
Andreas Maertens
-

Thanks for your module. It really improves search a bit and I have some additional ideas, but it doesn't solve the probleme I talked about. The general search still is with an 'and'.

Avatar
Andreas Maertens
-

After thinkin about your module I must say it does solve the Problem in a way. It helps me to find arguments for the existing solution in openerp and I think with your model and the standard behavior this may be the optimal solution. ty

Avatar
Grover Menacho
-

Yes, but I think I misunderstood your requirement, my module helps you to add fields to search but that was not the principal purpose, it helps you when you are searching a product in a sale order for example, you can write two words separated and you can find the product inmediately. For example 'Coca Cola Light' you only have to write 'Coc Lig' and it's going to find it. Basically it was to help in sale orders, anyways it can be improved a lot even in the search box adding some 'and' or 'or'.

Avatar
Andreas Maertens
-

Do you have any idea where to find that functionality? I am looking for since hours.

Avatar
Grover Menacho
-

I don't think that some functionality like that exists, anyways I'll do it by the same method as I did this module. Only parsing some elements that is not really complicated you'll have a searchbox that can do what you want.

0
Avatar
avasen
Best Answer

HELLO i know this post is not from now but i wanted to know if you have found a sloution because i am faced to the same problem

thanks a lot

1 Comment
Avatar
Discard
Avatar
Andreas Maertens
-

Sorry, we still have no easy way to do that.

0
Avatar
Ahmet Altinisik
Best Answer

And I found https://www.openerp.com/apps/7.0/web_filter_and_condition/ - but haven't tested yet!

Avatar
Discard
0
Avatar
fisher
Best Answer
Avatar
Discard