diff options
| author | Michael Mattiello (mcm) <mcm@odoo.com> | 2020-06-08 07:10:08 +0000 |
|---|---|---|
| committer | Michael Mattiello (mcm) <mcm@odoo.com> | 2020-06-15 13:53:21 +0000 |
| commit | 4197ebfabc1329110b18aa4972b5317e739d4dc0 (patch) | |
| tree | a3131e1f6990cbc624c1a3d3438d1a1c21af28c2 /addons/web/static/src/js/fields | |
| parent | beccf82e09d536255d9d9cb9bfe58ebae2559843 (diff) | |
[IMP] web: add options to formatFloatTime
This commit adds noLeadingZeroHour option to formatFloatTime.
The noLeadingZeroHour option can be used to format the value
like 1:30 instead of 01:30
This format behaviour is wanted for fields in web_grid module.
Task 2261853
closes odoo/odoo#52217
Related: odoo/enterprise#10870
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Hardik Prajapati <hap@odoo.com>
Co-authored-by: Mohammed Shekha <msh@openerp.com>
Diffstat (limited to 'addons/web/static/src/js/fields')
| -rw-r--r-- | addons/web/static/src/js/fields/field_utils.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js index 76fda4859e6..681a1eb3672 100644 --- a/addons/web/static/src/js/fields/field_utils.js +++ b/addons/web/static/src/js/fields/field_utils.js @@ -200,10 +200,16 @@ function formatFloatFactor(value, field, options) { * instead of 0.25. * * @param {float} value + * @param {Object} [field] + * a description of the field (note: this parameter is ignored) + * @param {Object} [options] + * @param {boolean} [options.noLeadingZeroHour] if true, format like 1:30 + * otherwise, format like 01:30 * @returns {string} */ -function formatFloatTime(value) { - var pattern = '%02d:%02d'; +function formatFloatTime(value, field, options) { + options = options || {}; + var pattern = options.noLeadingZeroHour ? '%1d:%02d' : '%02d:%02d'; if (value < 0) { value = Math.abs(value); pattern = '-' + pattern; |
