跳至內容
選單
此問題已被標幟
4 回覆
12560 瀏覽次數

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

頭像
捨棄
最佳答案

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

最佳答案

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

頭像
捨棄
作者 最佳答案

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.

頭像
捨棄
最佳答案

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>

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
3月 15
4017
1
12月 22
6095
16
9月 24
77539
3
10月 22
10278
1
12月 21
10435