Odoo Help

Welcome!

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.

0

How to sort products in "Products by categories" by alphabetical ?

By
Anne-Sylvie Burri
on 11/7/13, 4:45 AM 2,244 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

2
Anne-Sylvie Burri
On 11/12/13, 11:27 AM

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.

1
Subhin P V
On 11/7/13, 9:07 AM

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

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".

J.-M. Burri - Bureau ing.-conseils informatique, Anne-Sylvie Burri
on 11/20/13, 3:36 AM
0
E.R. Spada II
On 3/14/14, 12:54 AM

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>

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

0 follower(s)

Stats

Asked: 11/7/13, 4:45 AM
Seen: 2244 times
Last updated: 3/16/15, 8:10 AM