From 7766b89aa04f31c086f9e967965b2ff3d8d10410 Mon Sep 17 00:00:00 2001 From: Nimesh Jethva Date: Thu, 6 Sep 2018 08:43:32 +0000 Subject: [FIX] web: restore kanban progressbar animation With BS4 migration, the progressbar 'active' class should have been renamed 'progress-bar-animated'. closes odoo/odoo#26868 Signed-off-by: Quentin Smetz (qsm) --- addons/web/static/src/js/views/kanban/kanban_column_progressbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/kanban/kanban_column_progressbar.js b/addons/web/static/src/js/views/kanban/kanban_column_progressbar.js index 59f09bc9bb6..4a572739daf 100644 --- a/addons/web/static/src/js/views/kanban/kanban_column_progressbar.js +++ b/addons/web/static/src/js/views/kanban/kanban_column_progressbar.js @@ -158,7 +158,7 @@ var KanbanColumnProgressBar = Widget.extend({ }); // Adapt active state - $bar.toggleClass('active progress-bar-striped', key === self.activeFilter); + $bar.toggleClass('progress-bar-animated progress-bar-striped', key === self.activeFilter); // Adapt width $bar.removeClass('o_bar_has_records transition-off'); -- cgit v1.2.3 From 0ac405550452cb304408b56313776fd3f9538dc7 Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Tue, 9 Jul 2019 08:53:42 +0000 Subject: [IMP] web: do not set focus on form when lastActivatedFieldIndex is not set When opening a dialog using mouse and closing it, form_dialog_discarded is triggered, which tries to set focus on form while lastActivatedFieldIndex is -1, as dialog is opened using mouse directly do not set focus back to form widget if lastActivatedFieldIndex is -1 task-2031706 closes odoo/odoo#34684 Signed-off-by: VincentSchippefilt --- addons/web/static/src/js/views/form/form_controller.js | 9 ++++++--- addons/web/static/src/js/views/form/form_renderer.js | 7 +++++-- addons/web/static/src/js/views/view_dialogs.js | 18 ++++++++++++++---- 3 files changed, 25 insertions(+), 9 deletions(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index 434e2095a8e..e3085b1379d 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -596,9 +596,12 @@ var FormController = BasicController.extend({ * @private * @param {OdooEvent} event */ - _onFormDialogDiscarded: function(e) { - e.stopPropagation(); - this.renderer.focusLastActivatedWidget(); + _onFormDialogDiscarded: function(ev) { + ev.stopPropagation(); + var isFocused = this.renderer.focusLastActivatedWidget(); + if (ev.data.callback) { + ev.data.callback(_.str.toBool(isFocused)); + } }, /** * Opens a one2many record (potentially new) in a dialog. This handler is diff --git a/addons/web/static/src/js/views/form/form_renderer.js b/addons/web/static/src/js/views/form/form_renderer.js index 2bf3c29197c..518791a6be9 100644 --- a/addons/web/static/src/js/views/form/form_renderer.js +++ b/addons/web/static/src/js/views/form/form_renderer.js @@ -176,8 +176,11 @@ var FormRenderer = BasicRenderer.extend({ * field. */ focusLastActivatedWidget: function () { - this._activateNextFieldWidget(this.state, this.lastActivatedFieldIndex - 1, - { noAutomaticCreate: true }); + if (this.lastActivatedFieldIndex !== -1) { + return this._activateNextFieldWidget(this.state, this.lastActivatedFieldIndex - 1, + { noAutomaticCreate: true }); + } + return false; }, /** * returns the active tab pages for each notebook diff --git a/addons/web/static/src/js/views/view_dialogs.js b/addons/web/static/src/js/views/view_dialogs.js index 3df17bbf155..c7360c81d02 100644 --- a/addons/web/static/src/js/views/view_dialogs.js +++ b/addons/web/static/src/js/views/view_dialogs.js @@ -238,8 +238,13 @@ var FormViewDialog = ViewDialog.extend({ * @override */ _focusOnClose: function() { - this.trigger_up('form_dialog_discarded'); - return true; + var isFocusSet = false; + this.trigger_up('form_dialog_discarded', { + callback: function (isFocused) { + isFocusSet = isFocused; + }, + }); + return isFocusSet; }, /** @@ -466,8 +471,13 @@ var SelectCreateDialog = ViewDialog.extend({ * @override */ _focusOnClose: function() { - this.trigger_up('form_dialog_discarded'); - return true; + var isFocusSet = false; + this.trigger_up('form_dialog_discarded', { + callback: function (isFocused) { + isFocusSet = isFocused; + }, + }); + return isFocusSet; }, //-------------------------------------------------------------------------- // Handlers -- cgit v1.2.3 From 04a600486e63397fa6295d7715613bd4b0f0acde Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 19 Jul 2019 12:04:12 +0000 Subject: [FIX] web: remove lazyloaded controller from stack ... if the current action can't be executed. Let's assume a form view for a record with a multicompany ir.rule. If the user switches to another company, the webclient is reloaded, but he doesn't have access to that record anymore. In this case, he is redirected to the Home menu. Before this rev., when he clicked on an app in this situation, it crashed. This was due to a leftover reference of the failed action (the lazyloaded, multi-record controller) in the controller stack. closes odoo/odoo#34994 Signed-off-by: VincentSchippefilt --- addons/web/static/src/js/chrome/action_manager_act_window.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js') 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 8b3ff339ded..123f41965b3 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 @@ -285,6 +285,7 @@ ActionManager.include({ } var lazyViewDef; + var lazyControllerID; if (lazyView) { // if the main view is lazy-loaded, its (lazy-loaded) controller is inserted // into the controller stack (so that breadcrumbs can be correctly computed), @@ -294,6 +295,7 @@ ActionManager.include({ // this controller being lazy-loaded, this call is actually sync lazyViewDef = self._createViewController(action, lazyView.type, {}, {lazy: true}) .then(function (lazyLoadedController) { + lazyControllerID = lazyLoadedController.jsID; self.controllerStack.push(lazyLoadedController.jsID); }); } @@ -312,7 +314,13 @@ ActionManager.include({ action.controllerID = controller.jsID; return self._executeAction(action, options); }) - .fail(self._destroyWindowAction.bind(self, action)); + .fail(function () { + if (lazyControllerID) { + var index = self.controllerStack.indexOf(lazyControllerID); + self.controllerStack = self.controllerStack.slice(0, index); + } + self._destroyWindowAction(action); + }); }); }, /** -- cgit v1.2.3 From 4e6ee3ac97041653ff15a77abd77084dc0c9f525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 23 Jul 2019 08:08:03 +0000 Subject: [FIX] web: allow groupby buttons in list view at any level The initial implementation of the special group by buttons in list groups only supported the first level of groupby. So, if one grouped a list view by field A, it worked (if A had a groupby defined). However, if we want to group by B/A, this no longer works. opw 2040725 closes odoo/odoo#35090 Signed-off-by: VincentSchippefilt --- addons/web/static/src/js/views/list/list_model.js | 9 +-------- addons/web/static/src/js/views/list/list_renderer.js | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/list/list_model.js b/addons/web/static/src/js/views/list/list_model.js index 41178498c96..6c592bd977e 100644 --- a/addons/web/static/src/js/views/list/list_model.js +++ b/addons/web/static/src/js/views/list/list_model.js @@ -94,14 +94,7 @@ odoo.define('web.ListModel', function (require) { options = options || {}; options.fetchRecordsWithGroups = true; return this._super(list, options).then(function (result) { - var prom; - if (!list.parentID) { - // groupbys buttons are only displayed on the first level of - // groupby so no need to fetch the extra fields for inner - // groups - prom = self._readGroupExtraFields(list); - } - return Promise.resolve(prom).then(_.constant(result)); + return self._readGroupExtraFields(list).then(_.constant(result)); }); }, /** diff --git a/addons/web/static/src/js/views/list/list_renderer.js b/addons/web/static/src/js/views/list/list_renderer.js index 364c663d117..658319fc2e7 100644 --- a/addons/web/static/src/js/views/list/list_renderer.js +++ b/addons/web/static/src/js/views/list/list_renderer.js @@ -579,7 +579,7 @@ var ListRenderer = BasicRenderer.extend({ var $pager = this._renderGroupPager(group); $lastCell.addClass('o_group_pager').append($pager); } - if (groupLevel === 0 && group.isOpen && this.groupbys[groupBy]) { + if (group.isOpen && this.groupbys[groupBy]) { var $buttons = this._renderGroupButtons(group, this.groupbys[groupBy]); if ($buttons.length) { var $buttonSection = $('
', { -- cgit v1.2.3 From 78b09d82fb16181c3ae2e4964f3cff30b76424db Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 23 Jul 2019 10:01:11 +0000 Subject: [FIX] web: pivot keeps controlpanel's domain on reload Open a pivot view, make a search for some field Click on a pivot cell to display the list view of elements matching the group's domain Go back to the pivot using breadcrumbs Before this commit, the original search domain was not kept across those actions After this commit, it is kept This difference is due to the fact that before 12.2, the whole action had an env, containing the search domain in 12.2 and afterwards, things are not done this way anymore OPW 2030555 OPW 2030983 closes odoo/odoo#35096 Signed-off-by: Lucas Perais (lpe) --- addons/web/static/src/js/views/pivot/pivot_model.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/pivot/pivot_model.js b/addons/web/static/src/js/views/pivot/pivot_model.js index b60cf81ac86..2c41200ec0f 100644 --- a/addons/web/static/src/js/views/pivot/pivot_model.js +++ b/addons/web/static/src/js/views/pivot/pivot_model.js @@ -422,6 +422,7 @@ var PivotModel = AbstractModel.extend({ } if ('domain' in params) { this.data.domain = params.domain; + this.initialDomain = params.domain; } else { this.data.domain = this.initialDomain; } -- cgit v1.2.3 From 4d0f36ac01b7a68d3ed0669f6e26f6a508bcbf36 Mon Sep 17 00:00:00 2001 From: svs-odoo Date: Tue, 23 Jul 2019 12:54:12 +0000 Subject: [FIX] web: context when read on multi edit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, in list editable, when user save multiple records in the same time, the context is passed for the write but not for the read. Now, the context is passed also for the read. closes odoo/odoo#35113 Signed-off-by: Géry Debongnie (ged) --- addons/web/static/src/js/views/list/list_model.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/list/list_model.js b/addons/web/static/src/js/views/list/list_model.js index 6c592bd977e..25fdf28954c 100644 --- a/addons/web/static/src/js/views/list/list_model.js +++ b/addons/web/static/src/js/views/list/list_model.js @@ -52,17 +52,19 @@ odoo.define('web.ListModel', function (require) { var model = records[0].model; var recordResIds = _.pluck(records, 'res_id'); var fieldNames = records[0].getFieldNames(); + var context = records[0].getContext(); return this._rpc({ model: model, method: 'write', args: [recordResIds, changes], - context: records[0].getContext(), + context: context, }).then(function () { return self._rpc({ model: model, method: 'read', args: [recordResIds, fieldNames], + context: context, }); }).then(function (results) { results.forEach(function (data) { -- cgit v1.2.3 From 5c340913616a301060769a1503733a6ed1a86852 Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Thu, 11 Jul 2019 12:45:15 +0000 Subject: [FIX] web: improve editable list column widths Changed the way some field types are displayed. Before this commit, column width in a list were calculated according to a given factor (integer), determining their weight. Now, some specific fields have an hardcoded width instead. This task also slightly tweaks some width factors, in order to try to have a better layout in most list views Task 1985916 closes odoo/odoo#35147 Signed-off-by: VincentSchippefilt --- .../src/js/views/list/list_editable_renderer.js | 66 +++++++++++++--------- 1 file changed, 39 insertions(+), 27 deletions(-) (limited to 'addons/web/static/src/js') 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 e876a8acd28..2203c1c4151 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 @@ -480,34 +480,41 @@ ListRenderer.include({ * Returns the relative width according to the widget or the field type. * @see _renderHeader * - * @param {Object} column a `field` arch node + * @param {Object} column an arch node + * @returns {integer | string} either a weight factor (number) or a css + * width description (string) */ _getColumnWidthFactor: function (column) { - if (column.attrs.width) { - // the width attribute has precedence on the width factor - return 0; + if (!this.state.fieldsInfo.list[column.attrs.name]) { + // Unnamed columns get default value + return 1; + } + var field = this.state.fields[column.attrs.name]; + if (!field) { + // this is not a field. Probably a button or something of unknown + // width. + return 1; } - var fieldType = this.state.fields[column.attrs.name].type; var widget = this.state.fieldsInfo.list[column.attrs.name].Widget.prototype; if ('widthFactor' in widget) { return widget.widthFactor; } - switch (fieldType) { + switch (field.type) { case 'binary': return 1; - case 'boolean': return 0.4; + case 'boolean': return '40px'; case 'char': return 1; - case 'date': return 1; - case 'datetime': return 1.5; - case 'float': return 1; + case 'date': return '100px'; + case 'datetime': return '150px'; + case 'float': return '100px'; case 'html': return 3; - case 'integer': return 0.8; - case 'many2many': return 2.2; - case 'many2one': return 1.5; + case 'integer': return '80px'; + case 'many2many': return 2; + case 'many2one': return 2; case 'monetary': return 1.2; - case 'one2many': return 2.2; + case 'one2many': return 2.5; case 'reference': return 1.5; case 'selection': return 1.5; - case 'text': return 3; + case 'text': return 2.5; default: return 1; } }, @@ -720,24 +727,26 @@ ListRenderer.include({ }); }, /** - * Overridden to set weights on columns for the fixed layout. + * Overridden to set weights or explicit width on columns for the fixed layout. * * @override * @private */ _processColumns: function () { this._super.apply(this, arguments); - if (this.editable) { var self = this; this.columns.forEach(function (column) { - if (column.attrs.width_factor) { + if (column.attrs.width) { + // nothing to do + } else if (column.attrs.width_factor) { column.attrs.widthFactor = parseFloat(column.attrs.width_factor, 10); } else { - if (column.tag === 'field') { - column.attrs.widthFactor = self._getColumnWidthFactor(column); + var factor = self._getColumnWidthFactor(column); + if (typeof factor === 'string') { + column.attrs.width = factor; } else { - column.attrs.widthFactor = 1; + column.attrs.widthFactor = factor; } } }); @@ -808,15 +817,18 @@ ListRenderer.include({ var $thead = this._super.apply(this, arguments); if (this.editable) { + // we compute the sum of the weights for each columns, excluding + // those with a fixed width. var totalWidth = this.columns.reduce(function (acc, column) { - return acc + column.attrs.widthFactor; + return acc + (column.attrs.widthFactor || 0); }, 0); this.columns.forEach(function (column) { - var $cell = $thead.find('th[data-name=' + column.attrs.name + ']'); - if (column.attrs.width) { - $cell.css('width', column.attrs.width); - } else if (column.attrs.widthFactor) { - $cell.css('width', (column.attrs.widthFactor / totalWidth * 100) + '%'); + if (column.attrs.width || column.attrs.widthFactor) { + var width = column.attrs.width || ((column.attrs.widthFactor / totalWidth * 100) + '%'); + var $th = $thead.find('th[data-name=' + column.attrs.name + ']'); + if ($th.data('name')) { + $th.css('width', width); + } } }); } -- cgit v1.2.3 From 7d78795f8b34bc6a8afde18427a1c26901824db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 25 Jul 2019 09:32:32 +0000 Subject: [FIX] web: properly handle (grouped list) pager when last field is numeric closes odoo/odoo#35176 Signed-off-by: VincentSchippefilt --- addons/web/static/src/js/views/list/list_renderer.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/list/list_renderer.js b/addons/web/static/src/js/views/list/list_renderer.js index 658319fc2e7..aed795a6b9b 100644 --- a/addons/web/static/src/js/views/list/list_renderer.js +++ b/addons/web/static/src/js/views/list/list_renderer.js @@ -558,16 +558,22 @@ var ListRenderer = BasicRenderer.extend({ var colspanBeforeAggregate; if (firstAggregateIndex !== -1) { // if there are aggregates, the first $th goes until the first - // aggregate then all cells between aggregates are rendered, then - // there is a last $th for the pager + // aggregate then all cells between aggregates are rendered colspanBeforeAggregate = firstAggregateIndex; var lastAggregateIndex = _.findLastIndex(this.columns, function (column) { return column.tag === 'field' && _.contains(aggregateKeys, column.attrs.name); }); cells = cells.concat(aggregateCells.slice(firstAggregateIndex, lastAggregateIndex + 1)); - cells.push($('').attr('colspan', this.columns.length - 1 - lastAggregateIndex)); + var colSpan = this.columns.length - 1 - lastAggregateIndex; + if (colSpan > 0) { + cells.push($('').attr('colspan', colSpan)); + } } else { - colspanBeforeAggregate = this.columns.length; + var colN = this.columns.length; + colspanBeforeAggregate = colN > 1 ? colN - 1 : 1; + if (colN > 1) { + cells.push($('')); + } } if (this.hasSelectors) { colspanBeforeAggregate += 1; @@ -575,9 +581,9 @@ var ListRenderer = BasicRenderer.extend({ $th.attr('colspan', colspanBeforeAggregate); if (group.isOpen && !group.groupedBy.length && (group.count > group.data.length)) { - var $lastCell = cells[cells.length - 1]; var $pager = this._renderGroupPager(group); - $lastCell.addClass('o_group_pager').append($pager); + var $lastCell = cells[cells.length - 1]; + $lastCell.append($pager); } if (group.isOpen && this.groupbys[groupBy]) { var $buttons = this._renderGroupButtons(group, this.groupbys[groupBy]); -- cgit v1.2.3