From fced5d1e952bfe474ac33ed2da82cbe5e5ff3f48 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 2 Apr 2019 09:21:49 +0000 Subject: [FIX] web: Wrong comparison in invoice analyes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Steps to reproduce the bug: Let's consider that we are in 2019 - Create two customer invoices: I1 and I2 - I1 with invoice date = 2 april 2019 and amount = 100€ - I2 with invoice date = 2 april 2018 and amount = 1000€ - Go to Reporting > Invoices - Click on widget "Time Ranges" and set "Based on" Invoice Date and "Range" This Year "Compare To" Previous Year Bug: The untaxed total for previous year was 1100€ instead of 1000€ because it counted previous year and this year. opw:1962027 closes odoo/odoo#32331 Signed-off-by: Simon Goffin (sig) --- addons/web/static/src/js/core/domain.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/core/domain.js b/addons/web/static/src/js/core/domain.js index c31feb61a8f..00c8dcb83d4 100644 --- a/addons/web/static/src/js/core/domain.js +++ b/addons/web/static/src/js/core/domain.js @@ -258,8 +258,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; } -- cgit v1.2.3 From 663597b50f1fab36648c16ba132c924908435a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Wed, 3 Apr 2019 10:40:34 +0000 Subject: [FIX] web: Load correct form view for calendar popup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When creating a record from a calendar view, the default form view is always used when using the popup mode, ignoring the `form_view_id` attribute of the tag. After this commit, the `form_view_id` is no longer ignored. closes odoo/odoo#32379 Signed-off-by: Géry Debongnie (ged) --- addons/web/static/src/js/views/calendar/calendar_controller.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src/js') 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 f0998f63bf3..3bfd40841dd 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) { -- cgit v1.2.3 From eebb0c6152f270cfabb183f79fcf2b2e56918950 Mon Sep 17 00:00:00 2001 From: Vincent Schippefilt Date: Fri, 5 Apr 2019 07:48:02 +0000 Subject: [FIX] web: corrected the order of icons in systray Since the merge of JQuery 3, the building of systray icons is non deterministic. After this fix, the menus are loaded correctly in order. Task-ID: 1960741 closes odoo/odoo#32382 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/chrome/systray_menu.js | 41 +++++++++++++------------ 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'addons/web/static/src/js') 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($('
'))); + }); + 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); + }); }); }, }); -- cgit v1.2.3 From 8d34eb1328b74ec3a8e3a2cc2edaeadb4c46ffbb Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 4 Apr 2019 13:11:03 +0000 Subject: [FIX] web: editable list: shift-tab and readonly fields Before this rev., navigating with shift-tab didn't produce the expected result when there were readonly fields on the way. For instance, pressing shift-tab on a field: - to the right of a readonly field: the focus was kept in the current field, whereas it should have been moved to the first editable field to the left of the readonly one - in the editable first cell of a row, with a readonly field in the last column: the focus was moved to the previous line, which is ok, but on the first editable cell of it, whereas it should have been on the last editable cell. @KangOl this commit needs to be forwardported up to saas-12.2, not later (the code slightly changed in saas-12.3, and we did another version of the fix). --- addons/web/static/src/js/views/list/list_editable_renderer.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 185a385a812..07363b2febd 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 @@ -478,7 +478,8 @@ ListRenderer.include({ */ _moveToPreviousLine: function () { if (this.currentRow > 0) { - this._selectCell(this.currentRow - 1, this.columns.length - 1); + // FORWARD-PORT THIS COMMIT UP TO SAAS-12.2 + this._selectCell(this.currentRow - 1, this.columns.length - 1, {inc: -1}); } else { this.unselectRow().then(this.trigger_up.bind(this, 'add_record')); } @@ -692,6 +693,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 {Deferred} fails if no cell could be selected */ _selectCell: function (rowIndex, fieldIndex, options) { @@ -715,7 +718,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, }); @@ -868,7 +871,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}) .fail(this._moveToPreviousLine.bind(this)); } else { this._moveToPreviousLine(); -- cgit v1.2.3 From 7d31b863ca404bd328840f8f3288cfc3034a3559 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 8 Apr 2019 06:23:53 +0000 Subject: [FIX] web: list: re-evalute modifiers depending on id In an editable (main) list view with modifiers depending on the record id, add a new record. While the record isn't created yet, the modifiers were correctly evaluated. However, they weren't re-evaluted when the record was saved (thus getting an id), and a reload of the view was necessary for the modifiers to be correctly applied. With this rev. they are now correctly re-evaluated when the record is saved. closes odoo/odoo#32483 Signed-off-by: Martin Geubelle (mge) --- .../web/static/src/js/views/list/list_editable_renderer.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (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 07363b2febd..04da1bc4983 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 @@ -428,6 +428,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 -- cgit v1.2.3 From b917fdd1ac8a7b8bb18bac0ba38d26501c486107 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 10 Apr 2019 18:09:55 +0200 Subject: [FIX] web: correctly forward-port 8d34eb1328. I shouldn't have trust the comment and apply the patch anyway. --- addons/web/static/src/js/views/list/list_editable_renderer.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/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js index 2bd9b5cc4b1..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 @@ -598,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}); }); }, /** -- cgit v1.2.3 From cdd644befc52017a788920393661ad645a744c1d Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Fri, 5 Apr 2019 12:34:37 +0000 Subject: [FIX] web: correctly update modifiers in editable list with buttons Since rev. odoo/odoo@015958d it is possible to add buttons in list group headers. These buttons are defined in nodes, pointing to m2o fields. Modifiers specified on these buttons thus use fields on the m2o comodel. There was a traceback in editable list view, when grouping by a m2o that defines a groupby button with modifiers as the modifiers are not registered with the same datapoint. When updating the modifiers, one must ensure that the modifier are related to the updated record. closes odoo/odoo#32456 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/views/basic/basic_renderer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js') 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. in list) + if (record.id in modifiersData.evaluatedModifiers) { + modifiersData.evaluatedModifiers[record.id] = record.evalModifiers(modifiersData.modifiers); + self._applyModifiers(modifiersData, record); + } }); delete this.defs; -- cgit v1.2.3