summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/basic_fields.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
-rw-r--r--addons/web/static/src/js/fields/basic_fields.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js
index f2c44891ea2..4aac42db13b 100644
--- a/addons/web/static/src/js/fields/basic_fields.js
+++ b/addons/web/static/src/js/fields/basic_fields.js
@@ -1325,8 +1325,41 @@ var FieldFloatToggle = AbstractField.extend({
});
var FieldPercentage = FieldFloat.extend({
+ className: 'o_field_float_percentage o_field_number',
description: _lt("Percentage"),
- formatType:'percentage',
+
+ /**
+ * @constructor
+ */
+ init() {
+ this._super(...arguments);
+ if (this.mode === 'edit') {
+ this.tagName = 'div';
+ this.className += ' o_input';
+
+ // do not display % in the input in edit
+ this.formatOptions.noSymbol = true;
+ }
+ },
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * For percentage widget, the input is inside a div, alongside a span
+ * containing the percentage(%) symbol.
+ *
+ * @override
+ * @private
+ */
+ _renderEdit() {
+ this.$el.empty();
+ // Prepare and add the input
+ this._prepareInput(this.$input).appendTo(this.$el);
+ const $percentageSymbol = $('<span>', { text: '%' });
+ this.$el.append($percentageSymbol);
+ },
});
var FieldText = InputField.extend(TranslatableFieldMixin, {