From d67d0caee209ad18f5a1aa5d87109917035f919a Mon Sep 17 00:00:00 2001 From: sum1201 Date: Sat, 3 Feb 2018 00:02:29 +0800 Subject: [FIX] web: translate 'External ID' string Closes #22763 --- addons/web/static/src/js/widgets/data_export.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static') diff --git a/addons/web/static/src/js/widgets/data_export.js b/addons/web/static/src/js/widgets/data_export.js index 4b9f6a29a47..dd0096f269b 100644 --- a/addons/web/static/src/js/widgets/data_export.js +++ b/addons/web/static/src/js/widgets/data_export.js @@ -455,7 +455,7 @@ var DataExport = Dialog.extend({ Dialog.alert(this, _t("Please select fields to export...")); return; } - exported_fields.unshift({name: 'id', label: 'External ID'}); + exported_fields.unshift({name: 'id', label: _t('External ID')}); var export_format = this.$export_format_inputs.filter(':checked').val(); -- cgit v1.2.3 From e710e5df7a88b601f117c84d62930486b1d58415 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Mon, 5 Mar 2018 11:51:19 +0100 Subject: [FIX] web: show error when trying to export a report with more than 256 columns If the user tried to generate a report with more than 256 columns, he would get a traceback instead of an error message. Furthermore, if only one measure was selected, then the check was not done and the user would also get a traceback. opw-1816931 --- addons/web/static/src/js/views/pivot_view.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/web/static') diff --git a/addons/web/static/src/js/views/pivot_view.js b/addons/web/static/src/js/views/pivot_view.js index c874a87665f..40b18fff86c 100644 --- a/addons/web/static/src/js/views/pivot_view.js +++ b/addons/web/static/src/js/views/pivot_view.js @@ -803,7 +803,7 @@ var PivotView = View.extend({ framework.blockUI(); var nbr_measures = this.active_measures.length, headers = this.compute_headers(), - measure_row = nbr_measures > 1 ? _.last(headers) : [], + measure_row = nbr_measures >= 1 ? _.last(headers) : [], rows = this.compute_rows(), i, j, value; headers[0].splice(0,1); @@ -829,7 +829,8 @@ var PivotView = View.extend({ title: this.title, }; if(table.measure_row.length + 1 > 256) { - c.show_message(_t("For Excel compatibility, data cannot be exported if there are more than 256 columns.\n\nTip: try to flip axis, filter further or reduce the number of measures.")); + crash_manager.show_message(_t("For Excel compatibility, data cannot be exported if there are more than 256 columns.\n\nTip: try to flip axis, filter further or reduce the number of measures.")); + framework.unblockUI(); return; } session.get_file({ -- cgit v1.2.3 From 599f6a762e91dd08d093243684183cdb9a3b3513 Mon Sep 17 00:00:00 2001 From: Adrien Dieudonne Date: Mon, 5 Mar 2018 11:20:08 +0100 Subject: [FIX] web: qweb: load template with non-http xhr Since we are able to lazy load Qweb templates, there was an issue to generate Awesome Timesheet iOS native app with Cordova properly. It seems that under Cordova, iOS always returns 0 for the status on a xml http request object. The problem is that native applications are requesting a local file from something that isn't a webserver. The local file is delivered with no http headers that means no "200 OK" header and no "404 Not Found" errors. In this case, the request is still be completing as intended even if the status code used by browsers is 0. For more info, see: https://developer.mozilla.org/fr/docs/Web/API/XMLHttpRequest https://bugzilla.mozilla.org/show_bug.cgi?id=331610 --- addons/web/static/lib/qweb/qweb2.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'addons/web/static') diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js index c4bb7128e9b..94a0afaa32a 100644 --- a/addons/web/static/lib/qweb/qweb2.js +++ b/addons/web/static/lib/qweb/qweb2.js @@ -358,7 +358,12 @@ QWeb2.Engine = (function() { req.open('GET', s, async); if (async) { req.addEventListener("load", function() { - if (req.status == 200) { + // 0, not being a valid HTTP status code, is used by browsers + // to indicate success for a non-http xhr response + // (for example, using the file:// protocol) + // https://developer.mozilla.org/fr/docs/Web/API/XMLHttpRequest + // https://bugzilla.mozilla.org/show_bug.cgi?id=331610 + if (req.status == 200 || req.status == 0) { callback(null, self._parse_from_request(req)); } else { callback(new Error("Can't load template " + s + ", http status " + req.status)); -- cgit v1.2.3 From b771dd8a5cb9fdc37b9ed3e071c00ac9404d9074 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 1 Mar 2018 16:37:59 +0100 Subject: [FIX] web: Impossible to delete a line in a tree view When creating a record in a form view of model A, and adding a line in an inside tree view of model B(with a One2Many from A to B), it was impossible to delete a wrong line even if the record has not been saved because the user had no right to delete a record on model B. opw:1819099 --- addons/web/static/src/xml/base.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static') diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index d76dd44f469..76230befea5 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -381,7 +381,8 @@ t-att-data-field="column.id" > - + + -- cgit v1.2.3 From b466b3bc608b54d96ca0242b4d9c6176b76d88b6 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 1 Mar 2018 13:32:22 +0100 Subject: [FIX] web: create favorite filters in dialogs Consider the following scenario: open in edit mode a form view containing a many2many field displayed with widget many2many_tags, on the many2many field dropdown, click on 'Search More' (it opens a dialog), and in the dialog, try to save the current search in the searchview's favorite menu. Before this rev., it tried to retrieve the context of the active view in the closest instance of a ViewManager-like widget in the SearchView's ancestors. First, it is wrong as in the given scenario, the requested context is actually the one of the list controller in the dialog, not the one of the form controller in the background. Second, it produces a crash in Studio, when trying to save filters in the dialog opened by clicking on 'Search More' on the groups many2many field in the sidebar. This part of the code can't be tested in this version, but tests will be added in master. Fixes #23293 --- addons/web/static/src/js/view_manager.js | 22 ++++++++++++++++++++++ addons/web/static/src/js/views/form_common.js | 20 ++++++++++++++++++++ addons/web/static/src/js/views/search_menus.js | 16 +++++++++------- 3 files changed, 51 insertions(+), 7 deletions(-) (limited to 'addons/web/static') diff --git a/addons/web/static/src/js/view_manager.js b/addons/web/static/src/js/view_manager.js index a351a813263..490b2d5cfba 100644 --- a/addons/web/static/src/js/view_manager.js +++ b/addons/web/static/src/js/view_manager.js @@ -15,6 +15,9 @@ var _t = core._t; var ViewManager = Widget.extend(ControlPanelMixin, { className: "o_view_manager_content", + custom_events: { + get_controller_context: '_onGetControllerContext', + }, /** * Called each time the view manager is attached into the DOM */ @@ -474,6 +477,25 @@ var ViewManager = Widget.extend(ControlPanelMixin, { } return this._super.apply(this, arguments); }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + // ONLY FORWARDPORT THIS COMMIT UP TO SAAS-15 + /** + * Handles a context request: provides to the caller the context of the + * active view. + * + * @private + * @param {OdooEvent} ev + * @param {function} ev.data.callback used to send the requested context + */ + _onGetControllerContext: function (ev) { + var controller = this.active_view && this.active_view.controller; + var context = controller && controller.get_context(); + ev.data.callback(context); + }, }); return ViewManager; diff --git a/addons/web/static/src/js/views/form_common.js b/addons/web/static/src/js/views/form_common.js index 16e8c088368..f5853475231 100644 --- a/addons/web/static/src/js/views/form_common.js +++ b/addons/web/static/src/js/views/form_common.js @@ -976,6 +976,9 @@ var SelectCreateListView = ListView.extend({ * Search dialog (displays a list of records and permits to create a new one by switching to a form view) */ var SelectCreateDialog = ViewDialog.extend({ + custom_events: { + get_controller_context: '_onGetControllerContext', + }, /** * options: * - initial_ids @@ -1106,6 +1109,23 @@ var SelectCreateDialog = ViewDialog.extend({ return new FormViewDialog(this.__parentedParent, this.options).open(); }, on_view_list_loaded: function() {}, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * Handles a context request: provides to the caller the context of the + * list view. + * + * @private + * @param {OdooEvent} ev + * @param {function} ev.data.callback used to send the requested context + */ + _onGetControllerContext: function (ev) { + var context = this.view_list.get_context(); + ev.data.callback(context); + }, }); var DomainEditorDialog = SelectCreateDialog.extend({ diff --git a/addons/web/static/src/js/views/search_menus.js b/addons/web/static/src/js/views/search_menus.js index a8ce7274256..6c7069312aa 100644 --- a/addons/web/static/src/js/views/search_menus.js +++ b/addons/web/static/src/js/views/search_menus.js @@ -93,13 +93,15 @@ return Widget.extend({ this.$inputs.first().focus(); return; } - var search = this.searchview.build_search_data(), - view_manager = this.findAncestor(function (a) { - // HORRIBLE HACK. PLEASE SAVE ME FROM MYSELF (BUT IN A PAINLESS WAY IF POSSIBLE) - return 'active_view' in a; - }), - view_context = view_manager ? view_manager.active_view.controller.get_context() : {}, - results = pyeval.sync_eval_domains_and_contexts({ + var search = this.searchview.build_search_data(); + // ONLY FORWARDPORT THIS COMMIT UP TO SAAS-15 + var view_context; + this.trigger_up('get_controller_context', { + callback: function (ctx) { + view_context = ctx; + }, + }); + var results = pyeval.sync_eval_domains_and_contexts({ domains: search.domains, contexts: search.contexts.concat(view_context || []), group_by_seq: search.groupbys || [], -- cgit v1.2.3 From 16a27c94e01aa383fea9a14089668233f676692a Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 28 Feb 2018 14:15:06 +0100 Subject: [FIX] web: create favorite filters in dialogs This is a manual forwardport of rev. b466b3bc. Consider the following scenario: open in edit mode a form view containing a many2many field displayed with widget many2many_tags, on the many2many field dropdown, click on 'Search More' (it opens a dialog), and in the dialog, try to save the current search in the searchview's favorite menu. Before this rev., it tried to retrieve the context of the active controller in the closest instance of a ViewManager-like widget in the SearchView's ancestors. First, it is wrong as in the given scenario, the requested context is actually the one of the list controller in the dialog, not the one of the form controller in the background. Second, it produces a crash in Studio, when trying to save filters in the dialog opened by clicking on 'Search More' on the groups many2many field in the sidebar. This part of the code can't be tested in this version, but tests will be added in master. Fixes #23293 --- addons/web/static/src/js/chrome/search_menus.js | 14 ++++++++------ addons/web/static/src/js/chrome/view_manager.js | 16 ++++++++++++++++ addons/web/static/src/js/views/view_dialogs.js | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) (limited to 'addons/web/static') diff --git a/addons/web/static/src/js/chrome/search_menus.js b/addons/web/static/src/js/chrome/search_menus.js index fe2ce5f3c32..d41052c882e 100644 --- a/addons/web/static/src/js/chrome/search_menus.js +++ b/addons/web/static/src/js/chrome/search_menus.js @@ -96,14 +96,16 @@ return Widget.extend({ } var user_context = this.getSession().user_context; var search = this.searchview.build_search_data(); - var view_manager = this.findAncestor(function (a) { - // HORRIBLE HACK. PLEASE SAVE ME FROM MYSELF (BUT IN A PAINLESS WAY IF POSSIBLE) - return 'active_view' in a; - }); - var view_context = view_manager ? view_manager.active_view.controller.getContext() : {}; + // DO NOT FORWARDPORT THIS + var controllerContext; + this.trigger_up('get_controller_context', { + callback: function (ctx) { + controllerContext = ctx; + }, + }); var results = pyeval.eval_domains_and_contexts({ domains: search.domains, - contexts: [user_context].concat(search.contexts.concat(view_context || [])), + contexts: [user_context].concat(search.contexts.concat(controllerContext || [])), group_by_seq: search.groupbys || [], }); if (!_.isEmpty(results.group_by)) { diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js index 3f3cec9ec7f..6e44bb8ad63 100644 --- a/addons/web/static/src/js/chrome/view_manager.js +++ b/addons/web/static/src/js/chrome/view_manager.js @@ -46,6 +46,7 @@ var ViewManager = Widget.extend(ControlPanelMixin, { push_state: function(event) { this.do_push_state(event.data); }, + get_controller_context: '_onGetControllerContext', switch_to_previous_view: '_onSwitchToPreviousView', }, /** @@ -631,6 +632,21 @@ var ViewManager = Widget.extend(ControlPanelMixin, { // Handlers //-------------------------------------------------------------------------- + // DO NOT FORWARDPORT THIS + /** + * Handles a context request: provides to the caller the context of the + * active controller. + * + * @private + * @param {OdooEvent} ev + * @param {function} ev.data.callback used to send the requested context + */ + _onGetControllerContext: function (ev) { + ev.stopPropagation(); + var controller = this.active_view && this.active_view.controller; + var context = controller && controller.getContext(); + ev.data.callback(context); + }, /** * This handler is probably called by a sub form view when the user discards * its value. The usual result of this is that we switch back to the diff --git a/addons/web/static/src/js/views/view_dialogs.js b/addons/web/static/src/js/views/view_dialogs.js index a33f6f740b8..6f62483a81c 100644 --- a/addons/web/static/src/js/views/view_dialogs.js +++ b/addons/web/static/src/js/views/view_dialogs.js @@ -262,6 +262,7 @@ var SelectCreateDialog = ViewDialog.extend({ var searchData = this._process_search_data(d.domains, d.contexts, d.groupbys); this.list_controller.reload(searchData); }, + get_controller_context: '_onGetControllerContext', }), /** @@ -418,6 +419,24 @@ var SelectCreateDialog = ViewDialog.extend({ dialog.on('closed', this, this.close); return dialog; }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * Handles a context request: provides to the caller the context of the + * list controller. + * + * @private + * @param {OdooEvent} ev + * @param {function} ev.data.callback used to send the requested context + */ + _onGetControllerContext: function (ev) { + ev.stopPropagation(); + var context = this.list_controller.getContext(); + ev.data.callback(context); + }, }); return { -- cgit v1.2.3 From b7b8634575f3720593f5ad05d9dc828fb5b4d943 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 7 Mar 2018 11:40:25 +0100 Subject: [FIX] web: statusbar buttons design when no statusbar status When there were no status widget in the form view statusbar, the left buttons appeared without any vertical space around them in a smaller statusbar. There also was a 1px mistake that made the buttons appear non-centered. Now they appear centered in any case and a row of buttons is always forcing the correct statusbar height. Closes https://github.com/odoo/odoo/pull/22053 opw-(1)813479 --- addons/web/static/src/less/form_view.less | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/web/static') diff --git a/addons/web/static/src/less/form_view.less b/addons/web/static/src/less/form_view.less index cd9d550843a..ceff30ee4c2 100644 --- a/addons/web/static/src/less/form_view.less +++ b/addons/web/static/src/less/form_view.less @@ -165,7 +165,9 @@ .o-flex-flow(row, wrap); > .btn { - margin-right: 3px; + @o-statusbar-buttons-vmargin: 4px; + min-height: @odoo-statusbar-height - 2 * @o-statusbar-buttons-vmargin; + margin: @o-statusbar-buttons-vmargin 3px @o-statusbar-buttons-vmargin 0; padding-top: 2px; padding-bottom: 2px; } -- cgit v1.2.3