diff --git a/web_decimal_numpad_dot/README.rst b/web_decimal_numpad_dot/README.rst new file mode 100644 index 00000000..82e353e2 --- /dev/null +++ b/web_decimal_numpad_dot/README.rst @@ -0,0 +1,92 @@ +===================================== +Web - Numpad Dot as decimal separator +===================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/12.0/web_decimal_numpad_dot + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_decimal_numpad_dot + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/162/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Allows using numpad dot to enter period decimal separator even in localizations +where comma is used instead of period. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Whenever on a float or monetary input field pressing numpad dot produces the +proper decimal separator for the active localization. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* AvanzOSC +* Comunitea +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* Oihane Crucelaegui +* Ana Juaristi +* Omar Castiñeira Saavedra +* Oliver Dony <@odony> +* Wim Audenaert +* `Tecnativa `_: + + * Pedro M. Baeza + * David Vidal + * Jairo Llopis + * Ernesto Tejeda + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +This module is part of the `OCA/web `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_decimal_numpad_dot/__init__.py b/web_decimal_numpad_dot/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/web_decimal_numpad_dot/__manifest__.py b/web_decimal_numpad_dot/__manifest__.py new file mode 100644 index 00000000..1951a3e2 --- /dev/null +++ b/web_decimal_numpad_dot/__manifest__.py @@ -0,0 +1,26 @@ +# Copyright 2015 AvanzOSC - Oihane Crucelaegui +# Copyright 2015 Tecnativa - Pedro M. Baeza +# Copyright 2015 Comunitea - Omar Castiñeira Saavedra +# Copyright 2016 Oliver Dony +# Copyright 2017-18 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Web - Numpad Dot as decimal separator", + "version": "12.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://github.com/OCA/web", + "category": "Web", + "data": [ + "views/web_decimal_numpad_dot.xml", + ], + "installable": True, +} diff --git a/web_decimal_numpad_dot/i18n/web_decimal_numpad_dot.pot b/web_decimal_numpad_dot/i18n/web_decimal_numpad_dot.pot new file mode 100644 index 00000000..447d3bb3 --- /dev/null +++ b/web_decimal_numpad_dot/i18n/web_decimal_numpad_dot.pot @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + diff --git a/web_decimal_numpad_dot/readme/CONTRIBUTORS.rst b/web_decimal_numpad_dot/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..c8d09bb7 --- /dev/null +++ b/web_decimal_numpad_dot/readme/CONTRIBUTORS.rst @@ -0,0 +1,11 @@ +* Oihane Crucelaegui +* Ana Juaristi +* Omar Castiñeira Saavedra +* Oliver Dony <@odony> +* Wim Audenaert +* `Tecnativa `_: + + * Pedro M. Baeza + * David Vidal + * Jairo Llopis + * Ernesto Tejeda diff --git a/web_decimal_numpad_dot/readme/DESCRIPTION.rst b/web_decimal_numpad_dot/readme/DESCRIPTION.rst new file mode 100644 index 00000000..9737bec1 --- /dev/null +++ b/web_decimal_numpad_dot/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Allows using numpad dot to enter period decimal separator even in localizations +where comma is used instead of period. diff --git a/web_decimal_numpad_dot/readme/USAGE.rst b/web_decimal_numpad_dot/readme/USAGE.rst new file mode 100644 index 00000000..b7eab380 --- /dev/null +++ b/web_decimal_numpad_dot/readme/USAGE.rst @@ -0,0 +1,2 @@ +Whenever on a float or monetary input field pressing numpad dot produces the +proper decimal separator for the active localization. diff --git a/web_decimal_numpad_dot/static/description/icon.png b/web_decimal_numpad_dot/static/description/icon.png new file mode 100644 index 00000000..9c205cbc Binary files /dev/null and b/web_decimal_numpad_dot/static/description/icon.png differ diff --git a/web_decimal_numpad_dot/static/description/index.html b/web_decimal_numpad_dot/static/description/index.html new file mode 100644 index 00000000..7ebdcf75 --- /dev/null +++ b/web_decimal_numpad_dot/static/description/index.html @@ -0,0 +1,439 @@ + + + + + + +Web - Numpad Dot as decimal separator + + + +
+

Web - Numpad Dot as decimal separator

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

Allows using numpad dot to enter period decimal separator even in localizations +where comma is used instead of period.

+

Table of contents

+ +
+

Usage

+

Whenever on a float or monetary input field pressing numpad dot produces the +proper decimal separator for the active localization.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • AvanzOSC
  • +
  • Comunitea
  • +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + 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 00000000..82775b71 --- /dev/null +++ b/web_decimal_numpad_dot/static/src/js/numpad_dot.js @@ -0,0 +1,52 @@ +/* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */ + +odoo.define("web_decimal_numpad_dot.FieldFloat", function (require) { + "use strict"; + + var basic_fields = require("web.basic_fields"); + var translation = require("web.translation"); + + var NumpadDotReplaceMixin = { + init: function () { + this.events = $.extend({}, this.events, { + "keyup": "numpad_dot_replace", + }); + return this._super.apply(this, arguments); + }, + + l10n_decimal_point: function () { + return this.formatType === "float_time" + ? ":" : translation._t.database.parameters.decimal_point; + }, + + _replaceAt: function (cur_val, index, replacement) { + return cur_val.substr(0, index) + replacement + + cur_val.substr(index + replacement.length); + }, + + numpad_dot_replace: function (event) { + // Only act on numpad dot key + event.stopPropagation(); + 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(); + var new_val = this._replaceAt(cur_val, from-1, point); + this.$input.val(new_val); + // Put user caret in place + to = from + point.length; + this.$input.prop("selectionStart", to).prop("selectionEnd", to); + }, + }; + + basic_fields.FieldFloat.include(NumpadDotReplaceMixin); + basic_fields.FieldMonetary.include(NumpadDotReplaceMixin); + + return { + NumpadDotReplaceMixin: NumpadDotReplaceMixin, + }; +}); 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 00000000..d4815753 --- /dev/null +++ b/web_decimal_numpad_dot/views/web_decimal_numpad_dot.xml @@ -0,0 +1,11 @@ + + + + + +