diff --git a/addons/point_of_sale/__openerp__.py b/addons/point_of_sale/__openerp__.py index 9d985d40408..c4258511a68 100644 --- a/addons/point_of_sale/__openerp__.py +++ b/addons/point_of_sale/__openerp__.py @@ -86,6 +86,7 @@ Main features: 'js': [ 'static/lib/backbone/backbone-0.9.2.js', 'static/lib/mousewheel/jquery.mousewheel-3.0.6.js', + 'static/src/js/pos_db.js', 'static/src/js/pos_models.js', 'static/src/js/pos_basewidget.js', 'static/src/js/pos_keyboard_widget.js', diff --git a/addons/point_of_sale/static/src/js/db.js b/addons/point_of_sale/static/src/js/db.js deleted file mode 100644 index 86ad9a53a59..00000000000 --- a/addons/point_of_sale/static/src/js/db.js +++ /dev/null @@ -1,66 +0,0 @@ -function openerp_pos_db(instance, module){ - function importIndexedDB(){ - if('indexedDB' in window){ - return true; - }else if('webkitIndexedDB' in window){ - window.indexedDB = window.webkitIndexedDB; - window.IDBCursor = window.webkitIDBCursor; - window.IDBDatabase = window.webkitIDBDatabase; - window.IDBDatabaseError = window.webkitIDBDatabaseError; - window.IDBDatabaseException = window.webkitIDBDatabaseException; - window.IDBFactory = window.webkitIDBFactory; - window.IDBIndex = window.webkitIDBIndex; - window.IDBKeyRange = window.webkitIDBKeyRange; - window.IDBObjectSrore = window.webkitIDBOjbectStore; - window.IDBRequest = window.webkitIDBRequest; - window.IDBTransaction = window.webkitIDBTransaction; - }else if('mozIndexedDB' in window){ - window.indexedDB = window.mozIndexedDB; - }else{ - throw new Error("DATABASE ERROR: IndexedDB not implemented. Please upgrade your web browser"); - } - } - importIndexedDB(); - - modula.PosDB = modula.Class.extend({ - - state: 'connecting', // 'connecting' || 'connected' || 'failed' - version: 1, - name: 'openerp_pos_db', - - init: function(options){ - var open_request = indexedDB.open(this.name, this.version); - }, - upgrade_db: function(oldversion, transaction){ - this.db = transaction.db; - var productStore = this.db.createObjectStore("products", {keyPath: "id"}); - - productStore.createIndex("ean13", "ean13", {unique:true}); - - productStore.createIndex("name", "name", {unique:false}); - - productStore.createIndex("category","category", {unique:false}); - - var imageStore = this.db.createObjectStore("images", {keyPath: "id"}); - - imageStore.createIndex("product_id", "product_id", {unique:true}); - }, - _add_data: function(store, data, result_callback){ - var transaction = this.db.transaction([store], IDBTransaction.READ_WRITE); - - transaction.oncomplete = function(event){ if(result_callback){ result_callback(event); }}; - - }, - add_product: function(product){ - }, - get_product_by_ean: function(ean, result_callback){ - }, - get_product_by_category: function(category, result_callback){ - }, - get_product_image: function(product, result_callback){ - }, - search_product: function(query,result_callback){ - }, - }); - -} diff --git a/addons/point_of_sale/static/src/js/pos_main.js b/addons/point_of_sale/static/src/js/pos_main.js index 71ac69c6067..b9263b91314 100644 --- a/addons/point_of_sale/static/src/js/pos_main.js +++ b/addons/point_of_sale/static/src/js/pos_main.js @@ -5,6 +5,8 @@ openerp.point_of_sale = function(instance) { var module = instance.point_of_sale; + openerp_pos_db(instance,module); // import db.js + openerp_pos_models(instance,module); // import pos_models.js openerp_pos_basewidget(instance,module); // import pos_basewidget.js diff --git a/addons/point_of_sale/static/src/js/pos_models.js b/addons/point_of_sale/static/src/js/pos_models.js index 548b6b749f9..634e0d9b862 100644 --- a/addons/point_of_sale/static/src/js/pos_models.js +++ b/addons/point_of_sale/static/src/js/pos_models.js @@ -74,6 +74,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal this.weightable_categories = []; // a flat list of all categories that directly contain weightable products this.barcode_reader = new module.BarcodeReader({'pos': this}); // used to read barcodes this.proxy = new module.ProxyDevice(); // used to communicate to the hardware devices via a local proxy + this.db = new module.PosDB(); // a database used to store the products and product images // pos settings this.use_scale = false; diff --git a/addons/point_of_sale/static/src/js/pos_widgets.js b/addons/point_of_sale/static/src/js/pos_widgets.js index b41ccbfcc9a..a30a0ebe521 100644 --- a/addons/point_of_sale/static/src/js/pos_widgets.js +++ b/addons/point_of_sale/static/src/js/pos_widgets.js @@ -968,12 +968,14 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa }); }, close: function() { + var self = this; this.pos.barcode_reader.disconnect(); return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_close_statement']], ['res_id']).pipe( _.bind(function(res) { return this.rpc('/web/action/load', {'action_id': res[0]['res_id']}).pipe(_.bind(function(result) { var action = result.result; action.context = _.extend(action.context || {}, {'cancel_action': {type: 'ir.actions.client', tag: 'reload'}}); + //self.destroy(); this.do_action(action); }, this)); }, this));