[FIX] sale_layout: set 0 as default value for categ_sequence
authorDenis Ledoux <dle@odoo.com>
Wed, 26 Nov 2014 16:02:20 +0000 (17:02 +0100)
committerDenis Ledoux <dle@odoo.com>
Wed, 26 Nov 2014 16:03:42 +0000 (17:03 +0100)
Otherwise, in some cases, the categ_sequence can be set to null, which is not ordered the same way than 0, and you won't be able to sort lines with null and 0 as categ_sequence between each others

addons/sale_layout/models/sale_layout.py

index b5c996a..54298bd 100644 (file)
@@ -84,6 +84,9 @@ class AccountInvoiceLine(osv.Model):
     sale_layout_cat_id = openerp.fields.Many2one('sale_layout.category', string='Section')
     categ_sequence = openerp.fields.Integer(related='sale_layout_cat_id.sequence',
                                             string='Layout Sequence', store=True)
+    _defaults = {
+        'categ_sequence': 0
+    }
 
 
 class SaleOrder(osv.Model):
@@ -113,6 +116,11 @@ class SaleOrderLine(osv.Model):
                                          string='Layout Sequence', store=True)
         #  Store is intentionally set in order to keep the "historic" order.
     }
+
+    _defaults = {
+        'categ_sequence': 0
+    }
+
     _order = 'order_id, categ_sequence, sequence, id'
 
     def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):