Browse Source

Merge pull request #1245 from Tecnativa/8.0-web_decimal_numpad_dot

[8.0][ADD] web_decimal_numpad_dot: For proper Odoo apps indexation
pull/394/merge
Pedro M. Baeza 5 years ago
committed by GitHub
parent
commit
23da5b12c9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      web_decimal_numpad_dot/README.rst
  2. 4
      web_decimal_numpad_dot/__init__.py
  3. 36
      web_decimal_numpad_dot/__openerp__.py
  4. 25
      web_decimal_numpad_dot/static/src/js/numpad_dot.js
  5. 10
      web_decimal_numpad_dot/views/web_decimal_numpad_dot.xml

15
web_decimal_numpad_dot/README.rst

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

4
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
##############################################################################

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

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

10
web_decimal_numpad_dot/views/web_decimal_numpad_dot.xml

@ -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>
Loading…
Cancel
Save