From 98e5673c908fe4d72e55a068a951700cc93ee33f Mon Sep 17 00:00:00 2001
From: Nicolas Martinelli <nim@odoo.com>
Date: Fri, 8 Jan 2016 10:09:39 +0100
Subject: [PATCH] [FIX] product: sort pricelist items by sequence

The pricelist items should be sorted by sequence.

opw-660745
---
 addons/product/pricelist.py       | 4 ++--
 addons/product/pricelist_view.xml | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/addons/product/pricelist.py b/addons/product/pricelist.py
index ab8c84f6433d..bcd81241621e 100644
--- a/addons/product/pricelist.py
+++ b/addons/product/pricelist.py
@@ -148,7 +148,7 @@ class product_pricelist(osv.osv):
             'AND (categ_id IS NULL OR categ_id = any(%s)) '
             'AND (pricelist_id = %s) '
             'AND ((i.date_start IS NULL OR i.date_start<=%s) AND (i.date_end IS NULL OR i.date_end>=%s))'
-            'ORDER BY applied_on, min_quantity desc',
+            'ORDER BY sequence, applied_on, min_quantity desc',
             (prod_tmpl_ids, prod_ids, categ_ids, pricelist.id, date, date))
 
         item_ids = [x[0] for x in cr.fetchall()]
@@ -251,7 +251,7 @@ class product_pricelist(osv.osv):
 class product_pricelist_item(osv.osv):
     _name = "product.pricelist.item"
     _description = "Pricelist item"
-    _order = "applied_on, min_quantity desc"
+    _order = "sequence, applied_on, min_quantity desc"
 
     def _check_recursion(self, cr, uid, ids, context=None):
         for obj_list in self.browse(cr, uid, ids, context=context):
diff --git a/addons/product/pricelist_view.xml b/addons/product/pricelist_view.xml
index db191649c618..64f2a6d751e6 100644
--- a/addons/product/pricelist_view.xml
+++ b/addons/product/pricelist_view.xml
@@ -134,6 +134,7 @@
                             <separator string="Pricelist Items"/>
                             <field name="item_ids" nolabel="1" context="{'default_base':'list_price'}">
                                 <tree string="Pricelist Items">
+                                    <field name="sequence" widget="handle"/>
                                     <field name="name" string="Applicable On"/>
                                     <field name="min_quantity"/>
                                     <field name="date_start"/>
-- 
GitLab