Browse Source

Merge pull request #708 from Tecnativa/10.0-mig-web_decimal_numpad_dot

[MIG] web_decimal_numpad_dot: Migration to 10.0
pull/716/head
Pedro M. Baeza 7 years ago
committed by GitHub
parent
commit
a1e93d16d4
  1. 57
      web_decimal_numpad_dot/README.rst
  2. 1
      web_decimal_numpad_dot/__init__.py
  3. 27
      web_decimal_numpad_dot/__manifest__.py
  4. BIN
      web_decimal_numpad_dot/static/description/icon.png
  5. 34
      web_decimal_numpad_dot/static/src/js/numpad_dot.js
  6. 11
      web_decimal_numpad_dot/views/web_decimal_numpad_dot.xml

57
web_decimal_numpad_dot/README.rst

@ -0,0 +1,57 @@
.. 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>
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/__manifest__.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": "10.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

34
web_decimal_numpad_dot/static/src/js/numpad_dot.js

@ -0,0 +1,34 @@
/* 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.keypress = function (event) {
if (event.which === 46 || event.which === 44) {
event.preventDefault();
var input = this.$input || this.$("input");
var l10n = translation._t.database.parameters;
if (!_.str.contains(input.val(), l10n.decimal_point)) {
try {
var caret_pos = input[0].selectionStart;
var selection_end = input[0].selectionEnd;
var cur_val = input.val();
var newval = cur_val.substring(0, caret_pos) + l10n.decimal_point + cur_val.substring(selection_end);
input.val(newval);
input[0].selectionStart = input[0].selectionEnd = caret_pos + 1;
} catch (error) {
//fallback to appending if no caret position can be determined
input.val(input.val() + l10n.decimal_point);
}
}
}
};
return this._super.apply(this, arguments);
}
});
});

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