From 178873d4337148e75041c61c9cd1862edaafa37d Mon Sep 17 00:00:00 2001 From: Khoi Nguyen Date: Mon, 14 Aug 2017 14:53:44 +0200 Subject: [FIX] web: fix copy (Ctrl-C) of text field content in Firefox Before this commit, it was not possible to copy the contents of a multiline text field in read-only mode in Firefox without losing all line breaks in the process. This is due to a bug affecting div tags (see https://bugzilla.mozilla.org/show_bug.cgi?id=1390115) in Firefox. This commit ensures that the text in a text field is surrounded by a span (as opposed to div) tag. Note that spans were used in saas-15, so we are in fact simply undoing the change to divs introduced by the new views. --- addons/web/static/src/js/fields/basic_fields.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 0cb08b55d02..ec04f67e270 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -791,6 +791,7 @@ var FieldFloatTime = FieldFloat.extend({ var FieldText = InputField.extend(TranslatableFieldMixin, { className: 'o_field_text', supportedFieldTypes: ['text'], + tagName: 'span', /** * @constructor -- cgit v1.2.3 From f5b7ad80fcfd1638cb7ea019a38871c3b8438e36 Mon Sep 17 00:00:00 2001 From: Adrien Dieudonne Date: Wed, 16 Aug 2017 14:49:08 +0200 Subject: [FIX] web: always use browser timezone With the new views, we stopped using the browser timezone to display the dates in Odoo, and we used the timezone defined on the User profile instead. When loading the webclient, the timezone offset was put into the session and used to display all dates. This wasn't a good idea. The given offset was computed for the current time, meaning that it may be incorrect for specific dates (e.g. with the daylight saving, the UTC offset of today is not the same as 6 months ago). Moreover (but less likely), as the offset was stored in the session, it wasn't recalculated afterwards. So if the offset actually changed during the session (e.g. from or to daylight saving time), the displayed dates were incorrect until the user reloaded the page. With this rev., we don't retrieve the offset from the server anymore and we use the browser timezone again (like before the new views). However, we keep the computation of the offset (on the fly) in the session, so that it can be mocked in the test environment. --- addons/web/static/src/js/fields/basic_fields.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index ec04f67e270..035d24dbdf2 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -450,7 +450,7 @@ var FieldDateTime = FieldDate.extend({ */ _getValue: function () { var value = this.datewidget.getValue(); - return value && value.add(-this.getSession().tzOffset, 'minutes'); + return value && value.add(-this.getSession().getTZOffset(value), 'minutes'); }, /** @@ -460,7 +460,7 @@ var FieldDateTime = FieldDate.extend({ * @private */ _makeDatePicker: function () { - var value = this.value && this.value.clone().add(this.getSession().tzOffset, 'minutes'); + var value = this.value && this.value.clone().add(this.getSession().getTZOffset(this.value), 'minutes'); return new datepicker.DateTimeWidget(this, {defaultDate: value}); }, @@ -471,7 +471,7 @@ var FieldDateTime = FieldDate.extend({ * @private */ _renderEdit: function () { - var value = this.value && this.value.clone().add(this.getSession().tzOffset, 'minutes'); + var value = this.value && this.value.clone().add(this.getSession().getTZOffset(this.value), 'minutes'); this.datewidget.setValue(value); this.$input = this.datewidget.$input; }, -- cgit v1.2.3 From 0966f75b7e874bab69173918cbaf38cf031c21bd Mon Sep 17 00:00:00 2001 From: Richard Mathot Date: Fri, 18 Aug 2017 10:55:09 +0200 Subject: [FIX] web: enforce length-limited char fields In Odoo 10.0, `Char` fields with a maximum `size=` attribute were indeed limited in the web client. --- addons/web/static/src/js/fields/basic_fields.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'addons/web/static/src/js/fields/basic_fields.js') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 035d24dbdf2..c69ca8bd2e8 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -341,6 +341,9 @@ var FieldChar = InputField.extend(TranslatableFieldMixin, { */ _renderEdit: function () { var def = this._super.apply(this, arguments); + if (this.field.size && this.field.size > 0) { + this.$el.attr('maxlength', this.field.size); + } this.$el = this.$el.add(this._renderTranslateButton()); return def; }, -- cgit v1.2.3