[FIX] pad: render_value binded on change effective_readonly event, so render value calls wait for each others

bzr revid: dle@openerp.com-20140409160214-1anxi8z07xj49vsp
This commit is contained in:
Denis Ledoux 2014-04-09 18:02:14 +02:00
commit 83996269ca
1 changed files with 6 additions and 3 deletions

View File

@ -25,7 +25,7 @@ openerp.pad = function(instance) {
self.$(".oe_unconfigured").toggle(!configured);
self.$(".oe_configured").toggle(configured);
});
this.render_value();
this.on("change:effective_readonly", this, this.render_value);
},
render_value: function() {
var self = this;
@ -36,9 +36,12 @@ openerp.pad = function(instance) {
var value = self.get('value');
if (self.get('effective_readonly')) {
if (_.str.startsWith(value, 'http')) {
self.$('.oe_pad_content').addClass('oe_pad_loading')
this.pad_loading_request = self.view.dataset.call('pad_get_content', {url: value}).done(function(data) {
self.$('.oe_pad_content').removeClass('oe_pad_loading').html('<div class="oe_pad_readonly"><div>');
self.$('.oe_pad_readonly').html(data);
if (self.$('.oe_pad_loading').length) {
self.$('.oe_pad_content').removeClass('oe_pad_loading').html('<div class="oe_pad_readonly"><div>');
self.$('.oe_pad_readonly').html(data);
}
}).fail(function() {
self.$('.oe_pad_content').text(_t('Unable to load pad'));
});