[ADD] web_field_numeric_formatting

This commit is contained in:
Stefan Rijnhart
2023-08-08 07:26:50 +02:00
parent 81e0ce57b2
commit a08c406f37
12 changed files with 820 additions and 0 deletions

View File

@@ -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),
};
};

View File

@@ -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),
};
};

View File

@@ -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);
},
});