From e61639723d715bfde89c6b55f34601b2449234a6 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 21 May 2019 14:57:32 +0000 Subject: [FIX] web: resequence work w/ discardable lines In 11.0 091c86c21 introduced the unselection of lines when line are resequenced to solve some issue. There seems to be a related issue in the following use case if: - the one2many has a handle field - the lines have same sequence (eg. adding 2 o2m lines on new record) - there is an invalid o2m line (eg. empty line and required field) - without blurring, a valid line is moved then this happen: - the sequence of lines are computed - the invalid line is removed - the computed sequence of lines are applied => this break next onchange, because we try to apply an onchange to data that does not exist anymore (the invalid line). With this changeset, the invalid lines are discarded before sequences are computed so the computation is still correct before being applied. Without the change, the added test fails with: 5. one onchange happens when lines are resequenced (expect: 3, res: 2) 7. one onchange happens when a line is added (expect: 4, res: 2) 8. onchange worked there is 2 lines (expect: 2, res: 1) opw-1966589 closes #33591 Signed-off-by: Aaron Bohy (aab) --- .../src/js/views/list/list_editable_renderer.js | 74 +++++++++++----------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js index f5cb3a2c732..7a4147f540b 100644 --- a/addons/web/static/src/js/views/list/list_editable_renderer.js +++ b/addons/web/static/src/js/views/list/list_editable_renderer.js @@ -549,48 +549,48 @@ ListRenderer.include({ _resequence: function (event, ui) { var self = this; var movedRecordID = ui.item.data('id'); - var rows = this.state.data; - var row = _.findWhere(rows, {id: movedRecordID}); - var index0 = rows.indexOf(row); - var index1 = ui.item.index(); - var lower = Math.min(index0, index1); - var upper = Math.max(index0, index1) + 1; - - var order = _.findWhere(self.state.orderedBy, {name: self.handleField}); - var asc = !order || order.asc; - var reorderAll = false; - var sequence = (asc ? -1 : 1) * Infinity; - - // determine if we need to reorder all lines - _.each(rows, function (row, index) { - if ((index < lower || index >= upper) && - ((asc && sequence >= row.data[self.handleField]) || - (!asc && sequence <= row.data[self.handleField]))) { - reorderAll = true; - } - sequence = row.data[self.handleField]; - }); + self.unselectRow().then(function () { + var rows = self.state.data; + var row = _.findWhere(rows, {id: movedRecordID}); + var index0 = rows.indexOf(row); + var index1 = ui.item.index(); + var lower = Math.min(index0, index1); + var upper = Math.max(index0, index1) + 1; + + var order = _.findWhere(self.state.orderedBy, {name: self.handleField}); + var asc = !order || order.asc; + var reorderAll = false; + var sequence = (asc ? -1 : 1) * Infinity; + + // determine if we need to reorder all lines + _.each(rows, function (row, index) { + if ((index < lower || index >= upper) && + ((asc && sequence >= row.data[self.handleField]) || + (!asc && sequence <= row.data[self.handleField]))) { + reorderAll = true; + } + sequence = row.data[self.handleField]; + }); - if (reorderAll) { - rows = _.without(rows, row); - rows.splice(index1, 0, row); - } else { - rows = rows.slice(lower, upper); - rows = _.without(rows, row); - if (index0 > index1) { - rows.unshift(row); + if (reorderAll) { + rows = _.without(rows, row); + rows.splice(index1, 0, row); } else { - rows.push(row); + rows = rows.slice(lower, upper); + rows = _.without(rows, row); + if (index0 > index1) { + rows.unshift(row); + } else { + rows.push(row); + } } - } - var sequences = _.pluck(_.pluck(rows, 'data'), self.handleField); - var rowIDs = _.pluck(rows, 'id'); + var sequences = _.pluck(_.pluck(rows, 'data'), self.handleField); + var rowIDs = _.pluck(rows, 'id'); - if (!asc) { - rowIDs.reverse(); - } - this.unselectRow().then(function () { + if (!asc) { + rowIDs.reverse(); + } self.trigger_up('resequence', { rowIDs: rowIDs, offset: _.min(sequences), -- cgit v1.2.3 From 5adb6b62d22c49261d5b1aaeb1e9f15e40c074ae Mon Sep 17 00:00:00 2001 From: Priyanka Kakadiya Date: Wed, 22 May 2019 12:55:27 +0000 Subject: [FIX] web: update buttons in editable list In an editable view when editing a row, then apply or remove any groupby or filter the control panel buttons are not updated. When record is in edit mode in editable listview and applying groupby then control panel buttons 'Save' and 'Discard' buttons are always displaying, this issue occurs because when applying or removing filters control panel buttons not updated i.e. _updateButtons not called. With this commit button are updated when _update of list controller is called, _update of list controller is also called from search. Task-1967278 closes odoo/odoo#33572 Signed-off-by: VincentSchippefilt --- addons/web/static/src/js/views/list/list_controller.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js index df23fffa54c..b638f51c4df 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -326,8 +326,9 @@ var ListController = BasicController.extend({ * @returns {Deferred} */ _update: function () { - this._toggleSidebar(); - return this._super.apply(this, arguments); + return this._super.apply(this, arguments) + .then(this._toggleSidebar.bind(this)) + .then(this._updateButtons.bind(this, 'readonly')); }, /** * This helper simply makes sure that the control panel buttons matches the -- cgit v1.2.3 From 886967766965f7781d8b7c5d87d8505bb6881747 Mon Sep 17 00:00:00 2001 From: Grzegorz Krukar Date: Thu, 23 May 2019 07:36:10 +0000 Subject: [FIX] web: form: remove invisible fields spacing Invisible fields in form view and group reserve space. This looks bad with many invisible fields in a form. Fixes: #29505 and #28370 closes odoo/odoo#33598 Signed-off-by: Quentin Smetz (qsm) --- addons/web/static/src/less/form_view_extra.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/less/form_view_extra.less b/addons/web/static/src/less/form_view_extra.less index b90d39ed1e0..2f945ca693a 100644 --- a/addons/web/static/src/less/form_view_extra.less +++ b/addons/web/static/src/less/form_view_extra.less @@ -132,7 +132,7 @@ border-right: 1px solid #ddd; } .o_td_label + td { - padding: 2px 36px 2px 8px; + padding: 0px 36px 0px 8px; } .o_field_widget.o_text_overflow { width: 1px!important; // hack to make the table layout believe it is a small element (so that the table does not grow too much) ... -- cgit v1.2.3 From 042966ccae3270a1119c4c5dcb095753cd6b784f Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Fri, 24 May 2019 13:37:20 +0000 Subject: [IMP] web: better logging of errors When an error is raised server-side, the complete traceback is displayed in the JS console. This traceback can be very useful since it might contain information not recorded anywhere else by default. For example, access errors due to record rules or SQL constrains do not have their traceback displayed in the UI or recorded in the log [1], but it is logged in the JS console. However, the information is logged in the JS console as a stringified version of the `result.error` object. The final result is a long and non-formatted string which is unreadable. We replace by a new format more convenient for technical teams. The error is now formatted as: Error code Error message Error data message Error data debug This will hopefully give a better starting point for debugging purposes. [1] SQL constrains tracebacks are only recorded in the log in debug mode: https://github.com/odoo/odoo/blob/ec792da72b92b22349b6f325e53fd37d953c7db3/odoo/service/model.py#L122 closes odoo/odoo#33650 Signed-off-by: Nicolas Martinelli (nim) --- addons/web/static/src/js/core/ajax.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/core/ajax.js b/addons/web/static/src/js/core/ajax.js index f1f73bb5a28..cbd02e0755e 100644 --- a/addons/web/static/src/js/core/ajax.js +++ b/addons/web/static/src/js/core/ajax.js @@ -22,7 +22,13 @@ function genericJsonRpc (fct_name, params, settings, fct) { core.bus.trigger('rpc:result', data, result); if (result.error !== undefined) { if (result.error.data.arguments[0] !== "bus.Bus not available in test mode") { - console.error("Server application error", JSON.stringify(result.error)); + console.error( + "Server application error\n", + "Error code:", result.error.code, "\n", + "Error message:", result.error.message, "\n", + "Error data message:\n", result.error.data.message, "\n", + "Error data debug:\n", result.error.data.debug + ); } return $.Deferred().reject("server", result.error); } else { -- cgit v1.2.3 From 0379c51be36ab102ff38582abb8ac5784b2ff9a6 Mon Sep 17 00:00:00 2001 From: Luis Date: Mon, 29 Apr 2019 19:58:16 +0000 Subject: [FIX] web: refresh calendar if error If an error is raised when saving a calendar event, the transaction is correctly rolled back. However, the view is not refreshed and the incorrect information is displayed. We simply reload in all cases. opw-2002186 closes odoo/odoo#33028 Signed-off-by: Nicolas Martinelli (nim) --- addons/web/static/src/js/views/calendar/calendar_controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/calendar/calendar_controller.js b/addons/web/static/src/js/views/calendar/calendar_controller.js index d79f26ffcd2..ae87aaaf47e 100644 --- a/addons/web/static/src/js/views/calendar/calendar_controller.js +++ b/addons/web/static/src/js/views/calendar/calendar_controller.js @@ -103,7 +103,7 @@ var CalendarController = AbstractController.extend({ * @returns {Deferred} */ _updateRecord: function (record) { - return this.model.updateRecord(record).then(this.reload.bind(this)); + return this.model.updateRecord(record).always(this.reload.bind(this)); }, //-------------------------------------------------------------------------- -- cgit v1.2.3 From e9350993ca0b81df17308766d7e26d458bc39520 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Mon, 27 May 2019 10:41:48 +0000 Subject: [FIX] web: restore /apps/ controller Since JS refactoring of ActionManager at 32b8cec536, the /apps/ controller was not working anymore as the refactoring dropped the support of `sa` as URL state. closes odoo/odoo#33679 Signed-off-by: Aaron Bohy (aab) --- .../src/js/chrome/action_manager_act_window.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/chrome/action_manager_act_window.js b/addons/web/static/src/js/chrome/action_manager_act_window.js index f644d8cc821..979a5ecfa1d 100644 --- a/addons/web/static/src/js/chrome/action_manager_act_window.js +++ b/addons/web/static/src/js/chrome/action_manager_act_window.js @@ -47,7 +47,10 @@ ActionManager.include({ * @param {string} [state.view_type] */ loadState: function (state) { + var callersArguments = arguments; + var self = this; var action; + var def; var options = { clear_breadcrumbs: true, pushState: false, @@ -102,11 +105,20 @@ ActionManager.include({ action = lastAction; options.viewType = state.view_type; } + } else if (state.sa) { + def = this._rpc({ + route: '/web/session/get_session_action', + params: {key: state.sa}, + }).then(function (sessionAction) { + action = sessionAction; + }); } - if (action) { - return this.doAction(action, options); - } - return this._super.apply(this, arguments); + return $.when(def).then(function () { + if (action) { + return self.doAction(action, options); + } + return self._super.apply(self, callersArguments); + }); }, //-------------------------------------------------------------------------- -- cgit v1.2.3