diff --git a/web_decimal_numpad_dot/README.rst b/web_decimal_numpad_dot/README.rst new file mode 100644 index 000000000..c41cb4504 --- /dev/null +++ b/web_decimal_numpad_dot/README.rst @@ -0,0 +1,15 @@ +Web - Numpad Dot as decimal separator +===================================== + + + +Credits +======= + +Contributors +------------ + +* Oihane Crucelaegui +* Pedro M. Baeza +* Ana Juaristi +* Omar Castiñeira Saavedra diff --git a/web_decimal_numpad_dot/__init__.py b/web_decimal_numpad_dot/__init__.py new file mode 100644 index 000000000..ee9e0cf60 --- /dev/null +++ b/web_decimal_numpad_dot/__init__.py @@ -0,0 +1,4 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## diff --git a/web_decimal_numpad_dot/__openerp__.py b/web_decimal_numpad_dot/__openerp__.py new file mode 100644 index 000000000..90b7e3679 --- /dev/null +++ b/web_decimal_numpad_dot/__openerp__.py @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## + +{ + "name": "Web - Numpad Dot as decimal separator", + "version": "8.0.1.0.0", + "depends": [ + "web", + ], + "author": "AvanzOSC," + "Tecnativa," + "Comunitea Servicios Tecnológicos," + "Odoo Community Association (OCA)", + "website": "http://github.com/OCA/web", + "category": "Custom Module", + "license": "AGPL-3", + "data": [ + "views/web_decimal_numpad_dot.xml", + ], + "installable": True, +} diff --git a/web_decimal_numpad_dot/static/src/js/numpad_dot.js b/web_decimal_numpad_dot/static/src/js/numpad_dot.js new file mode 100644 index 000000000..1e5a7e602 --- /dev/null +++ b/web_decimal_numpad_dot/static/src/js/numpad_dot.js @@ -0,0 +1,25 @@ +(function() { + +var instance = openerp; + +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') && instance.web._t.database.parameters.decimal_point == ','){ + //Cancel the keypress + e.preventDefault(); + // Add the comma to the value of the input field + if(this.el.firstElementChild.value.slice(-1)!=','){ + this.$("input").val(this.$("input").val() + ','); + } + } + }, +}); + +})(); diff --git a/web_decimal_numpad_dot/views/web_decimal_numpad_dot.xml b/web_decimal_numpad_dot/views/web_decimal_numpad_dot.xml new file mode 100644 index 000000000..3345c5dcc --- /dev/null +++ b/web_decimal_numpad_dot/views/web_decimal_numpad_dot.xml @@ -0,0 +1,10 @@ + + + + + +