Merge PR #3031 into 18.0

Signed-off-by pedrobaeza
pull/3059/head
OCA-git-bot 2025-01-09 12:29:26 +00:00
commit 335e1d6aa5
23 changed files with 1102 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,163 @@
=======================
Web Widget Numeric Step
=======================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1062d0c26bb10198c524113d70fa069c5928514e9569f607316544fee88bb6d9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/18.0/web_widget_numeric_step
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_widget_numeric_step
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This widget changes input number field and make it easier to increment
the number thanks to 2 buttons (+ and -). Use JS native logic for input
number, so you can use the options ``min``, ``max``, ``step``,
``placeholder``.
Demo available at Settings > Users & Companies > Users > \*Select One\*
> See 'Credit Limit' field
**Table of contents**
.. contents::
:local:
Usage
=====
In your xml view, add ``widget="numeric_step"`` This will add the 2
buttons "+" and "-" just next to the input field in edit mode. Iteration
step by default is 1.
|image1|
**Optional**
Add an option to choose the step iteration and limits (min and max
values).
Example for an 0.25 step, min to -1 and max to 10 :
.. code:: xml
<field name="sale_delay" widget="numeric_step" options="{'step': 0.25, 'min': -1, 'max': 10}" /> days
**Available Options**
- step > Amount to increase/decrease (default: 1.0)
- min > Min. value allowed (default: no limit)
- max > Max. value allowed (default: no limit)
- auto_select > Select the content when the element get focus (default:
False)
- placeholder > Define the placeholder text (default: None)
**Examples**
Iteration with 0.25 step, min to -1 and max to 10.
Start to increment with button, continue incrementing with scrolling
mouse.
|image2|
Iteration with 10 step, max limit 15, placeholder with onchange
|image3|
**Demo**
You can test the feature by going to Settings > Technical > Scheduled
Actions. The field "Execute Every" is configured to use the widget with
2 step, min to 0 and max to 40.
.. |image1| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_widget_numeric_step/static/description/add_two_buttons.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_widget_numeric_step/static/description/step0,25andlimits.gif
.. |image3| image:: https://raw.githubusercontent.com/OCA/web/18.0/web_widget_numeric_step/static/description/step10_limit15_placeholder117_with_onchange.gif
Known issues / Roadmap
======================
When the value is entered using the keyboard, the limits set in the
widget can be exceeded
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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_numeric_step%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
-------
* GRAP
* Tecnativa
Contributors
------------
- `GRAP <http://www.grap.coop>`__:
- Quentin DUPONT <quentin.dupont@grap.coop>
- `Tecnativa <https://www.tecnativa.com/>`__:
- Alexandre Díaz
- Carlos Roca
- Helly kapatel <helly.kapatel@initos.com>
- Thanakrit Pintana <thanakrit.p39@gmail.com>
- Dhara Solanki <dhara.solanki@initos.com>
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.
.. |maintainer-rafaelbn| image:: https://github.com/rafaelbn.png?size=40px
:target: https://github.com/rafaelbn
:alt: rafaelbn
.. |maintainer-yajo| image:: https://github.com/yajo.png?size=40px
:target: https://github.com/yajo
:alt: yajo
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-rafaelbn| |maintainer-yajo|
This module is part of the `OCA/web <https://github.com/OCA/web/tree/18.0/web_widget_numeric_step>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -0,0 +1,22 @@
# Copyright 2019 GRAP - Quentin DUPONT
# Copyright 2020 Tecnativa - Alexandre Díaz
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{
"name": "Web Widget Numeric Step",
"category": "web",
"version": "18.0.1.0.0",
"author": "GRAP, Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/web",
"depends": ["web"],
"demo": ["demo/ir_cron.xml"],
"assets": {
"web.assets_backend": [
"web_widget_numeric_step/static/src/*",
],
},
"maintainers": ["rafaelbn", "yajo"],
"auto_install": False,
"installable": True,
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="ir_cron_view_form" model="ir.ui.view">
<field name="model">ir.cron</field>
<field name="inherit_id" ref="base.ir_cron_view_form" />
<field name="arch" type="xml">
<field name="interval_number" position="attributes">
<attribute name="widget">numeric_step</attribute>
<attribute name="options">{'step': 2, 'min': 0, 'max': 40}</attribute>
</field>
</field>
</record>
</odoo>

View File

@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_numeric_step
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-10-13 20:46+0000\n"
"Last-Translator: Corneliuus <cornelius@clk-it.de>\n"
"Language-Team: none\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#, python-format
msgid "Minus"
msgstr "Minus"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.esm.js:0
#, python-format
msgid "Numeric Step"
msgstr ""
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#, python-format
msgid "Plus"
msgstr "Plus"
#, python-format
#~ msgid "Value"
#~ msgstr "Wert"

View File

@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_numeric_step
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-10-15 20:36+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#, python-format
msgid "Minus"
msgstr "Menos"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.esm.js:0
#, python-format
msgid "Numeric Step"
msgstr "Paso Numérico"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#, python-format
msgid "Plus"
msgstr "Más"
#, python-format
#~ msgid "Value"
#~ msgstr "Valor"

View File

@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_number_ux_choice
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-30 12:07+0000\n"
"PO-Revision-Date: 2019-08-30 12:07+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#, python-format
msgid "Minus"
msgstr "Moins"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.esm.js:0
#, python-format
msgid "Numeric Step"
msgstr ""
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#, python-format
msgid "Plus"
msgstr "Plus"

View File

@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_numeric_step
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-27 11:33+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#, python-format
msgid "Minus"
msgstr "Meno"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.esm.js:0
#, python-format
msgid "Numeric Step"
msgstr "Passo numerico"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#, python-format
msgid "Plus"
msgstr "Più"
#, python-format
#~ msgid "Value"
#~ msgstr "Valore"

View File

@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_numeric_step
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.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"
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#, python-format
msgid "Minus"
msgstr ""
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.esm.js:0
#, python-format
msgid "Numeric Step"
msgstr ""
#. module: web_widget_numeric_step
#. odoo-javascript
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#: code:addons/web_widget_numeric_step/static/src/numeric_step.xml:0
#, python-format
msgid "Plus"
msgstr ""

View File

@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@ -0,0 +1,8 @@
- [GRAP](http://www.grap.coop):
- Quentin DUPONT \<<quentin.dupont@grap.coop>\>
- [Tecnativa](https://www.tecnativa.com/):
- Alexandre Díaz
- Carlos Roca
- Helly kapatel \<<helly.kapatel@initos.com>\>
- Thanakrit Pintana \<<thanakrit.p39@gmail.com>\>
- Dhara Solanki \<<dhara.solanki@initos.com>\>

View File

@ -0,0 +1,6 @@
This widget changes input number field and make it easier to increment
the number thanks to 2 buttons (+ and -). Use JS native logic for input
number, so you can use the options `min`, `max`, `step`, `placeholder`.
Demo available at Settings \> Users & Companies \> Users \> \*Select
One\* \> See 'Credit Limit' field

View File

@ -0,0 +1 @@
When the value is entered using the keyboard, the limits set in the widget can be exceeded

View File

@ -0,0 +1,44 @@
In your xml view, add `widget="numeric_step"` This will add the 2
buttons "+" and "-" just next to the input field in edit mode. Iteration
step by default is 1.
![](../static/description/add_two_buttons.png)
**Optional**
Add an option to choose the step iteration and limits (min and max
values).
Example for an 0.25 step, min to -1 and max to 10 :
``` xml
<field name="sale_delay" widget="numeric_step" options="{'step': 0.25, 'min': -1, 'max': 10}" /> days
```
**Available Options**
- step \> Amount to increase/decrease (default: 1.0)
- min \> Min. value allowed (default: no limit)
- max \> Max. value allowed (default: no limit)
- auto_select \> Select the content when the element get focus (default:
False)
- placeholder \> Define the placeholder text (default: None)
**Examples**
Iteration with 0.25 step, min to -1 and max to 10.
Start to increment with button, continue incrementing with scrolling
mouse.
![](../static/description/step0,25andlimits.gif)
Iteration with 10 step, max limit 15, placeholder with onchange
![](../static/description/step10_limit15_placeholder117_with_onchange.gif)
**Demo**
You can test the feature by going to Settings > Technical > Scheduled Actions. The
field "Execute Every" is configured to use the widget with 2 step, min to 0 and max
to 40.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

View File

@ -0,0 +1,483 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Web Widget Numeric Step</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic, pre.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="web-widget-numeric-step">
<h1 class="title">Web Widget Numeric Step</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1062d0c26bb10198c524113d70fa069c5928514e9569f607316544fee88bb6d9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/18.0/web_widget_numeric_step"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_widget_numeric_step"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This widget changes input number field and make it easier to increment
the number thanks to 2 buttons (+ and -). Use JS native logic for input
number, so you can use the options <tt class="docutils literal">min</tt>, <tt class="docutils literal">max</tt>, <tt class="docutils literal">step</tt>,
<tt class="docutils literal">placeholder</tt>.</p>
<p>Demo available at Settings &gt; Users &amp; Companies &gt; Users &gt; *Select One*
&gt; See Credit Limit field</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-2">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>In your xml view, add <tt class="docutils literal"><span class="pre">widget=&quot;numeric_step&quot;</span></tt> This will add the 2
buttons “+” and “-” just next to the input field in edit mode. Iteration
step by default is 1.</p>
<p><img alt="image1" src="https://raw.githubusercontent.com/OCA/web/18.0/web_widget_numeric_step/static/description/add_two_buttons.png" /></p>
<p><strong>Optional</strong></p>
<p>Add an option to choose the step iteration and limits (min and max
values).</p>
<p>Example for an 0.25 step, min to -1 and max to 10 :</p>
<pre class="code xml literal-block">
<span class="nt">&lt;field</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;sale_delay&quot;</span><span class="w"> </span><span class="na">widget=</span><span class="s">&quot;numeric_step&quot;</span><span class="w"> </span><span class="na">options=</span><span class="s">&quot;{'step': 0.25, 'min': -1, 'max': 10}&quot;</span><span class="w"> </span><span class="nt">/&gt;</span><span class="w"> </span>days
</pre>
<p><strong>Available Options</strong></p>
<ul class="simple">
<li>step &gt; Amount to increase/decrease (default: 1.0)</li>
<li>min &gt; Min. value allowed (default: no limit)</li>
<li>max &gt; Max. value allowed (default: no limit)</li>
<li>auto_select &gt; Select the content when the element get focus (default:
False)</li>
<li>placeholder &gt; Define the placeholder text (default: None)</li>
</ul>
<p><strong>Examples</strong></p>
<p>Iteration with 0.25 step, min to -1 and max to 10.</p>
<p>Start to increment with button, continue incrementing with scrolling
mouse.</p>
<p><img alt="image2" src="https://raw.githubusercontent.com/OCA/web/18.0/web_widget_numeric_step/static/description/step0,25andlimits.gif" /></p>
<p>Iteration with 10 step, max limit 15, placeholder with onchange</p>
<p><img alt="image3" src="https://raw.githubusercontent.com/OCA/web/18.0/web_widget_numeric_step/static/description/step10_limit15_placeholder117_with_onchange.gif" /></p>
<p><strong>Demo</strong></p>
<p>You can test the feature by going to Settings &gt; Technical &gt; Scheduled
Actions. The field “Execute Every” is configured to use the widget with
2 step, min to 0 and max to 40.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
<p>When the value is entered using the keyboard, the limits set in the
widget can be exceeded</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_numeric_step%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>GRAP</li>
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="http://www.grap.coop">GRAP</a>:<ul>
<li>Quentin DUPONT &lt;<a class="reference external" href="mailto:quentin.dupont&#64;grap.coop">quentin.dupont&#64;grap.coop</a>&gt;</li>
</ul>
</li>
<li><a class="reference external" href="https://www.tecnativa.com/">Tecnativa</a>:<ul>
<li>Alexandre Díaz</li>
<li>Carlos Roca</li>
</ul>
</li>
<li>Helly kapatel &lt;<a class="reference external" href="mailto:helly.kapatel&#64;initos.com">helly.kapatel&#64;initos.com</a>&gt;</li>
<li>Thanakrit Pintana &lt;<a class="reference external" href="mailto:thanakrit.p39&#64;gmail.com">thanakrit.p39&#64;gmail.com</a>&gt;</li>
<li>Dhara Solanki &lt;<a class="reference external" href="mailto:dhara.solanki&#64;initos.com">dhara.solanki&#64;initos.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/rafaelbn"><img alt="rafaelbn" src="https://github.com/rafaelbn.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/yajo"><img alt="yajo" src="https://github.com/yajo.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/18.0/web_widget_numeric_step">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

View File

@ -0,0 +1,89 @@
/** @odoo-module */
import {_t} from "@web/core/l10n/translation";
import {registry} from "@web/core/registry";
import {FloatField} from "@web/views/fields/float/float_field";
import {standardFieldProps} from "@web/views/fields/standard_field_props";
export class NumericStep extends FloatField {
setup() {
super.setup();
}
_onStepClick(ev) {
const mode = ev.target.dataset.mode;
this._doStep(mode);
}
_onKeyDown(ev) {
if (ev.keyCode === 38) {
this._doStep("plus");
} else if (ev.keyCode === 40) {
this._doStep("minus");
}
}
_onWheel(ev) {
ev.preventDefault();
if (!this._lastWheelTime) {
this._lastWheelTime = 0;
}
const now = Date.now();
const throttleLimit = 100;
if (now - this._lastWheelTime >= throttleLimit) {
this._lastWheelTime = now;
if (ev.deltaY > 0) {
this._doStep("minus");
} else {
this._doStep("plus");
}
}
}
updateField(val) {
return this.props.record.update({[this.props.name]: val});
}
_doStep(mode) {
let cval = this.props.record.data[this.props.name];
if (mode === "plus") {
cval += this.props.step;
} else if (mode === "minus") {
cval -= this.props.step;
}
if (cval < this.props.min) {
cval = this.props.min;
} else if (cval > this.props.max) {
cval = this.props.max;
}
this.updateField(cval);
}
}
NumericStep.template = "web_widget_numeric_step";
NumericStep.props = {
...standardFieldProps,
inputType: {type: String, optional: true},
step: {type: Number, optional: true},
min: {type: Number, optional: true},
max: {type: Number, optional: true},
placeholder: {type: String, optional: true},
};
NumericStep.defaultProps = {
...FloatField.defaultProps,
inputType: "text",
};
export const numericStep = {
component: NumericStep,
supportedTypes: ["float"],
displayName: _t("Numeric Step"),
extractProps: ({attrs, options}) => {
return {
name: attrs.name,
inputType: attrs.type,
step: options.step || 1,
min: options.min,
max: options.max,
placeholder: attrs.placeholder,
};
},
};
registry.category("fields").add("numeric_step", numericStep);

View File

@ -0,0 +1,22 @@
// Copyright 2023 Moduon Team S.L.
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
.widget_numeric_step {
// Hide the buttons until the user hovers if possible
@media (hover: hover) {
.btn_numeric_step {
visibility: hidden;
}
}
&:hover .btn_numeric_step {
visibility: visible;
}
}
.o_numeric_step_cell {
// Default for old browsers
min-width: 15 * $btn-padding-x;
// Value hardcoded in `FIXED_FIELD_COLUMN_WIDTHS.float` + width of 2
// FontAwesome icons + 2 buttons * 2 horizontal paddings
min-width: calc(92px + 2ex + 4 * #{$btn-padding-x});
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright 2019 GRAP - Quentin DUPONT
Copyright 2020 Tecnativa - Alexandre Díaz
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<template>
<t t-name="web_widget_numeric_step">
<div class="d-flex widget_numeric_step">
<div class="input-group-prepend widget_numeric_step_btn">
<button
class="fa fa-minus btn btn-default btn_numeric_step"
aria-label="Minus"
tabindex="-1"
title="Minus"
type="button"
data-mode="minus"
t-att-disabled="props.readonly"
t-on-click="_onStepClick"
/>
</div>
<input
t-att-id="props.id"
t-ref="numpadDecimal"
t-att-placeholder="props.placeholder"
t-att-type="props.inputType"
class="o_input input_numeric_step"
inputmode="decimal"
t-att-step="props.step"
t-on-keydown="_onKeyDown"
t-on-wheel="_onWheel"
/>
<div class="input-group-append widget_numeric_step_btn">
<button
class="fa fa-plus btn btn-default btn_numeric_step"
aria-label="Plus"
tabindex="-1"
title="Plus"
type="button"
data-mode="plus"
t-att-disabled="props.readonly"
t-on-click="_onStepClick"
/>
</div>
</div>
</t>
</template>