This question has been flagged
4 Replies
10609 Views

Hi everybody,

Someone knows how to sort products by alphabetical in "Products by categories" ? When I add _order... in my python file it works only on the total list of products "Products".

Thanks in advance for your help.

JMB

Avatar
Discard
Best Answer

image description

Is this what you wanted.. ? Here you can See that i clicked on name (column header) And it got sorted in alphabetical Order.

Sorry if i have mistook your requiremet

Avatar
Discard
Author

Thanks for your answer. Unfortunately it's not this list that I wanna sort but the hierarchical tree (where it's possible to click on a category and then the subcategory opens). It's the first screen when you click on the menu "Products by Category".

Best Answer

I want to sort categories e.g. alphabetically. I haven't understood how to do this. Who would provide full instructions?

Avatar
Discard
Author Best Answer

Thanks for your answer but it doesn't work. Indeed, it's not possible to click on the title "name".

Do you see another solution ? I think I have to modify something in a js file.

Avatar
Discard
Best Answer

You need to modify the action and sort by the name, write a small module, like this:

product.py file below from openerp.osv import osv

class product_category(osv.osv):

_inherit = "product.category"
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
    if context is None:
        context = {}
    if context and context.get('order_name', False):
        order = 'name'
    return super(product_category, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count)

product_category()

XML - product_view.xml <openerp> <data> <record id="product.product_category_action" model="ir.actions.act_window"> <field name="context">{'order_name':True}</field> </record>

</data>

</openerp>

Avatar
Discard