Odoo Help


This community 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.


Filter product by product categories

Anne-Sylvie Burri
on 12/6/13, 6:41 AM 1,346 views


I have some problems to make a filter on research product by product categories.

So firstly I have created a new class on my python folder "product_product.py".

class product_product_category(osv.osv):
_inherit = 'product.category'
# Retourne tous les ids enfant d'une catégorie
def _compute_child(self, category):
    ids = [category.id]
    for child in category.child_ids:
    return ids

# Retourne les ids de tous les enregistrements de product.product.category dont le champ complete_name doit être recalculé
def _get_child_ids(self, cr, uid, ids, context=None):
    return_ids = []        
    for category in self.browse(cr, uid, ids, context=context):
    return return_ids

# Ici on redéfini la fonction du champ complete_name 
def _name_get_fnc2(self, cr, uid, ids, prop, unknow_none, context=None):
    product = self._name_get_fnc(cr, uid, ids, prop, unknow_none, context=context)
    return product
_order = 'complete_name asc'
_columns = {
    # Size = 1002 pour permettre 15 niveaux (15*64 + 14*3)
    'complete_name': fields.function(_name_get_fnc2, type="char", string='Full Name', size=1002,
                                    store = {                                             

secoundly i have created two records on my xml folder "product_view.xml"

        <record model="ir.ui.view" id="product_search_form_view">
        <field name="name">product.product.search.form</field>
        <field name="model">product.product</field>
        <field name="arch" type="xml">
        <search string="Recherche catégorie">
                <field name="name" />
                <filter name="mothercateg" string="Categories mères" context="{'group_by': 'parent_id'}"/>
                <filter name="filtre_categ_010" string="010 test" domain="[('complete_name', 'like','010 test')]" />
                <filter name="filtre_categ_011" string="011 test" domain="[('complete_name', 'like','011 test')]" />
                <filter name="filtre_categ_020" string="020 test" domain="[('complete_name', 'like','020 test')]" />
                <filter name="filtre_categ_030" string="030 test" domain="[('complete_name', 'like','030 test')]" />
                <filter name="filtre_categ_040" string="040 test" domain="[('complete_name', 'like','040 test')]" />
                <filter name="filtre_categ_050" string="050 test" domain="[('complete_name', 'like','050 test')]" />
                <filter name="filtre_categ_070" string="070 test" domain="[('complete_name', 'like','070 test')]" />
                <filter name="filtre_categ_075" string="075 test" domain="[('complete_name', 'like','075 test')]" />
                <filter name="filtre_categ_080" string="080 test" domain="[('complete_name', 'like','080 test')]" />
                <filter name="filtre_categ_090" string="090 test" domain="[('complete_name', 'like','090 test')]" />
                <filter name="filtre_categ_100" string="100 test" domain="[('complete_name', 'like','100 test')]" />
                <filter name="filtre_categ_120" string="120 test" domain="[('complete_name', 'like','120 test')]" />
    <record model="ir.ui.view" id="product_product_tree_view">
        <field name="name">product.product.tree</field>
        <field name="model">product.product</field>
        <field name="inherit_id" ref="product.product_product_tree_view"/>
        <field name="type">tree</field>
        <field name="arch" type="xml" >
            <field name="name" position="replace">
                <field name="name"/>

Then I have upload and instal my new module "product_product", despite of that, when i try to make a research with my product there aren't my new filters :/.

Does anybody know the answer please?

Can we maybe replace "product.search.form" by "product.category.search"? If it's possible how can i do that?

J.-M. Burri - Bureau ing.-conseils informatique, Anne-Sylvie Burri
on 12/10/13, 10:32 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 12/6/13, 6:41 AM
Seen: 1346 times
Last updated: 3/16/15, 8:10 AM