Browse Source

Merge pull request #736 from adhoc-dev/9.0-mig-web_decimal_numpad_dot

[9.0] web decimal numpad dot [Backport v10]
pull/757/head
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
74740d0d9b
  1. 58
      web_decimal_numpad_dot/README.rst
  2. 1
      web_decimal_numpad_dot/__init__.py
  3. 27
      web_decimal_numpad_dot/__openerp__.py
  4. BIN
      web_decimal_numpad_dot/static/description/icon.png
  5. 43
      web_decimal_numpad_dot/static/src/js/numpad_dot.js
  6. 11
      web_decimal_numpad_dot/views/web_decimal_numpad_dot.xml

58
web_decimal_numpad_dot/README.rst

@ -0,0 +1,58 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
===============================
Numpad Dot as decimal separator
===============================
Allows using numpad dot to enter period decimal separator even in localizations
where comma is used instead of period.
Usage
=====
Whenever on a float or monetary input field pressing numpad dot produces the
proper decimal separator for the active localization.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/web/162
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/web/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.
Credits
=======
Contributors
------------
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Ana Juaristi <anajuaristi@avanzosc.es>
* Omar Castiñeira Saavedra <omar@comunitea.com>
* Oliver Dony <@odony>
* Wim Audenaert <Wim.Audenaert@ucamco.com>
* David Vidal <david.vidal@tecnativa.com>
* Jairo Llopis <jairo.llopis@tecnativa.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

1
web_decimal_numpad_dot/__init__.py

@ -0,0 +1 @@
# -*- encoding: utf-8 -*-

27
web_decimal_numpad_dot/__openerp__.py

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Copyright 2015 AvanzOSC - Oihane Crucelaegui
# Copyright 2015 Tecnativa - Pedro M. Baeza
# Copyright 2015 Comunitea - Omar Castiñeira Saavedra
# Copyright 2016 Oliver Dony
# Copyright 2017 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Web - Numpad Dot as decimal separator",
"version": "9.0.1.0.0",
"license": "AGPL-3",
"summary": "Allows using numpad dot to enter period decimal separator",
"depends": [
"web",
],
"author": "AvanzOSC, "
"Comunitea, "
"Tecnativa, "
"Odoo Community Association (OCA)",
"website": "https://odoo-community.org/",
"category": "Web",
"data": [
"views/web_decimal_numpad_dot.xml",
],
"installable": True,
}

BIN
web_decimal_numpad_dot/static/description/icon.png

After

Width: 513  |  Height: 513  |  Size: 38 KiB

43
web_decimal_numpad_dot/static/src/js/numpad_dot.js

@ -0,0 +1,43 @@
/* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) {
"use strict";
var form_widgets = require("web.form_widgets");
var translation = require("web.translation");
form_widgets.FieldFloat.include({
init: function () {
this.events = $.extend({}, this.events, {
"keydown": "numpad_dot_replace",
});
return this._super.apply(this, arguments);
},
l10n_decimal_point: function () {
return this.widget == "float_time"
? ":" : translation._t.database.parameters.decimal_point;
},
numpad_dot_replace: function (event) {
// Only act on numpad dot key
if (event.keyCode != 110) {
return;
}
event.preventDefault();
var from = this.$input.prop("selectionStart"),
to = this.$input.prop("selectionEnd"),
cur_val = this.$input.val(),
point = this.l10n_decimal_point();
// Replace selected text by proper character
this.$input.val(
cur_val.substring(0, from) +
point +
cur_val.substring(to)
);
// Put user caret in place
to = from + point.length
this.$input.prop("selectionStart", to).prop("selectionEnd", to);
},
});
});

11
web_decimal_numpad_dot/views/web_decimal_numpad_dot.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<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>
</odoo>
Loading…
Cancel
Save