From 997ba7e3f5cc62f5ee45ad2786166fa7ec758330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Casti=C3=B1eira=20Saavedra?= Date: Tue, 15 Dec 2015 11:53:05 +0100 Subject: [PATCH] web_decimal_numpad_dot: fixed float widget not working properly --- web_decimal_numpad_dot/static/src/js/numpad_dot.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/web_decimal_numpad_dot/static/src/js/numpad_dot.js b/web_decimal_numpad_dot/static/src/js/numpad_dot.js index 621bf89c..55f9917c 100644 --- a/web_decimal_numpad_dot/static/src/js/numpad_dot.js +++ b/web_decimal_numpad_dot/static/src/js/numpad_dot.js @@ -2,11 +2,13 @@ var instance = openerp; - instance.web.form.FieldFloat = instance.web.form.FieldChar.extend({ - is_field_number: true, - widget_class: 'oe_form_field_float', - events: { - "keypress": "floatKeypress", + instance.web.form.FieldFloat = instance.web.form.FieldFloat.extend({ + render_value: function() { + var self = this; + this._super(); + if (!this.get('readonly')){ + this.$el.find('input').on('keypress', this.floatKeypress.bind(this)); + } }, floatKeypress: function(e){ if(e.keyCode == '46' || e.charCode == '46'){ @@ -14,7 +16,7 @@ e.preventDefault(); // Add the comma to the value of the input field this.$("input").val(this.$("input").val() + ','); - } + } }, }); })();