[IMP] pos_restaurant: allow re-ordering of the restaurant floors
authorFrederic van der Essen <fva@openerp.com / fvdessen+o@gmail.com>
Tue, 18 Nov 2014 22:03:46 +0000 (23:03 +0100)
committerFrédéric van der Essen <fvdessen@gmail.com>
Wed, 26 Nov 2014 11:18:49 +0000 (12:18 +0100)
addons/pos_restaurant/restaurant.py
addons/pos_restaurant/restaurant_view.xml
addons/pos_restaurant/static/src/js/floors.js

index 52f66e1..46affe5 100644 (file)
@@ -35,6 +35,11 @@ class restaurant_floor(osv.osv):
         'pos_config_id':    fields.many2one('pos.config','Point of Sale'),
         'background_image': fields.binary('Background Image', help='A background image used to display a floor layout in the point of sale interface'),  
         'table_ids':        fields.one2many('restaurant.table','floor_id','Tables', help='The list of tables in this floor'),
+        'sequence':         fields.integer('Sequence',help='Used to sort Floors'),
+    }
+
+    _defaults = {
+        'sequence': 1,
     }
 
 class restaurant_table(osv.osv):
index 38b24cd..1baacaa 100644 (file)
@@ -31,6 +31,7 @@
             <field name="model">restaurant.floor</field>
             <field name="arch" type="xml">
                 <tree string="Restaurant Floors">
+                    <field name="sequence" widget="handle" />
                     <field name="name" />
                     <field name="pos_config_id" />
                 </tree>
index 0e1e025..d329aa5 100644 (file)
@@ -5,7 +5,7 @@ function openerp_restaurant_floors(instance,module){
     // At POS Startup, load the floors, and add them to the pos model
     module.PosModel.prototype.models.push({
         model: 'restaurant.floor',
-        fields: ['name','background_image','table_ids'],
+        fields: ['name','background_image','table_ids','sequence'],
         domain: function(self){ return [['pos_config_id','=',self.config.id]] },
         loaded: function(self,floors){
             self.floors = floors;
@@ -14,6 +14,10 @@ function openerp_restaurant_floors(instance,module){
                 floors[i].tables = [];
                 self.floors_by_id[floors[i].id] = floors[i];
             }
+
+            // Make sure they display in the correct order
+            self.floors = self.floors.sort(function(a,b){ return a.sequence - b.sequence; });
+
             // Ignore floorplan features if no floor specified, or feature deactivated
             self.config.iface_floorplan = self.config.iface_floorplan && !!self.floors.length;
         },