summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-04-20 11:13:28 +0200
committerAaron Bohy <aab@odoo.com>2017-04-20 13:12:50 +0200
commite61454f148583c90fca625de75fce85b5d0129c8 (patch)
tree93300640f7483373db97a2b581bbb9029335e04c /addons/web/static/src
parent6a5f18f9709674ffa1a8557afe16448f38c29487 (diff)
[FIX] web: BasicRenderer: don't reset this.defs too soon
The 'defs' attribute of the BasicRenderer is used to push the rendering deferred of asynchronous fields. It is set to an empty array before the rendering, and for each asynchronous field, its deferred is pushed in the array, so that the renderer can wait for all its fields to be rendered (no flickering). The function '_applyModifiers' is called during the whole view rendering (for each field in the view), and when some fields change, as the modifiers are then re-evaluated. As it is called during the whole view rendering, it can't delete the 'defs' attribute, otherwise it will crash if one of the remaining fields in the view uses an asynchronous widget (trying to push a deferred in an undefined variable). This rev. moves the deletion of 'defs' to the function that is called when all modifiers are re-evaluated and applied.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/basic/basic_renderer.js15
1 files changed, 6 insertions, 9 deletions
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 a18a82e5745..dd0f59a4176 100644
--- a/addons/web/static/src/js/views/basic/basic_renderer.js
+++ b/addons/web/static/src/js/views/basic/basic_renderer.js
@@ -176,23 +176,17 @@ var BasicRenderer = AbstractRenderer.extend({
* @param {Object} modifiersData
* @param {Object} record
* @param {Object} [element] - do the update only on this element if given
- * @returns {Deferred} resolved once finished
*/
_applyModifiers: function (modifiersData, record, element) {
var self = this;
- var defs = [];
var modifiers = modifiersData.evaluatedModifiers[record.id] || {};
- this.defs = defs; // Potentially filled by widget rerendering
if (element) {
_apply(element);
} else {
// Clone is necessary as the list might change during _.each
_.each(_.clone(modifiersData.elementsByRecord[record.id]), _apply);
}
- delete this.defs;
-
- return $.when.apply($, defs);
function _apply(element) {
// If the view is in edit mode and that a widget have to switch
@@ -540,10 +534,13 @@ var BasicRenderer = AbstractRenderer.extend({
_updateAllModifiers: function (record) {
var self = this;
- var defs = _.flatten(_.map(this.allModifiersData, function (modifiersData) {
+ var defs = [];
+ this.defs = defs; // Potentially filled by widget rerendering
+ _.each(this.allModifiersData, function (modifiersData) {
self._computeModifiers(modifiersData, record);
- return self._applyModifiers(modifiersData, record);
- }));
+ self._applyModifiers(modifiersData, record);
+ });
+ delete this.defs;
return $.when.apply($, defs);
},