[IMP] web: float_factor and float_toggle widgets

This commit provides new js widgets for list, kanban and form
views on float field.

1/ 'float_factor' displays the normal float field, but takes a
conversion factor as option. The displays value is the normal
one multiplied by the factor.

You can use the widget like
<field name="my_float_field" widget="float_factor"
option="{'factor': 2}"/>

2/ 'float_toggle' displays a button (in edit mode) looping on a
range of given value at each click. A conversion factor is optional
(default will be 1) to display a converted value, but sent to
non converted one to the server.

You can use the widget like
<field name="my_float" widget="float_toggle"
option="{'range': [0, 0.5, 1], 'factor': 2}"/>

'range' and 'factor' are put in the options.
In simple read mode, the widget display the value as a traditionnal
text (like a normal char field).

This commit provides tests and documentation for those 2 widgets.

Task #39079
This commit is contained in:
jem-odoo
2018-08-13 14:33:48 +02:00
parent 6b4062ea63
commit 1f72644c44
7 changed files with 299 additions and 1 deletions
+20
View File
@@ -1418,6 +1418,26 @@ order.
- Supported field types: *float*
- float_factor (FieldFloatFactor)
This widget aims to display properly a float value that converted using a factor
given in its options. So, for example, the value saved in database is 0.5 and the
factor is 3, the widget value should be formatted as 1.5.
- Supported field types: *float*
- float_toggle (FieldFloatToggle)
The goal of this widget is to replace the input field by a button containing a
range of possible values (given in the options). Each click allows the user to loop
in the range. The purpose here is to restrict the field value to a predefined selection.
Also, the widget support the factor conversion as the *float_factor* widget (Range values
should be the result of the conversion).
- Supported field types: *float*
.. code-block:: xml
<field name="days_to_close" widget="float_toggle" options='{"factor": 2, "range": [0, 4, 8]}'/>
- boolean (FieldBoolean)
This is the default field type for fields of type *boolean*.