diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-04-12 13:37:44 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-04-12 13:37:44 +0200 |
| commit | 0a09a4d8a819ef06db47e798f0465e500004e4c1 (patch) | |
| tree | b9d66d60a1e9b5ff6030be62fff89df410b744ee /addons/web/static/src/js | |
| parent | db97bb7f1136dc3ebde9924b79364a698a63765d (diff) | |
| parent | 120359bf0c98191051ac19ae2e5fde53ca7d2ae5 (diff) | |
[MERGE] forward port branch saas-12.3 up to 120359bf0c9
Diffstat (limited to 'addons/web/static/src/js')
5 files changed, 47 insertions, 27 deletions
diff --git a/addons/web/static/src/js/chrome/systray_menu.js b/addons/web/static/src/js/chrome/systray_menu.js index fd214c0b650..cb292a9b90f 100644 --- a/addons/web/static/src/js/chrome/systray_menu.js +++ b/addons/web/static/src/js/chrome/systray_menu.js @@ -1,6 +1,7 @@ odoo.define('web.SystrayMenu', function (require) { "use strict"; +var dom = require('web.dom'); var Widget = require('web.Widget'); /** @@ -18,35 +19,35 @@ var SystrayMenu = Widget.extend({ this.widgets = []; }, /** + * Instanciate the items and add them into a temporary fragmenet * @override - * @returns {Promise} */ - start: function () { + willStart: function () { var self = this; - self._super.apply(this, arguments); - self._loadItems(); - - return new Promise(function (resolve, reject) { - Promise.all(self.items).then(resolve).guardedCatch(resolve); + var proms = []; + SystrayMenu.Items = _.sortBy(SystrayMenu.Items, function (item) { + return !_.isUndefined(item.prototype.sequence) ? item.prototype.sequence : 50; }); - }, - //-------------------------------------------------------------------------- - // Private - //-------------------------------------------------------------------------- + SystrayMenu.Items.forEach(function (WidgetClass) { + var cur_systray_item = new WidgetClass(self); + self.widgets.push(cur_systray_item); + proms.push(cur_systray_item.appendTo($('<div>'))); + }); + return this._super.apply(this, arguments).then(function () { + return Promise.all(proms); + }); + }, /** - * Instantiate items, using the classes located in SystrayMenu.items. + * Add the instanciated items, using the object located in this.wisgets */ - _loadItems: function () { + start: function () { var self = this; - SystrayMenu.Items = _.sortBy(SystrayMenu.Items, function (item) { - return !_.isUndefined(item.prototype.sequence) ? item.prototype.sequence : 50; - }); - _.each(SystrayMenu.Items, function (WidgetClass) { - var cur_systray_item = new WidgetClass(self); - self.widgets.push(cur_systray_item); - self.items.push(cur_systray_item.prependTo(self.$el)); + return this._super.apply(this, arguments).then(function () { + self.widgets.forEach(function (widget) { + dom.prepend(self.$el, widget.$el); + }); }); }, }); diff --git a/addons/web/static/src/js/core/domain.js b/addons/web/static/src/js/core/domain.js index c7533aabae0..9c74dcb953e 100644 --- a/addons/web/static/src/js/core/domain.js +++ b/addons/web/static/src/js/core/domain.js @@ -263,8 +263,8 @@ var Domain = collections.Tree.extend({ }); break; case 'previous_year': - leftBoundaryParams.years = leftBoundaryParams.years ? leftBoundaryParams.years-- : -1; - rightBoundaryParams.years = rightBoundaryParams.years ? rightBoundaryParams.years-- : -1; + leftBoundaryParams.years = leftBoundaryParams.years ? leftBoundaryParams.years - 1 : -1; + rightBoundaryParams.years = rightBoundaryParams.years ? rightBoundaryParams.years - 1 : -1; break; } diff --git a/addons/web/static/src/js/views/basic/basic_renderer.js b/addons/web/static/src/js/views/basic/basic_renderer.js index f741e11b789..4c03d9b77a1 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -731,8 +731,12 @@ var BasicRenderer = AbstractRenderer.extend({ var defs = []; this.defs = defs; // Potentially filled by widget rerendering _.each(this.allModifiersData, function (modifiersData) { - modifiersData.evaluatedModifiers[record.id] = record.evalModifiers(modifiersData.modifiers); - self._applyModifiers(modifiersData, record); + // `allModifiersData` might contain modifiers registered for other + // records than the given record (e.g. <groupby> in list) + if (record.id in modifiersData.evaluatedModifiers) { + modifiersData.evaluatedModifiers[record.id] = record.evalModifiers(modifiersData.modifiers); + self._applyModifiers(modifiersData, record); + } }); delete this.defs; 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 ec85b567cf7..dda3978635b 100644 --- a/addons/web/static/src/js/views/calendar/calendar_controller.js +++ b/addons/web/static/src/js/views/calendar/calendar_controller.js @@ -272,6 +272,7 @@ var CalendarController = AbstractController.extend({ res_model: this.modelName, context: context, title: title, + view_id: this.formViewId || false, disable_multiple_selection: true, on_saved: function () { if (event.data.on_save) { 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 9f37fcecbea..818739c6f48 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 @@ -435,6 +435,18 @@ ListRenderer.include({ }); } }, + /** + * @override + */ + updateState: function (state, params) { + if (params.noRender) { + // the state changed, but we won't do a re-rendering right now, so + // remove computed modifiers data (as they are obsolete) to force + // them to be recomputed at next (sub-)rendering + this.allModifiersData = []; + } + return this._super.apply(this, arguments); + }, //-------------------------------------------------------------------------- // Private @@ -586,7 +598,7 @@ ListRenderer.include({ this.commitChanges(curRecordId).then(function () { var $prevRow = self._getRow(self.allRecordIds[prevRecordIndex]); var prevRowIndex = $prevRow.prop('rowIndex') - 1; - self._selectCell(prevRowIndex, self.columns.length - 1); + self._selectCell(prevRowIndex, self.columns.length - 1, {inc: -1}); }); }, /** @@ -955,6 +967,8 @@ ListRenderer.include({ * @param {boolean} [options.force=false] if true, force selecting the cell * even if seems to be already the selected one (useful after a re- * rendering, to reset the focus on the correct field) + * @param {integer} [options.inc=1] the increment to use when searching for + * the "next" possible cell (if the cell to select can't be selected) * @return {Promise} fails if no cell could be selected */ _selectCell: function (rowIndex, fieldIndex, options) { @@ -979,7 +993,7 @@ ListRenderer.include({ var oldFieldIndex = self.currentFieldIndex; self.currentFieldIndex = fieldIndex; fieldIndex = self._activateFieldWidget(record, fieldIndex, { - inc: 1, + inc: options.inc || 1, wrap: wrap, event: options && options.event, }); @@ -1183,7 +1197,7 @@ ListRenderer.include({ switch (ev.data.direction) { case 'previous': if (this.currentFieldIndex > 0) { - this._selectCell(this.currentRow, this.currentFieldIndex - 1, {wrap: false}) + this._selectCell(this.currentRow, this.currentFieldIndex - 1, {inc: -1, wrap: false}) .guardedCatch(this._moveToPreviousLine.bind(this)); } else { this._moveToPreviousLine(); |
