From 1daa3d0b271bf1df6bde51e9dd632f27c39f7c6e Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 31 Jul 2023 14:42:45 +0000 Subject: [PATCH] [REF] hr_holidays: convert float_without_trailing_zeros to owl This field has been introduced as a fix in 15.0 [1] where views were still legacy, and it hasn't been adapted in the forwardport. So this commit converts it to owl as the support for legacy fields is about to be dropped. Part of task~3439226 [1] odoo/odoo#112520 Part-of: odoo/odoo#130462 --- .../src/js/float_without_trailing_zeros.js | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/addons/hr_holidays/static/src/js/float_without_trailing_zeros.js b/addons/hr_holidays/static/src/js/float_without_trailing_zeros.js index fc8d6578c02..01906ffea5b 100644 --- a/addons/hr_holidays/static/src/js/float_without_trailing_zeros.js +++ b/addons/hr_holidays/static/src/js/float_without_trailing_zeros.js @@ -1,17 +1,16 @@ /** @odoo-module **/ -import FieldRegistry from '@web/legacy/js/fields/field_registry'; -import basic_fields from '@web/legacy/js/fields/basic_fields'; -var FieldFloat = basic_fields.FieldFloat; +import { registry } from "@web/core/registry"; +import { floatField, FloatField } from "@web/views/fields/float/float_field"; -var FloatWithoutTrailingZeros = FieldFloat.extend({ - _renderReadonly: function () { - var value = this._formatValue(this.value); - var parsed_value = parseFloat(value); - value = parsed_value.toString().replace(/\.0+$/, ''); - this.$el.text(value); +const fieldRegistry = registry.category("fields"); + +class FloatWithoutTrailingZeros extends FloatField { + get formattedValue() { + return super.formattedValue.replace(/\.0+$/, ''); } -}); +} -FieldRegistry.add('float_without_trailing_zeros', FloatWithoutTrailingZeros); +const floatWithoutTrailingZeros = { ...floatField, component: FloatWithoutTrailingZeros }; +fieldRegistry.add("float_without_trailing_zeros", floatWithoutTrailingZeros);