From ef72f482fbeaa1998a5d857d1081d21b9e759ddd Mon Sep 17 00:00:00 2001 From: "Vidhin Mehta (OpenERP)" Date: Thu, 13 Dec 2012 17:36:57 +0530 Subject: [PATCH] [IMP]Make validation on payable amount field.In that user can enter only number and a single dot in input box. bzr revid: vme@tinyerp.com-20121213120657-yez2wi7j05lgtziw --- addons/point_of_sale/static/src/js/widgets.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 135c00f198d..fb8eead4d86 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -308,11 +308,21 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa if (this.amount !== this.payment_line.get_amount()) this.renderElement(); }, + checkAmount:function(e){ + if (e.which !== 0 && e.charCode !== 0) { + if(isNaN(String.fromCharCode(e.charCode))){ + return (String.fromCharCode(e.charCode) === "." && e.currentTarget.value.toString().split(".").length < 2)?true:false; + } + } + return true + }, renderElement: function() { var self = this; this.name = this.payment_line.get_cashregister().get('journal_id')[1]; this._super(); - this.$('input').keyup(_.bind(this.changeAmount, this)); + this.$('input') + .keypress(_.bind(this.checkAmount, this)) + .keyup(_.bind(this.changeAmount, this)); this.$('.delete-payment-line').click(function() { self.trigger('delete_payment_line', self); });