forked from Techsystech/web
Merge pull request #828 from Tecnativa/11.0-mig-web_decimal_numpad_dot
[MIG] web_decimal_numpad_dot: Migration to 11.011.0
commit
fca3782269
|
@ -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/11.0
|
||||
|
||||
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.
|
|
@ -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": "11.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,
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
|
@ -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 basic_fields = require("web.basic_fields");
|
||||
var translation = require("web.translation");
|
||||
|
||||
basic_fields.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);
|
||||
},
|
||||
});
|
||||
});
|
|
@ -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…
Reference in New Issue