0

I'm using OpenERP V7.

I have the following structure:

  • Category 1
    • Subcategory A
      • Product 1
      • Product 2
    • Subcategory B
      • Product 3
      • Product 4
  • Category 2
    • Subcategory C
      • Product 5
      • Product 6

I would like to list all the products under Category 1. But I can only list the products if I search for Subcategory A or Subcategory B. If I search for Category 1 it shows an empty list.

I saw similar questions:

But I can't make it work with any of the solutions there. I think I'm missing some step. What would be the best way to solve it?

Edit: Also found this module: https://www.odoo.com/apps/7.0/product_category_full_search/ I can install it but after the installation It doesn't seem to work, if I look for Category1 it's still empty.

2 Answers 2

1

I finally found the way, it's explained in the second link.

I was modifying the file product_view.xml. But as explained here, the XML files are uploaded into the database for faster response, meaning that the changes done in the file itself in your computer won't have a direct effect on the server, unless you update the module.

There were two ways of solving my question:

  1. You create a module (there are some tutorials around explaining that) and then you install it.

The code for the view would be:

<record id="view_product_search_child_categories" model="ir.ui.view">
    <field name="name">product.search.categories</field>
    <field name="model">product.product</field>
    <field name="inherit_id" ref="product.product_search_form_view" />
    <field name="arch" type="xml">
        <field name="categ_id" position="attributes">
            <attribute name="operator">child_of</attribute>
        </field>
    </field>
</record>

Or the other option:

  1. You create a view directly from within OpenERP interface. In my case I did:
    • Enable the Technical features of my admin user.
    • Go to Settings>Technical>User Interface>Views>Create:
      • View name: product.search.categories
      • View type: (it will display Tree but after saving will change to Search)
      • Object: product.product
      • Child Field: empty
      • Inherited view: product.search.form
      • External ID: empty

In the architecture write:

<?xml version="1.0"?>
    <field name="categ_id" position="attributes">
        <attribute name="operator">child_of</attribute>
    </field>
0

You can go to Sales --> Products --> Products by Category menu and delete the filter in search bar. You'll have all product of the category tree.

Or you can create a filter like

<filter string="NAME" icon="terp-accessories-archiver" domain="[('categ_id','child_of',X]"/>

where X is the ID of your category. You can use a list of categories like domain="[('categ_id','child_of',[X,Y])]"

4
  • I saw that answer on the 2nd link I shared. That doesn't work.
    – EricPb
    Sep 24, 2014 at 8:04
  • Thank you Yaseen, but I don't see where I should put that piece of code.
    – EricPb
    Sep 24, 2014 at 14:07
  • You can use it in the group by part of the search filter for the list of products. Sep 25, 2014 at 3:57
  • Thats great Eric, do share if there's a better method...:-) Sep 25, 2014 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.