3
0
Fork 0

Merge pull request #1245 from Tecnativa/8.0-web_decimal_numpad_dot

[8.0][ADD] web_decimal_numpad_dot: For proper Odoo apps indexation
8.0
Pedro M. Baeza 2019-04-10 18:42:31 +02:00 committed by GitHub
commit 23da5b12c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,15 @@
Web - Numpad Dot as decimal separator
=====================================
Credits
=======
Contributors
------------
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Ana Juaristi <anajuaristi@avanzosc.es>
* Omar Castiñeira Saavedra <omar@comunitea.com>

View File

@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################

View File

@ -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,
}

View File

@ -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() + ',');
}
}
},
});
})();

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="assets_backend" name="numpad_dot assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_decimal_numpad_dot/static/src/js/numpad_dot.js"></script>
</xpath>
</template>
</data>
</openerp>