From 2471ee506f38f5ca54d7bd54084b0ac3d74abeae Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 20 Sep 2019 12:46:07 +0000 Subject: [FIX] web: translate html fields This commit fixes: - body of a email.template in a small field - translation of website_description of a product does not show the source of the translation - translation of website_description of a product shows the full content for the current language HTML fields are typically fields with longer of content. If the field is an HTML field, it should be displayed in a textarea, like the text fields. Most of HTML fields are split in meaningful chunks of content (using xml_translate or html_translate method). For these fields, the source must be displayed. Also sort the entries on the source to have a consistent order closes odoo/odoo#37215 Signed-off-by: Martin Trigaux (mat) --- addons/web/static/src/js/views/basic/basic_controller.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/basic/basic_controller.js') diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index be0b9a00bf3..21ce85ce025 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -833,7 +833,8 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { userLanguageValue: ev.target.value || '', dataPointID: record.id, isComingFromTranslationAlert: ev.data.isComingFromTranslationAlert, - isText: record.fields[ev.data.fieldName].type === 'text', + isText: result.context.translation_type === 'text', + showSrc: result.context.translation_show_src, }); return this.translationDialog.open(); }, -- cgit v1.2.3 From a7a60f7c61275f26521cbc4ea0da2889095a5cc5 Mon Sep 17 00:00:00 2001 From: Mathieu Duckerts-Antoine Date: Mon, 23 Sep 2019 12:24:47 +0000 Subject: [FIX] web: avoid multiple displays of the "same" discard warning Before this commit, editing a record e.g. in a form view and toggling the home menu would cause the discard warning to be displayed twice when going to the home menu (in enterprise) and then once again when going to an other app. This is now fixed. Task ID: 2043027 closes odoo/odoo#37301 Signed-off-by: VincentSchippefilt Co-authored-by: Mohammed Shekha Co-authored-by: aab-odoo --- addons/web/static/src/js/views/basic/basic_controller.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/basic/basic_controller.js') diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 9e9e7559ede..c82bf05996b 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -382,10 +382,13 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { options = options || {}; return this.canBeDiscarded(recordID) .then(function (needDiscard) { - if (options.noAbandon || (options.readonlyIfRealDiscard && !needDiscard)) { + if (options.readonlyIfRealDiscard && !needDiscard) { return; } self.model.discardChanges(recordID); + if (options.noAbandon) { + return; + } if (self.model.canBeAbandoned(recordID)) { self._abandonRecord(recordID); return; -- cgit v1.2.3 From da2b24714616bfbaf3ed7834844618207ec6ca2c Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Mon, 30 Sep 2019 09:57:21 +0000 Subject: [FIX] web: m2o updates its value after reload Changes the behaviour of many2ones when their value is changed via a form dialog. Before this commit, when editing a m2o with a form dialog opened by an external button, the field triggered an onchange with its old value before reloading its widget. This caused the edition in list views to display outdated information when saving multiple records. Now, the reload is executed first, then the onchange occurs so that the value is the newly updated one. Part of task 2078807 closes odoo/odoo#37576 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/views/basic/basic_controller.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_controller.js') diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index df1a03e0f42..7639d2dea99 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -705,21 +705,25 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { * re-render (reload the whole form by default) * @param {string[]} [ev.data.fieldNames] list of the record's fields to * reload + * @param {Function} [ev.data.onSuccess] callback executed after reload is resolved + * @param {Function} [ev.data.onFailure] callback executed when reload is rejected */ _onReload: function (ev) { ev.stopPropagation(); // prevent other controllers from handling this request var data = ev && ev.data || {}; var handle = data.db_id; + var prom; if (handle) { // reload the relational field given its db_id - this.model.reload(handle).then(this._confirmSave.bind(this, handle)); + prom = this.model.reload(handle).then(this._confirmSave.bind(this, handle)); } else { // no db_id given, so reload the main record - this.reload({ + prom = this.reload({ fieldNames: data.fieldNames, keepChanges: data.keepChanges || false, }); } + prom.then(ev.data.onSuccess).guardedCatch(ev.data.onFailure); }, /** * Resequence records in the given order. -- cgit v1.2.3