From 5ec43630eaab0f7a8a84c1769915aac554313b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Sun, 1 Feb 2015 23:43:04 +0100 Subject: [PATCH] [IMP] pos_restaurant: automatic numbering of new tables. --- addons/pos_restaurant/static/src/js/floors.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/addons/pos_restaurant/static/src/js/floors.js b/addons/pos_restaurant/static/src/js/floors.js index fbfcfa177e3..d8caffd162e 100644 --- a/addons/pos_restaurant/static/src/js/floors.js +++ b/addons/pos_restaurant/static/src/js/floors.js @@ -473,17 +473,32 @@ openerp.pos_restaurant.load_floors = function(instance,module){ 'position_h': 100, 'width': 75, 'height': 75, - 'name': 'T1', 'shape': 'square', 'seats': 1, }); this.select_table(tw); }, + new_table_name: function(name){ + if (name) { + var num = Number((name.match(/\d+/g) || [])[0] || 0); + var str = (name.replace(/\d+/g,'')); + var n = {num: num, str:str}; + n.num += 1; + this.last_name = n; + } else if (this.last_name) { + this.last_name.num += 1; + } else { + this.last_name = {num: 1, str:'T'}; + } + return '' + this.last_name.str + this.last_name.num; + }, create_table: function(params) { var table = {}; for (var p in params) { table[p] = params[p]; } + + table.name = this.new_table_name(params.name); delete table['id']; table.floor_id = [this.floor.id,''];