From bcc6a6aeda2dd9dde545d5064c6a85180cdd8e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Tue, 11 Feb 2014 17:45:41 +0100 Subject: [PATCH] [IMP] point_of_sale: allow negative product quantities, and negatives totals bzr revid: fva@openerp.com-20140211164541-nt2xu5rhdv0tm7pk --- addons/point_of_sale/static/src/js/models.js | 9 +++++---- addons/point_of_sale/static/src/js/screens.js | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 6b54c14113d..2197783473d 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -544,11 +544,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal this.order.removeOrderline(this); return; }else{ - var quant = Math.max(parseFloat(quantity) || 0, 0); + var quant = parseFloat(quantity) || 0; var unit = this.get_unit(); if(unit){ - this.quantity = Math.max(unit.rounding, round_pr(quant, unit.rounding)); - this.quantityStr = this.quantity.toFixed(Math.max(0,Math.ceil(Math.log(1.0 / unit.rounding) / Math.log(10)))); + this.quantity = round_pr(quant, unit.rounding); + this.quantityStr = this.quantity.toFixed(Math.ceil(Math.log(1.0 / unit.rounding) / Math.log(10))); }else{ this.quantity = quant; this.quantityStr = '' + this.quantity; @@ -1104,10 +1104,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal } }, switchSign: function() { + console.log('switchsing'); var oldBuffer; oldBuffer = this.get('buffer'); this.set({ - buffer: oldBuffer[0] === '-' ? oldBuffer.substr(1) : "-" + oldBuffer + buffer: oldBuffer[0] === '-' ? oldBuffer.substr(1) : "-" + oldBuffer }); this.trigger('set_value',this.get('buffer')); }, diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index cbd6779f33c..937ee3f88d4 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -1125,8 +1125,8 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa }, is_paid: function(){ var currentOrder = this.pos.get('selectedOrder'); - return (currentOrder.getTotalTaxIncluded() >= 0.000001 - && currentOrder.getPaidTotal() + 0.000001 >= currentOrder.getTotalTaxIncluded()); + return (currentOrder.getTotalTaxIncluded() < 0.000001 + || currentOrder.getPaidTotal() + 0.000001 >= currentOrder.getTotalTaxIncluded()); }, validate_order: function(options) {