[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
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user