on_close: function() {},
action_menu_id: null,
});
- if (_.isString(action) && instance.web.client_actions.contains(action)) {
+ if (action === false) {
+ action = { type: 'ir.actions.act_window_close' };
+ } else if (_.isString(action) && instance.web.client_actions.contains(action)) {
var action_client = { type: "ir.actions.client", tag: action, params: {} };
return this.do_action(action_client, options);
} else if (_.isNumber(action) || _.isString(action)) {
return self.do_action(result, options);
});
}
+
+ // Ensure context & domain are evaluated and can be manipulated/used
+ if (action.context) {
+ action.context = instance.web.pyeval.eval(
+ 'context', action.context);
+ }
+ if (action.domain) {
+ action.domain = instance.web.pyeval.eval(
+ 'domain', action.domain);
+ }
+
if (!action.type) {
console.error("No type for action", action);
return $.Deferred().reject();
dialogClass: executor.klass,
});
this.dialog.on("closing", null, options.on_close);
- this.dialog.init_dialog();
this.dialog.dialog_title = executor.action.name;
if (widget instanceof instance.web.ViewManager) {
_.extend(widget.flags, {
options.on_close();
}
this.dialog_stop();
+ return $.when();
},
ir_actions_server: function (action, options) {
var self = this;
ir_actions_report_xml: function(action, options) {
var self = this;
instance.web.blockUI();
- self.rpc("/web/session/eval_domain_and_context", {
+ return instance.web.pyeval.eval_domains_and_contexts({
contexts: [action.context],
domains: []
- }).done(function(res) {
+ }).then(function(res) {
action = _.clone(action);
action.context = res.context;
var c = instance.webclient.crashmanager;
- self.session.get_file({
- url: '/web/report',
- data: {action: JSON.stringify(action)},
- complete: instance.web.unblockUI,
- success: function(){
- if (!self.dialog) {
- options.on_close();
+ 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();
}
- self.dialog_stop();
- },
- error: c.rpc_error.bind(c)
- })
+ })
+ });
});
},
ir_actions_act_url: function (action) {
window.open(action.url, action.target === 'self' ? '_self' : '_blank');
+ return $.when();
},
});
var self = this,
controller = this.views[this.active_view].controller,
action_context = this.action.context || {};
- this.rpc('/web/session/eval_domain_and_context', {
+ instance.web.pyeval.eval_domains_and_contexts({
domains: [this.action.domain || []].concat(domains || []),
contexts: [action_context].concat(contexts || []),
group_by_seq: groupbys || []
case 'toggle_layout_outline':
current_view.rendering_engine.toggle_layout_debugging();
break;
+ case 'set_defaults':
+ current_view.open_defaults_dialog();
+ break;
case 'translate':
this.do_action({
name: "Technical Translation",
nested: true,
}
};
- this.session.get_file({ url: '/web/report', data: {action: JSON.stringify(action)}, complete: instance.web.unblockUI });
+ this.session.get_file({
+ url: '/web/report',
+ data: {action: JSON.stringify(action)},
+ complete: instance.web.unblockUI
+ });
}
break;
default:
this.fileupload_id = _.uniqueId('oe_fileupload');
$(window).on(this.fileupload_id, function() {
var args = [].slice.call(arguments).slice(1);
- if (args[0] && args[0].error) {
- alert(args[0].error);
- } else {
- self.do_attachement_update(self.dataset, self.model_id);
- }
+ self.do_attachement_update(self.dataset, self.model_id,args);
instance.web.unblockUI();
});
},
active_id: ids[0],
active_ids: ids,
active_model: self.getParent().dataset.model
- };
+ };
+ var c = instance.web.pyeval.eval('context',
+ new instance.web.CompoundContext(
+ sidebar_eval_context, active_ids_context));
self.rpc("/web/action/load", {
action_id: item.action.id,
- context: active_ids_context,
- eval_context: new instance.web.CompoundContext(sidebar_eval_context, active_ids_context),
+ context: c
}).done(function(result) {
- console.log(result.context);
- result.context = new instance.web.CompoundContext(result.context || {}, active_ids_context);
+ result.context = new instance.web.CompoundContext(
+ result.context || {}, active_ids_context)
+ .set_eval_context(c);
result.flags = result.flags || {};
result.flags.new_window = true;
self.do_action(result, {
});
});
},
- do_attachement_update: function(dataset, model_id) {
+ do_attachement_update: function(dataset, model_id,args) {
+ var self = this;
this.dataset = dataset;
this.model_id = model_id;
+ if (args && args[0]["erorr"]) {
+ instance.web.dialog($('<div>'),{
+ modal: true,
+ title: "OpenERP " + _.str.capitalize(args[0]["title"]),
+ buttons: [{
+ text: _t("Ok"),
+ click: function(){
+ $(this).dialog("close");
+ }}]
+ }).html(args[0]["erorr"]);
+ }
if (!model_id) {
this.on_attachments_loaded([]);
} else {
}
},
on_attachment_delete: function(e) {
- var self = this;
e.preventDefault();
e.stopPropagation();
var self = this;
"view_id": this.view_id,
"view_type": this.view_type,
toolbar: !!this.options.$sidebar,
- context: this.dataset.get_context(context)
+ context: instance.web.pyeval.eval(
+ 'context', this.dataset.get_context(context))
});
}
return view_loaded.then(function(r) {
};
var context = new instance.web.CompoundContext(dataset.get_context(), action_data.context || {});
- var handler = function (r) {
- var action = r;
+ var handler = function (action) {
if (action && action.constructor == Object) {
var ncontext = new instance.web.CompoundContext(context);
if (record_id) {
});
}
ncontext.add(action.context || {});
- return self.rpc('/web/session/eval_domain_and_context', {
- contexts: [ncontext],
- domains: []
- }).then(function (results) {
- action.context = results.context;
- /* niv: previously we were overriding once more with action_data.context,
- * I assumed this was not a correct behavior and removed it
- */
- return self.do_action(action, {
- on_close: result_handler,
- });
- }, null);
+ action.context = ncontext;
+ return self.do_action(action, {
+ on_close: result_handler,
+ });
} else {
self.do_action({"type":"ir.actions.act_window_close"});
return result_handler();
}
}
args.push(context);
- return dataset.call_button(action_data.name, args).done(handler);
+ return dataset.call_button(action_data.name, args).then(handler);
} else if (action_data.type=="action") {
- return this.rpc('/web/action/load', { action_id: action_data.name, context: context, do_not_eval: true}).done(handler);
+ return this.rpc('/web/action/load', {
+ action_id: action_data.name,
+ context: instance.web.pyeval.eval('context', context),
+ do_not_eval: true
+ }).then(handler);
} else {
- return dataset.exec_workflow(record_id, action_data.name).done(handler);
+ return dataset.exec_workflow(record_id, action_data.name).then(handler);
}
},
/**
new instance.web.DataExport(this, this.dataset).open();
},
sidebar_eval_context: function () {
- return $.when();
+ return $.when({});
},
/**
* Asks the view to reload itself, if the reloading is asynchronous should