mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[ADD] web_field_numeric_formatting
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import {FloatField} from "@web/views/fields/float/float_field";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(FloatField.prototype, "web_field_numeric_formatting.FloatField", {
|
||||
get formattedValue() {
|
||||
if (!this.props.formatNumber) {
|
||||
return this.props.value;
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
|
||||
Object.assign(FloatField.props, {
|
||||
formatNumber: {type: Boolean, optional: true},
|
||||
});
|
||||
Object.assign(FloatField.defaultProps, {
|
||||
formatNumber: true,
|
||||
});
|
||||
const superExtractProps = FloatField.extractProps;
|
||||
FloatField.extractProps = ({attrs, field}) => {
|
||||
return {
|
||||
...superExtractProps({attrs, field}),
|
||||
formatNumber:
|
||||
attrs.options.enable_formatting === undefined
|
||||
? true
|
||||
: Boolean(attrs.options.enable_formatting),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import {IntegerField} from "@web/views/fields/integer/integer_field";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(IntegerField.prototype, "web_field_numeric_formatting.IntegerField", {
|
||||
get formattedValue() {
|
||||
if (!this.props.formatNumber) {
|
||||
return this.props.value;
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
|
||||
Object.assign(IntegerField.props, {
|
||||
formatNumber: {type: Boolean, optional: true},
|
||||
});
|
||||
Object.assign(IntegerField.defaultProps, {
|
||||
formatNumber: true,
|
||||
});
|
||||
const superExtractProps = IntegerField.extractProps;
|
||||
IntegerField.extractProps = ({attrs}) => {
|
||||
return {
|
||||
...superExtractProps({attrs}),
|
||||
formatNumber:
|
||||
attrs.options.enable_formatting === undefined
|
||||
? true
|
||||
: Boolean(attrs.options.enable_formatting),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import {ListRenderer} from "@web/views/list/list_renderer";
|
||||
import {patch} from "@web/core/utils/patch";
|
||||
|
||||
patch(ListRenderer.prototype, "web_field_numeric_formatting.ListRenderer", {
|
||||
getFormattedValue(column, record) {
|
||||
if (column.options.enable_formatting === false) {
|
||||
return record.data[column.name];
|
||||
}
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user