summaryrefslogtreecommitdiff
path: root/addons/base/static/src/js
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2011-07-18 14:54:22 +0200
committerAntony Lesuisse <al@openerp.com>2011-07-18 14:54:22 +0200
commit31a725f75cfe5ea49099bf46a52ad9f9998aaa35 (patch)
treeb7971a4f6b3fdcaea6fa096a4d4c9f04fe90008c /addons/base/static/src/js
parentc121f79c60f98b2522a54e9e85f1231dc67945fd (diff)
Controller is now a family
bzr revid: al@openerp.com-20110718125422-x20k89dogbklgr4c
Diffstat (limited to 'addons/base/static/src/js')
-rw-r--r--addons/base/static/src/js/chrome.js98
-rw-r--r--addons/base/static/src/js/controller.js9
-rw-r--r--addons/base/static/src/js/data.js46
-rw-r--r--addons/base/static/src/js/form.js12
-rw-r--r--addons/base/static/src/js/list.js10
-rw-r--r--addons/base/static/src/js/search.js37
-rw-r--r--addons/base/static/src/js/views.js27
7 files changed, 95 insertions, 144 deletions
diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js
index 1a080a77f9b..63fd722b298 100644
--- a/addons/base/static/src/js/chrome.js
+++ b/addons/base/static/src/js/chrome.js
@@ -162,8 +162,8 @@ openerp.base.generate_null_object_class = function(claz, add) {
};
openerp.base.Notification = openerp.base.BasicController.extend({
- init: function(element_id) {
- this._super(element_id);
+ init: function(parent, element_id) {
+ this._super(parent, element_id);
this.$element.notify({
speed: 500,
expires: 1500
@@ -183,6 +183,7 @@ openerp.base.Notification = openerp.base.BasicController.extend({
}
});
+// Session should be a Class not Controller
openerp.base.Session = openerp.base.BasicController.extend( /** @lends openerp.base.Session# */{
/**
* @constructs
@@ -191,7 +192,7 @@ openerp.base.Session = openerp.base.BasicController.extend( /** @lends openerp.b
* @param server
* @param port
*/
- init: function(element_id, server, port) {
+ init: function(parent, element_id, server, port) {
this._super(element_id);
this.server = (server == undefined) ? location.hostname : server;
this.port = (port == undefined) ? location.port : port;
@@ -449,21 +450,10 @@ openerp.base.Controller = openerp.base.BasicController.extend( /** @lends opener
* @constructs
* @extends openerp.base.BasicController
*/
- init: function(parent_or_session, element_id) {
- this._super(element_id);
- this.controller_parent = null;
- this.controller_children = [];
- if(parent_or_session) {
- if(parent_or_session.session) {
- this.parent = parent_or_session;
- this.session = this.parent.session;
- if(this.parent.children) {
- this.parent.children.push(this);
- }
- } else {
- // TODO remove Backward compatilbility
- this.session = parent_or_session;
- }
+ init: function(parent, element_id) {
+ this._super(parent, element_id);
+ if(this.parent && this.parent.session) {
+ this.session = this.parent.session;
}
},
/**
@@ -476,7 +466,6 @@ openerp.base.Controller = openerp.base.BasicController.extend( /** @lends opener
* @returns {jQuery.Deferred} deferred object for the RPC call
*/
rpc: function(url, data, success, error) {
- // TODO: support additional arguments ?
return this.session.rpc(url, data, success, error);
}
});
@@ -510,11 +499,8 @@ openerp.base.BaseWidget = openerp.base.Controller.extend({
* @constructs
* @params {openerp.base.search.BaseWidget} parent The parent widget.
*/
- init: function (parent, session) {
- this._super(session);
- this.children = [];
- this.parent = null;
- this.set_parent(parent);
+ init: function (parent) {
+ this._super(parent);
this.make_id(this.identifier_prefix);
},
/**
@@ -554,21 +540,6 @@ openerp.base.BaseWidget = openerp.base.Controller.extend({
this._super();
},
/**
- * Set the parent of this component, also un-register the previous parent
- * if there was one.
- *
- * @param {openerp.base.BaseWidget} parent The new parent.
- */
- set_parent: function(parent) {
- if(this.parent) {
- this.parent.children = _.without(this.parent.children, this);
- }
- this.parent = parent;
- if(this.parent) {
- parent.children.push(this);
- }
- },
- /**
* Render the widget. This.template must be defined.
* The content of the current object is passed as context to the template.
*
@@ -582,8 +553,8 @@ openerp.base.BaseWidget = openerp.base.Controller.extend({
openerp.base.Dialog = openerp.base.BaseWidget.extend({
dialog_title: "",
identifier_prefix: 'dialog',
- init: function (session, options) {
- this._super(null, session);
+ init: function (parent, options) {
+ this._super(parent);
this.options = {
modal: true,
width: 'auto',
@@ -667,8 +638,8 @@ openerp.base.Dialog = openerp.base.BaseWidget.extend({
openerp.base.CrashManager = openerp.base.Dialog.extend({
identifier_prefix: 'dialog_crash',
- init: function(session) {
- this._super(session);
+ init: function(parent) {
+ this._super(parent);
this.session.on_rpc_error.add(this.on_rpc_error);
},
on_button_Ok: function() {
@@ -702,11 +673,8 @@ openerp.base.CrashManager = openerp.base.Dialog.extend({
});
openerp.base.Loading = openerp.base.Controller.extend({
- controller_manifest: {
- register: ["Loading"]
- },
- init: function(session, element_id) {
- this._super(session, element_id);
+ init: function(parent, element_id) {
+ this._super(parent, element_id);
this.count = 0;
this.session.on_rpc_request.add_first(this.on_rpc_event, 1);
this.session.on_rpc_response.add_last(this.on_rpc_event, -1);
@@ -728,8 +696,8 @@ openerp.base.Database = openerp.base.Controller.extend({
openerp.base.Login = openerp.base.Controller.extend({
remember_creditentials: true,
- init: function(session, element_id) {
- this._super(session, element_id);
+ init: function(parent, element_id) {
+ this._super(parent, element_id);
this.has_local_storage = typeof(localStorage) != 'undefined';
this.selected_db = null;
this.selected_login = null;
@@ -805,8 +773,8 @@ openerp.base.Login = openerp.base.Controller.extend({
});
openerp.base.Header = openerp.base.Controller.extend({
- init: function(session, element_id) {
- this._super(session, element_id);
+ init: function(parent, element_id) {
+ this._super(parent, element_id);
},
start: function() {
this.do_update();
@@ -819,8 +787,8 @@ openerp.base.Header = openerp.base.Controller.extend({
});
openerp.base.Menu = openerp.base.Controller.extend({
- init: function(session, element_id, secondary_menu_id) {
- this._super(session, element_id);
+ init: function(parent, element_id, secondary_menu_id) {
+ this._super(parent, element_id);
this.secondary_menu_id = secondary_menu_id;
this.$secondary_menu = $("#" + secondary_menu_id);
this.menu = false;
@@ -910,34 +878,32 @@ openerp.base.ImportExport = openerp.base.Controller.extend({
openerp.base.WebClient = openerp.base.Controller.extend({
init: function(element_id) {
- var self = this;
this._super(null, element_id);
QWeb.add_template("xml/base.xml");
var params = {};
- if(jQuery.param != undefined &&
- jQuery.deparam(jQuery.param.querystring()).kitten != undefined) {
+ if(jQuery.param != undefined && jQuery.deparam(jQuery.param.querystring()).kitten != undefined) {
this.$element.addClass("kitten-mode-activated");
}
this.$element.html(QWeb.render("Interface", params));
- this.session = new openerp.base.Session("oe_errors");
- this.loading = new openerp.base.Loading(this.session, "oe_loading");
- this.crashmanager = new openerp.base.CrashManager(this.session);
+ this.session = new openerp.base.Session(this,"oe_errors");
+ this.loading = new openerp.base.Loading(this,"oe_loading");
+ this.crashmanager = new openerp.base.CrashManager(this);
this.crashmanager.start(false);
// Do you autorize this ?
- openerp.base.Controller.prototype.notification = new openerp.base.Notification("oe_notification");
+ openerp.base.Controller.prototype.notification = new openerp.base.Notification(this, "oe_notification");
- this.header = new openerp.base.Header(this.session, "oe_header");
- this.login = new openerp.base.Login(this.session, "oe_login");
+ this.header = new openerp.base.Header(this, "oe_header");
+ this.login = new openerp.base.Login(this, "oe_login");
this.header.on_logout.add(this.login.on_logout);
this.session.on_session_invalid.add(this.login.do_ask_login);
this.session.on_session_valid.add_last(this.header.do_update);
this.session.on_session_valid.add_last(this.on_logged);
- this.menu = new openerp.base.Menu(this.session, "oe_menu", "oe_secondary_menu");
+ this.menu = new openerp.base.Menu(this, "oe_menu", "oe_secondary_menu");
this.menu.on_action.add(this.on_menu_action);
},
start: function() {
@@ -948,9 +914,9 @@ openerp.base.WebClient = openerp.base.Controller.extend({
this.notification.notify("OpenERP Client", "The openerp client has been initialized.");
},
on_logged: function() {
- this.action_manager = new openerp.base.ActionManager(this.session, "oe_app");
+ this.action_manager = new openerp.base.ActionManager(this, "oe_app");
this.action_manager.start();
-
+
// if using saved actions, load the action and give it to action manager
var parameters = jQuery.deparam(jQuery.param.querystring());
if(parameters["s_action"] != undefined) {
diff --git a/addons/base/static/src/js/controller.js b/addons/base/static/src/js/controller.js
index aca7c5fe004..a5c7bca4b53 100644
--- a/addons/base/static/src/js/controller.js
+++ b/addons/base/static/src/js/controller.js
@@ -130,12 +130,19 @@ instance.base.BasicController = instance.base.Class.extend( /** @lends instance.
*
* @constructs
*/
- init: function(element_id) {
+ init: function(parent, element_id) {
this.element_id = element_id;
this.$element = $('#' + element_id);
if (element_id) {
instance.screen[element_id] = this;
}
+ // save the parent children relationship
+ this.controller_parent = null;
+ this.controller_children = [];
+ this.parent = parent;
+ if(this.parent && this.parent.children) {
+ this.parent.children.push(this);
+ }
// Transform on_* method into openerp.base.callbacks
for (var name in this) {
diff --git a/addons/base/static/src/js/data.js b/addons/base/static/src/js/data.js
index c1b64b93307..aeb9f0b096a 100644
--- a/addons/base/static/src/js/data.js
+++ b/addons/base/static/src/js/data.js
@@ -39,18 +39,16 @@ openerp.base.DataGroup = openerp.base.Controller.extend( /** @lends openerp.bas
* @param {Array} group_by sequence of fields by which to group
* @param {Number} [level=0] nesting level of the group
*/
- init: function(session, model, domain, context, group_by, level) {
+ init: function(parent, model, domain, context, group_by, level) {
+ this._super(parent, null);
if (group_by) {
if (group_by.length || context['group_by_no_leaf']) {
- return new openerp.base.ContainerDataGroup(
- session, model, domain, context, group_by, level);
+ return new openerp.base.ContainerDataGroup( this, model, domain, context, group_by, level);
} else {
- return new openerp.base.GrouplessDataGroup(
- session, model, domain, context, level);
+ return new openerp.base.GrouplessDataGroup( this, model, domain, context, level);
}
}
- this._super(session, null);
this.model = model;
this.context = context;
this.domain = domain;
@@ -59,8 +57,7 @@ openerp.base.DataGroup = openerp.base.Controller.extend( /** @lends openerp.bas
},
cls: 'DataGroup'
});
-openerp.base.ContainerDataGroup = openerp.base.DataGroup.extend(
- /** @lends openerp.base.ContainerDataGroup# */ {
+openerp.base.ContainerDataGroup = openerp.base.DataGroup.extend( /** @lends openerp.base.ContainerDataGroup# */ {
/**
*
* @constructs
@@ -73,8 +70,8 @@ openerp.base.ContainerDataGroup = openerp.base.DataGroup.extend(
* @param group_by
* @param level
*/
- init: function (session, model, domain, context, group_by, level) {
- this._super(session, model, domain, context, null, level);
+ init: function (parent, model, domain, context, group_by, level) {
+ this._super(parent, model, domain, context, null, level);
this.group_by = group_by;
},
@@ -197,8 +194,7 @@ openerp.base.ContainerDataGroup = openerp.base.DataGroup.extend(
});
}
});
-openerp.base.GrouplessDataGroup = openerp.base.DataGroup.extend(
- /** @lends openerp.base.GrouplessDataGroup# */ {
+openerp.base.GrouplessDataGroup = openerp.base.DataGroup.extend( /** @lends openerp.base.GrouplessDataGroup# */ {
/**
*
* @constructs
@@ -210,18 +206,16 @@ openerp.base.GrouplessDataGroup = openerp.base.DataGroup.extend(
* @param context
* @param level
*/
- init: function (session, model, domain, context, level) {
- this._super(session, model, domain, context, null, level);
+ init: function (parent, model, domain, context, level) {
+ this._super(parent, model, domain, context, null, level);
},
list: function (fields, ifGroups, ifRecords) {
ifRecords(_.extend(
- new openerp.base.DataSetSearch(this.session, this.model),
+ new openerp.base.DataSetSearch(this, this.model),
{domain: this.domain, context: this.context, _sort: this.sort}));
}
});
-
-openerp.base.StaticDataGroup = openerp.base.GrouplessDataGroup.extend(
- /** @lends openerp.base.StaticDataGroup# */ {
+openerp.base.StaticDataGroup = openerp.base.GrouplessDataGroup.extend( /** @lends openerp.base.StaticDataGroup# */ {
/**
* A specialization of groupless data groups, relying on a single static
* dataset as its records provider.
@@ -249,8 +243,8 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base.
* @param {openerp.base.Session} session current OpenERP session
* @param {String} model the OpenERP model this dataset will manage
*/
- init: function(session, model, context) {
- this._super(session);
+ init: function(parent, model, context) {
+ this._super(parent);
this.model = model;
this.context = context || {};
this.index = null;
@@ -382,10 +376,9 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base.
return this.context;
}
});
-
openerp.base.DataSetStatic = openerp.base.DataSet.extend({
- init: function(session, model, context, ids) {
- this._super(session, model, context);
+ init: function(parent, model, context, ids) {
+ this._super(parent, model, context);
// all local records
this.ids = ids || [];
if (this.ids.length) {
@@ -411,10 +404,9 @@ openerp.base.DataSetStatic = openerp.base.DataSet.extend({
this.set_ids(_.without.apply(null, [this.ids].concat(ids)));
}
});
-
openerp.base.DataSetSearch = openerp.base.DataSet.extend({
- init: function(session, model, context, domain) {
- this._super(session, model, context);
+ init: function(parent, model, context, domain) {
+ this._super(parent, model, context);
this.domain = domain || [];
this._sort = [];
this.offset = 0;
@@ -485,7 +477,6 @@ openerp.base.DataSetSearch = openerp.base.DataSet.extend({
}, error_callback);
}
});
-
openerp.base.BufferedDataSet = openerp.base.DataSetStatic.extend({
virtual_id_prefix: "one2many_v_id_",
virtual_id_regex: /one2many_v_id_.*/,
@@ -590,7 +581,6 @@ openerp.base.BufferedDataSet = openerp.base.DataSetStatic.extend({
return completion.promise();
}
});
-
openerp.base.ReadOnlyDataSetSearch = openerp.base.DataSetSearch.extend({
create: function(data, callback, error_callback) {
this.on_create(data);
diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js
index 19f5e271858..4acdeb86d03 100644
--- a/addons/base/static/src/js/form.js
+++ b/addons/base/static/src/js/form.js
@@ -17,9 +17,9 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
*
* @property {openerp.base.Registry} registry=openerp.base.form.widgets widgets registry for this form view instance
*/
- init: function(view_manager, session, element_id, dataset, view_id) {
- this._super(session, element_id);
- this.view_manager = view_manager || new openerp.base.NullViewManager();
+ init: function(parent, element_id, dataset, view_id) {
+ this._super(parent, element_id);
+ this.view_manager = parent || new openerp.base.NullViewManager();
this.dataset = dataset;
this.model = dataset.model;
this.view_id = view_id;
@@ -403,7 +403,7 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV
} else {
// TODO fme: modify this so it doesn't try to load attachments when there is not sidebar
/*(new openerp.base.DataSetSearch(
- this.session, 'ir.attachment', this.dataset.get_context(),
+ this, 'ir.attachment', this.dataset.get_context(),
[['res_model', '=', this.dataset.model],
['res_id', '=', this.datarecord.id],
['type', 'in', ['binary', 'url']]])).read_slice(
@@ -1910,7 +1910,7 @@ openerp.base.form.SelectCreatePopup = openerp.base.BaseWidget.extend({
if (!this.options.auto_create)
return;
var self = this;
- var wdataset = new openerp.base.DataSetSearch(this.session, this.model, this.context, this.domain);
+ var wdataset = new openerp.base.DataSetSearch(this, this.model, this.context, this.domain);
wdataset.parent_view = this.options.parent_view;
wdataset.create(data, function(r) {
self.on_select_elements([r.result]);
@@ -2005,7 +2005,7 @@ openerp.base.form.FormOpenPopup = openerp.base.BaseWidget.extend({
if (!this.options.auto_write)
return;
var self = this;
- var wdataset = new openerp.base.DataSetSearch(this.session, this.model, this.context, this.domain);
+ var wdataset = new openerp.base.DataSetSearch(this, this.model, this.context, this.domain);
wdataset.parent_view = this.options.parent_view;
wdataset.write(id, data, function(r) {
self.on_write_completed();
diff --git a/addons/base/static/src/js/list.js b/addons/base/static/src/js/list.js
index 84b605f1114..491fd885a5f 100644
--- a/addons/base/static/src/js/list.js
+++ b/addons/base/static/src/js/list.js
@@ -87,9 +87,9 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
*
* @borrows openerp.base.ActionExecutor#execute_action as #execute_action
*/
- init: function(view_manager, session, element_id, dataset, view_id, options) {
- this._super(session, element_id);
- this.view_manager = view_manager || new openerp.base.NullViewManager();
+ init: function(parent, element_id, dataset, view_id, options) {
+ this._super(parent, element_id);
+ this.view_manager = parent || new openerp.base.NullViewManager();
this.dataset = dataset;
this.model = dataset.model;
this.view_id = view_id;
@@ -100,7 +100,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
this.flags = this.view_manager.flags || {};
this.set_groups(new openerp.base.ListView.Groups(this));
-
+
if (this.dataset instanceof openerp.base.DataSetStatic) {
this.groups.datagroup = new openerp.base.StaticDataGroup(this.dataset);
}
@@ -451,7 +451,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
this.dataset.context = results.context;
this.dataset.domain = results.domain;
this.groups.datagroup = new openerp.base.DataGroup(
- this.session, this.model,
+ this, this.model,
results.domain, results.context,
results.group_by);
this.groups.datagroup.sort = this.dataset._sort;
diff --git a/addons/base/static/src/js/search.js b/addons/base/static/src/js/search.js
index f5b66774384..fcf4a175b3c 100644
--- a/addons/base/static/src/js/search.js
+++ b/addons/base/static/src/js/search.js
@@ -1,9 +1,9 @@
openerp.base.search = function(openerp) {
openerp.base.SearchView = openerp.base.Controller.extend({
- init: function(view_manager, session, element_id, dataset, view_id, defaults) {
- this._super(session, element_id);
- this.view_manager = view_manager || new openerp.base.NullViewManager();
+ init: function(parent, element_id, dataset, view_id, defaults) {
+ this._super(parent, element_id);
+ this.view_manager = parent || new openerp.base.NullViewManager();
this.dataset = dataset;
this.model = dataset.model;
this.view_id = view_id;
@@ -115,7 +115,7 @@ openerp.base.SearchView = openerp.base.Controller.extend({
data.fields_view.fields);
// for extended search view
- var ext = new openerp.base.search.ExtendedSearch(null, this.session, this.model);
+ var ext = new openerp.base.search.ExtendedSearch(this, this.model);
lines.push([ext]);
this.inputs.push(ext);
@@ -124,6 +124,7 @@ openerp.base.SearchView = openerp.base.Controller.extend({
'lines': lines,
'defaults': this.defaults
});
+
// We don't understand why the following commented line does not work in Chrome but
// the non-commented line does. As far as we investigated, only God knows.
//this.$element.html(render);
@@ -301,8 +302,7 @@ openerp.base.search.fields = new openerp.base.Registry({
'many2one': 'openerp.base.search.ManyToOneField',
'many2many': 'openerp.base.search.ManyToManyField'
});
-openerp.base.search.Invalid = openerp.base.Class.extend(
- /** @lends openerp.base.search.Invalid# */{
+openerp.base.search.Invalid = openerp.base.Class.extend( /** @lends openerp.base.search.Invalid# */{
/**
* Exception thrown by search widgets when they hold invalid values,
* which they can not return when asked.
@@ -322,8 +322,7 @@ openerp.base.search.Invalid = openerp.base.Class.extend(
': [' + this.value + '] is ' + this.message);
}
});
-openerp.base.search.Widget = openerp.base.Controller.extend(
- /** @lends openerp.base.search.Widget# */{
+openerp.base.search.Widget = openerp.base.Controller.extend( /** @lends openerp.base.search.Widget# */{
template: null,
/**
* Root class of all search widgets
@@ -420,8 +419,7 @@ openerp.base.search.Group = openerp.base.search.Widget.extend({
}
});
-openerp.base.search.Input = openerp.base.search.Widget.extend(
- /** @lends openerp.base.search.Input# */{
+openerp.base.search.Input = openerp.base.search.Widget.extend( /** @lends openerp.base.search.Input# */{
/**
* @constructs
* @extends openerp.base.search.Widget
@@ -491,8 +489,7 @@ openerp.base.search.Filter = openerp.base.search.Input.extend({
return this.attrs.domain;
}
});
-openerp.base.search.Field = openerp.base.search.Input.extend(
- /** @lends openerp.base.search.Field# */ {
+openerp.base.search.Field = openerp.base.search.Input.extend( /** @lends openerp.base.search.Field# */ {
template: 'SearchView.field',
default_operator: '=',
/**
@@ -557,8 +554,7 @@ openerp.base.search.Field = openerp.base.search.Input.extend(
* @class
* @extends openerp.base.search.Field
*/
-openerp.base.search.CharField = openerp.base.search.Field.extend(
- /** @lends openerp.base.search.CharField# */ {
+openerp.base.search.CharField = openerp.base.search.Field.extend( /** @lends openerp.base.search.CharField# */ {
default_operator: 'ilike',
get_value: function () {
return this.$element.val();
@@ -631,12 +627,7 @@ openerp.base.search.SelectionField = openerp.base.search.Field.extend({
return this.$element.val();
}
});
-/**
- * @class
- * @extends openerp.base.search.Field
- */
-openerp.base.search.DateField = openerp.base.search.Field.extend(
- /** @lends openerp.base.search.DateField# */{
+openerp.base.search.DateField = openerp.base.search.Field.extend( /** @lends openerp.base.search.DateField# */{
template: 'SearchView.fields.date',
/**
* enables date picker on the HTML widgets
@@ -724,7 +715,7 @@ openerp.base.search.ManyToOneField = openerp.base.search.CharField.extend({
self.$element.val(self.name);
});
this.dataset = new openerp.base.DataSet(
- this.view.session, this.attrs['relation']);
+ this.view, this.attrs['relation']);
},
start: function () {
this._super();
@@ -791,8 +782,8 @@ openerp.base.search.ManyToManyField = openerp.base.search.CharField.extend({
openerp.base.search.ExtendedSearch = openerp.base.BaseWidget.extend({
template: 'SearchView.extended_search',
identifier_prefix: 'extended-search',
- init: function (parent, session, model) {
- this._super(parent, session);
+ init: function (parent, model) {
+ this._super(parent);
this.model = model;
},
add_group: function() {
diff --git a/addons/base/static/src/js/views.js b/addons/base/static/src/js/views.js
index 81d55855eb8..f2359461ef4 100644
--- a/addons/base/static/src/js/views.js
+++ b/addons/base/static/src/js/views.js
@@ -35,15 +35,12 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
action.flags.new_window = true;
}
if (action.target == 'new') {
- var dialog = this.current_dialog = new openerp.base.ActionDialog(this.session, {
- title: action.name,
- width: '50%'
- });
+ var dialog = this.current_dialog = new openerp.base.ActionDialog(this, { title: action.name, width: '90%' });
if (on_closed) {
dialog.close_callback = on_closed;
}
dialog.start(false);
- var viewmanager = dialog.viewmanager = new openerp.base.ViewManagerAction(this.session, dialog.element_id, action);
+ var viewmanager = dialog.viewmanager = new openerp.base.ViewManagerAction(this, dialog.element_id, action);
viewmanager.start();
dialog.open();
} else if (action.flags.new_window) {
@@ -57,7 +54,7 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
if (this.viewmanager) {
this.viewmanager.stop();
}
- this.viewmanager = new openerp.base.ViewManagerAction(this.session, this.element_id, action);
+ this.viewmanager = new openerp.base.ViewManagerAction(this, this.element_id, action);
this.viewmanager.start();
}
break;
@@ -85,8 +82,8 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
});
openerp.base.ViewManager = openerp.base.Controller.extend({
- init: function(session, element_id, dataset, views) {
- this._super(session, element_id);
+ init: function(parent, element_id, dataset, views) {
+ this._super(parent, element_id);
this.model = dataset.model;
this.dataset = dataset;
this.searchview = null;
@@ -133,7 +130,7 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
if (!view.controller) {
// Lazy loading of views
var controllerclass = this.registry.get_object(view_type);
- var controller = new controllerclass( this, this.session, this.element_id + "_view_" + view_type,
+ var controller = new controllerclass( this, this.element_id + "_view_" + view_type,
this.dataset, view.view_id, view.options);
if (view.embedded_view) {
controller.set_embedded_view(view.embedded_view);
@@ -203,7 +200,7 @@ openerp.base.ViewManager = openerp.base.Controller.extend({
if (this.searchview) {
this.searchview.stop();
}
- this.searchview = new openerp.base.SearchView(this, this.session, this.element_id + "_search", this.dataset, view_id, search_defaults);
+ this.searchview = new openerp.base.SearchView(this, this.element_id + "_search", this.dataset, view_id, search_defaults);
if (this.flags.search_view === false) {
this.searchview.hide();
}
@@ -253,18 +250,19 @@ openerp.base.NullViewManager = openerp.base.generate_null_object_class(openerp.b
});
openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({
- init: function(session, element_id, action) {
+ init: function(parent, element_id, action) {
+ this.session = parent.session;
var dataset;
if (!action.res_id) {
- dataset = new openerp.base.DataSetSearch(session, action.res_model, action.context || null);
+ dataset = new openerp.base.DataSetSearch(this, action.res_model, action.context || null);
} else {
- dataset = new openerp.base.DataSetStatic(session, action.res_model, {}, [action.res_id]);
+ dataset = new openerp.base.DataSetStatic(this, action.res_model, {}, [action.res_id]);
if (action.context) {
// TODO fme: should normalize all DataSets constructors to (session, model, context, ...)
dataset.context = action.context;
}
}
- this._super(session, element_id, dataset, action.views);
+ this._super(parent, element_id, dataset, action.views);
this.action = action;
this.flags = this.action.flags || {};
if (action.res_model == 'board.board' && action.views.length == 1 && action.views) {
@@ -402,7 +400,6 @@ openerp.base.Sidebar = openerp.base.BaseWidget.extend({
}
});
-
openerp.base.NullSidebar = openerp.base.generate_null_object_class(openerp.base.Sidebar);
openerp.base.Export = openerp.base.Dialog.extend({