[IMP] actionmanager report port to the new synchronous pyeval api.

bzr revid: al@openerp.com-20140217224626-3s0q34x0jw8t4okg
This commit is contained in:
Antony Lesuisse 2014-02-17 23:46:26 +01:00
parent 9a22d42b8b
commit e4579fdbbd
1 changed files with 31 additions and 36 deletions

View File

@ -496,44 +496,39 @@ instance.web.ActionManager = instance.web.Widget.extend({
ir_actions_report_xml: function(action, options) {
var self = this;
instance.web.blockUI();
return instance.web.pyeval.eval_domains_and_contexts({
contexts: [action.context],
domains: []
}).then(function(res) {
action = _.clone(action);
action.context = res.context;
action = _.clone(action);
var eval_contexts = ([instance.session.user_context] || []).concat([action.context]);
action.context = instance.web.pyeval.eval('contexts',eval_contexts);
// iOS devices doesn't allow iframe use the way we do it,
// opening a new window seems the best way to workaround
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
var params = {
action: JSON.stringify(action),
token: new Date().getTime()
};
var url = self.session.url('/web/report', params);
instance.web.unblockUI();
$('<a href="'+url+'" target="_blank"></a>')[0].click();
return;
}
var c = instance.webclient.crashmanager;
return $.Deferred(function (d) {
self.session.get_file({
url: '/web/report',
data: {action: JSON.stringify(action)},
complete: instance.web.unblockUI,
success: function(){
if (!self.dialog) {
options.on_close();
}
self.dialog_stop();
d.resolve();
},
error: function () {
c.rpc_error.apply(c, arguments);
d.reject();
// iOS devices doesn't allow iframe use the way we do it,
// opening a new window seems the best way to workaround
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
var params = {
action: JSON.stringify(action),
token: new Date().getTime()
};
var url = self.session.url('/web/report', params);
instance.web.unblockUI();
$('<a href="'+url+'" target="_blank"></a>')[0].click();
return;
}
var c = instance.webclient.crashmanager;
return $.Deferred(function (d) {
self.session.get_file({
url: '/web/report',
data: {action: JSON.stringify(action)},
complete: instance.web.unblockUI,
success: function(){
if (!self.dialog) {
options.on_close();
}
});
self.dialog_stop();
d.resolve();
},
error: function () {
c.rpc_error.apply(c, arguments);
d.reject();
}
});
});
},