summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/data.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/data.js')
-rw-r--r--addons/web/static/src/js/data.js34
1 files changed, 32 insertions, 2 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js
index 986c58270ca..d501b1263b1 100644
--- a/addons/web/static/src/js/data.js
+++ b/addons/web/static/src/js/data.js
@@ -253,6 +253,36 @@ instance.web.QueryGroup = instance.web.Class.extend({
});
instance.web.Model.include({
+ /**
+ new openerp.web.Model([session,] model_name[, context[, domain]])
+
+ @constructs instance.web.Model
+ @extends instance.web.Class
+
+ @param {openerp.web.Session} [session] The session object used to communicate with
+ the server.
+ @param {String} model_name name of the OpenERP model this object is bound to
+ @param {Object} [context]
+ @param {Array} [domain]
+ */
+ init: function() {
+ var session, model_name, context, domain;
+ var args = _.toArray(arguments);
+ args.reverse();
+ session = args.pop();
+ if (session && ! (session instanceof openerp.web.Session)) {
+ model_name = session;
+ session = null;
+ } else {
+ model_name = args.pop();
+ }
+ context = args.length > 0 ? args.pop() : null;
+ domain = args.length > 0 ? args.pop() : null;
+
+ this._super(session, model_name, context, domain);
+ this._context = context || {};
+ this._domain = domain || [];
+ },
session: function() {
if (! this._session)
return instance.session;
@@ -303,7 +333,7 @@ instance.web.Model.include({
* @param {String} signal signal to trigger on the workflow
*/
exec_workflow: function (id, signal) {
- return instance.session.rpc('/web/dataset/exec_workflow', {
+ return this.session().rpc('/web/dataset/exec_workflow', {
model: this.name,
id: id,
signal: signal
@@ -340,7 +370,7 @@ instance.web.Model.include({
*/
call_button: function (method, args) {
instance.web.pyeval.ensure_evaluated(args, {});
- return instance.session.rpc('/web/dataset/call_button', {
+ return this.session().rpc('/web/dataset/call_button', {
model: this.name,
method: method,
// Should not be necessary anymore. Integrate remote in this?