diff --git a/addons/point_of_sale/static/src/js/db.js b/addons/point_of_sale/static/src/js/db.js index 93dc86ebd9f..2be58d6ce97 100644 --- a/addons/point_of_sale/static/src/js/db.js +++ b/addons/point_of_sale/static/src/js/db.js @@ -142,7 +142,6 @@ function openerp_pos_db(instance, module){ /* saves a record store to the database */ save: function(store,data){ var str_data = JSON.stringify(data); - console.log('Storing '+ Math.round(str_data.length/1024.0)+' KB of data to store: '+store); localStorage[this.name + '_' + store] = JSON.stringify(data); this.cache[store] = data; }, @@ -276,12 +275,9 @@ function openerp_pos_db(instance, module){ }, remove_order: function(order_id){ var orders = this.load('orders',[]); - console.log('Remove order:',order_id); - console.log('Order count:',orders.length); orders = _.filter(orders, function(order){ return order.id !== order_id; }); - console.log('Order count:',orders.length); this.save('orders',orders); }, get_orders: function(){ diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index d4b1df38d36..fb5c9c6f417 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -342,7 +342,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal this.order = options.order; this.product = options.product; this.price = options.product.get('price'); - this.priceStr = '' + this.price; this.quantity = 1; this.quantityStr = '1'; this.discount = 0; @@ -352,19 +351,10 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal }, // sets a discount [0,100]% set_discount: function(discount){ - var disc = parseFloat(discount); - if(_.isNaN(disc)){ - return; - }else if(disc < 0){ - this.discount = 0; - this.discountStr = '0'; - }else if(disc > 100){ - this.discount = 100; - this.discountStr = '100'; - }else{ - this.discount = disc; - this.discountStr = discount; - } + console.log('set_discount: ',discount); + var disc = Math.min(Math.max(parseFloat(discount) || 0, 0),100); + this.discount = disc; + this.discountStr = '' + disc; this.trigger('change'); }, // returns the discount [0,100]% @@ -381,16 +371,12 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal // product's unity of measure properties. Quantities greater than zero will not get // rounded to zero set_quantity: function(quantity){ - var quant = parseFloat(quantity); - if(_.isNaN(quant)){ - if(quantity === 'remove'){ - this.order.removeOrderline(this); - } + console.log('set_quantity: ',quantity); + if(quantity === 'remove'){ + this.order.removeOrderline(this); return; }else{ - if(quant < 0){ - quant = 0; - } + var quant = Math.max(parseFloat(quantity) || 0, 0); var unit = this.get_unit(); if(unit){ this.quantity = Math.max(unit.rounding, Math.round(quant / unit.rounding) * unit.rounding); @@ -486,11 +472,8 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal }, // changes the base price of the product for this orderline set_unit_price: function(price){ - var pr = parseFloat(price); - if(_.isNaN(pr)){ - return; - } - this.price = round(pr,2); + console.log('set_price: ',price); + this.price = round(parseFloat(price) || 0, 2); this.trigger('change'); }, get_unit_price: function(){ @@ -567,16 +550,8 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal }, //sets the amount of money on this payment line set_amount: function(value){ - if(typeof value === 'string'){ - var val = parseFloat(value); - if(!isNaN(val)){ - this.amount = val; - this.trigger('change'); - } - }else{ - this.amount = value; - this.trigger('change'); - } + this.amount = parseFloat(value) || 0; + this.trigger('change'); }, // returns the amount of money on this paymentline get_amount: function(){ @@ -865,24 +840,19 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal buffer: (this.get('buffer')) + newChar }); } - this.updateTarget(); + this.trigger('set_value',this.get('buffer')); }, deleteLastChar: function() { - var tempNewBuffer = this.get('buffer').slice(0, -1); - - if(!tempNewBuffer){ - this.set({ buffer: "0" }); + if(this.get('buffer') === ""){ if(this.get('mode') === 'quantity'){ - this.killTarget(); + this.trigger('set_value','remove'); }else{ - this.updateTarget(); + this.trigger('set_value',this.get('buffer')); } }else{ - if (isNaN(tempNewBuffer)) { - tempNewBuffer = "0"; - } - this.set({ buffer: tempNewBuffer }); - this.updateTarget(); + var newBuffer = this.get('buffer').slice(0,-1) || ""; + this.set({ buffer: newBuffer }); + this.trigger('set_value',this.get('buffer')); } }, switchSign: function() { @@ -891,7 +861,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal this.set({ buffer: oldBuffer[0] === '-' ? oldBuffer.substr(1) : "-" + oldBuffer }); - this.updateTarget(); + this.trigger('set_value',this.get('buffer')); }, changeMode: function(newMode) { this.set({ @@ -908,17 +878,5 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal resetValue: function(){ this.set({buffer:'0'}); }, - updateTarget: function() { - var bufferContent, params; - bufferContent = this.get('buffer'); - if (bufferContent && !isNaN(bufferContent)) { - console.log('set_value ',bufferContent); - this.trigger('set_value',bufferContent); - } - }, - killTarget: function(){ - console.log('set_value ','remove'); - this.trigger('set_value','remove'); - }, }); } diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index eb2250d7f9e..2d522c0a1c0 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -368,7 +368,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa module.ChooseReceiptPopupWidget = module.PopUpWidget.extend({ template:'ChooseReceiptPopupWidget', show: function(){ - console.log('show'); this._super(); this.renderElement(); var self = this; @@ -603,7 +602,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa // initiates the connection to the payment terminal and starts the update requests this.start = function(){ var def = new $.Deferred(); - console.log("START"); self.pos.proxy.payment_request(self.pos.get('selectedOrder').getDueLeft()) .done(function(ack){ if(ack === 'ok'){ @@ -613,7 +611,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }else{ console.error('unknown payment request return value:',ack); } - console.log("START_END"); def.resolve(); }); return def; @@ -621,10 +618,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa // gets updated status from the payment terminal and performs the appropriate consequences this.update = function(){ - console.log("UPDATE"); var def = new $.Deferred(); if(self.canceled){ - console.log("UPDATE_END"); return def.resolve(); } self.pos.proxy.payment_status() @@ -656,7 +651,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }else{ console.error('unknown status value:',status.status); } - console.log("UPDATE_END"); def.resolve(); }); return def; @@ -664,14 +658,12 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa // cancels a payment. this.cancel = function(){ - console.log("CANCEL"); if(!self.paid && !self.canceled){ self.canceled = true; self.pos.proxy.payment_cancel(); self.pos_widget.screen_selector.set_current_screen(self.previous_screen); self.queue.clear(); } - console.log("CANCEL_END"); return (new $.Deferred()).resolve(); } @@ -941,7 +933,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }); l.appendTo(this.$('#paymentlines')); this.paymentlinewidgets.push(l); - this.$('.paymentline-amount input:last').focus(); if(this.numpadState){ this.numpadState.resetValue(); } diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index d9e57d08add..ccad06e70fd 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -313,17 +313,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa }, changeAmount: function(event) { var newAmount = event.currentTarget.value; - console.log(event); - console.log('changeAmount:',newAmount); - if( typeof newAmmount === 'string'){ - var amount = parseFloat(newAmount); - if(!isNaN(amount)){ - this.amount = amount; - this.payment_line.set_amount(amount); - } - }else if(!isNaN(newAmount)){ - this.amount = newAmount; - this.payment_line.set_amount(newAmount); + var amount = parseFloat(newAmount); + if(!isNaN(amount)){ + this.amount = amount; + this.payment_line.set_amount(amount); } }, changedAmount: function() {