summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_renderer.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-11-16 11:10:03 +0100
committerGéry Debongnie <ged@odoo.com>2017-11-16 12:19:15 +0100
commit745d00362ab8353bf88457b05f090c470f780ef5 (patch)
tree11e98e5ea3b843d35bc4c441d8bc09406bbd4f66 /addons/web/static/src/js/views/basic/basic_renderer.js
parenta226f415f2065fdb39235e0569aa7841cc4ad244 (diff)
[FIX] web: make sure modifiers works for async widgets
Before this commit, asynchronous field widgets (with willStart async), with a non empty template had a problem: the invisible modifier was not applied properly. The reason is that the code that applied the modifiers was called directly after the widget was 'willStarted'. This means that if this is async, and if there is a template, the $el in willStart will be replaced by another $el after, which will remove the invisible modifier. This was an interesting problem with the pad widget (it is asynchronous the first time a pad widget is instantiated)
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_renderer.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_renderer.js21
1 files changed, 12 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 09b264be0b5..7b5cd87daaa 100644
--- a/addons/web/static/src/js/views/basic/basic_renderer.js
+++ b/addons/web/static/src/js/views/basic/basic_renderer.js
@@ -484,15 +484,18 @@ var BasicRenderer = AbstractRenderer.extend({
// Update the modifiers registration by associating the widget and by
// giving the modifiers options now (as the potential callback is
// associated to new widget)
- this._registerModifiers(node, record, widget, _.extend({
- callback: (function (element, modifiers, record) {
- element.$el.toggleClass('o_field_empty', !!(
- record.data.id
- && (modifiers.readonly || this.mode === 'readonly')
- && !element.widget.isSet()
- ));
- }).bind(this),
- }, modifiersOptions || {}));
+ var self = this;
+ def.then(function () {
+ self._registerModifiers(node, record, widget, _.extend({
+ callback: function (element, modifiers, record) {
+ element.$el.toggleClass('o_field_empty', !!(
+ record.data.id
+ && (modifiers.readonly || self.mode === 'readonly')
+ && !element.widget.isSet()
+ ));
+ },
+ }, modifiersOptions || {}));
+ });
return widget;
},