From 4079c4afa0602e57f09f52f504d9676c0abdb001 Mon Sep 17 00:00:00 2001 From: Frederic van der Essen Date: Tue, 18 Nov 2014 23:03:46 +0100 Subject: [PATCH] [IMP] pos_restaurant: allow re-ordering of the restaurant floors --- addons/pos_restaurant/restaurant.py | 5 +++++ addons/pos_restaurant/restaurant_view.xml | 1 + addons/pos_restaurant/static/src/js/floors.js | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/pos_restaurant/restaurant.py b/addons/pos_restaurant/restaurant.py index 52f66e1..46affe5 100644 --- a/addons/pos_restaurant/restaurant.py +++ b/addons/pos_restaurant/restaurant.py @@ -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): diff --git a/addons/pos_restaurant/restaurant_view.xml b/addons/pos_restaurant/restaurant_view.xml index 38b24cd..1baacaa 100644 --- a/addons/pos_restaurant/restaurant_view.xml +++ b/addons/pos_restaurant/restaurant_view.xml @@ -31,6 +31,7 @@ restaurant.floor + diff --git a/addons/pos_restaurant/static/src/js/floors.js b/addons/pos_restaurant/static/src/js/floors.js index 0e1e025..d329aa5 100644 --- a/addons/pos_restaurant/static/src/js/floors.js +++ b/addons/pos_restaurant/static/src/js/floors.js @@ -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; }, -- 1.7.10.4