[IMP] sed -i '' -e 's/connection/session/g'
bzr revid: chs@openerp.com-20120814152900-8r84kyz0qy1hwkvz
This commit is contained in:
parent
8c43267c4a
commit
63e4d9b572
|
@ -193,7 +193,7 @@ instance.web.CrashManager = instance.web.CallbackEnabled.extend({
|
||||||
on_traceback: function(error) {
|
on_traceback: function(error) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var buttons = {};
|
var buttons = {};
|
||||||
if (instance.connection.openerp_entreprise) {
|
if (instance.session.openerp_entreprise) {
|
||||||
buttons[_t("Send OpenERP Enterprise Report")] = function() {
|
buttons[_t("Send OpenERP Enterprise Report")] = function() {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
var issuename = $('#issuename').val();
|
var issuename = $('#issuename').val();
|
||||||
|
@ -224,7 +224,7 @@ instance.web.CrashManager = instance.web.CallbackEnabled.extend({
|
||||||
min_height: '600px',
|
min_height: '600px',
|
||||||
buttons: buttons
|
buttons: buttons
|
||||||
}).open();
|
}).open();
|
||||||
dialog.$element.html(QWeb.render('CrashManager.error', {session: instance.connection, error: error}));
|
dialog.$element.html(QWeb.render('CrashManager.error', {session: instance.session, error: error}));
|
||||||
},
|
},
|
||||||
on_javascript_exception: function(exception) {
|
on_javascript_exception: function(exception) {
|
||||||
this.on_traceback({
|
this.on_traceback({
|
||||||
|
@ -269,7 +269,7 @@ instance.web.Loading = instance.web.Widget.extend({
|
||||||
|
|
||||||
this.count += increment;
|
this.count += increment;
|
||||||
if (this.count > 0) {
|
if (this.count > 0) {
|
||||||
if (instance.connection.debug) {
|
if (instance.session.debug) {
|
||||||
this.$element.text(_.str.sprintf( _t("Loading (%d)"), this.count));
|
this.$element.text(_.str.sprintf( _t("Loading (%d)"), this.count));
|
||||||
} else {
|
} else {
|
||||||
this.$element.text(_t("Loading"));
|
this.$element.text(_t("Loading"));
|
||||||
|
@ -882,8 +882,8 @@ instance.web.UserMenu = instance.web.Widget.extend({
|
||||||
var func = new instance.web.Model("res.users").get_func("read");
|
var func = new instance.web.Model("res.users").get_func("read");
|
||||||
return func(self.session.uid, ["name", "company_id"]).pipe(function(res) {
|
return func(self.session.uid, ["name", "company_id"]).pipe(function(res) {
|
||||||
var topbar_name = res.name;
|
var topbar_name = res.name;
|
||||||
if(instance.connection.debug)
|
if(instance.session.debug)
|
||||||
topbar_name = _.str.sprintf("%s (%s)", topbar_name, instance.connection.db);
|
topbar_name = _.str.sprintf("%s (%s)", topbar_name, instance.session.db);
|
||||||
if(res.company_id[0] > 1)
|
if(res.company_id[0] > 1)
|
||||||
topbar_name = _.str.sprintf("%s (%s)", topbar_name, res.company_id[1]);
|
topbar_name = _.str.sprintf("%s (%s)", topbar_name, res.company_id[1]);
|
||||||
self.$element.find('.oe_topbar_name').text(topbar_name);
|
self.$element.find('.oe_topbar_name').text(topbar_name);
|
||||||
|
@ -900,7 +900,7 @@ instance.web.UserMenu = instance.web.Widget.extend({
|
||||||
on_menu_settings: function() {
|
on_menu_settings: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.rpc("/web/action/load", { action_id: "base.action_res_users_my" }, function(result) {
|
self.rpc("/web/action/load", { action_id: "base.action_res_users_my" }, function(result) {
|
||||||
result.result.res_id = instance.connection.uid;
|
result.result.res_id = instance.session.uid;
|
||||||
self.getParent().action_manager.do_action(result.result);
|
self.getParent().action_manager.do_action(result.result);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -927,7 +927,7 @@ instance.web.Client = instance.web.Widget.extend({
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
return instance.connection.session_bind(this.origin).pipe(function() {
|
return instance.session.session_bind(this.origin).pipe(function() {
|
||||||
var $e = $(QWeb.render(self._template, {}));
|
var $e = $(QWeb.render(self._template, {}));
|
||||||
self.replaceElement($e);
|
self.replaceElement($e);
|
||||||
self.bind_events();
|
self.bind_events();
|
||||||
|
@ -970,7 +970,7 @@ instance.web.Client = instance.web.Widget.extend({
|
||||||
show_common: function() {
|
show_common: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.crashmanager = new instance.web.CrashManager();
|
this.crashmanager = new instance.web.CrashManager();
|
||||||
instance.connection.on_rpc_error.add(this.crashmanager.on_rpc_error);
|
instance.session.on_rpc_error.add(this.crashmanager.on_rpc_error);
|
||||||
self.notification = new instance.web.Notification(this);
|
self.notification = new instance.web.Notification(this);
|
||||||
self.notification.appendTo(self.$element);
|
self.notification.appendTo(self.$element);
|
||||||
self.loading = new instance.web.Loading(self);
|
self.loading = new instance.web.Loading(self);
|
||||||
|
@ -1067,7 +1067,7 @@ instance.web.WebClient = instance.web.Client.extend({
|
||||||
do_reload: function() {
|
do_reload: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
return this.session.session_reload().pipe(function () {
|
return this.session.session_reload().pipe(function () {
|
||||||
instance.connection.load_modules(true).pipe(
|
instance.session.load_modules(true).pipe(
|
||||||
self.menu.proxy('do_reload')); });
|
self.menu.proxy('do_reload')); });
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -1174,7 +1174,7 @@ instance.web.EmbeddedClient = instance.web.Client.extend({
|
||||||
start: function() {
|
start: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
return $.when(this._super()).pipe(function() {
|
return $.when(this._super()).pipe(function() {
|
||||||
return instance.connection.session_authenticate(self.dbname, self.login, self.key, true).pipe(function() {
|
return instance.session.session_authenticate(self.dbname, self.login, self.key, true).pipe(function() {
|
||||||
return self.rpc("/web/action/load", { action_id: self.action_id }, function(result) {
|
return self.rpc("/web/action/load", { action_id: self.action_id }, function(result) {
|
||||||
var action = result.result;
|
var action = result.result;
|
||||||
action.flags = _.extend({
|
action.flags = _.extend({
|
||||||
|
|
|
@ -692,7 +692,7 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, {
|
||||||
instance.web.WidgetMixin.init.call(this,parent);
|
instance.web.WidgetMixin.init.call(this,parent);
|
||||||
// FIXME: this should not be
|
// FIXME: this should not be
|
||||||
this.setElement(this._make_descriptive());
|
this.setElement(this._make_descriptive());
|
||||||
this.session = instance.connection;
|
this.session = instance.session;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Renders the element. The default implementation renders the widget using QWeb,
|
* Renders the element. The default implementation renders the widget using QWeb,
|
||||||
|
@ -841,7 +841,7 @@ instance.web.Widget = instance.web.Class.extend(instance.web.WidgetMixin, {
|
||||||
rpc: function(url, data, success, error) {
|
rpc: function(url, data, success, error) {
|
||||||
var def = $.Deferred().then(success, error);
|
var def = $.Deferred().then(success, error);
|
||||||
var self = this;
|
var self = this;
|
||||||
instance.connection.rpc(url, data). then(function() {
|
instance.session.rpc(url, data). then(function() {
|
||||||
if (!self.isDestroyed())
|
if (!self.isDestroyed())
|
||||||
def.resolve.apply(def, arguments);
|
def.resolve.apply(def, arguments);
|
||||||
}, function() {
|
}, function() {
|
||||||
|
@ -863,7 +863,7 @@ instance.web.Registry = instance.web.Class.extend({
|
||||||
*
|
*
|
||||||
* An object path is simply a dotted name from the instance root to the
|
* An object path is simply a dotted name from the instance root to the
|
||||||
* object pointed to (e.g. ``"instance.web.Session"`` for an OpenERP
|
* object pointed to (e.g. ``"instance.web.Session"`` for an OpenERP
|
||||||
* connection object).
|
* session object).
|
||||||
*
|
*
|
||||||
* @constructs instance.web.Registry
|
* @constructs instance.web.Registry
|
||||||
* @param {Object} mapping a mapping of keys to object-paths
|
* @param {Object} mapping a mapping of keys to object-paths
|
||||||
|
|
|
@ -514,7 +514,7 @@ $.async_when = function() {
|
||||||
// special tweak for the web client
|
// special tweak for the web client
|
||||||
var old_async_when = $.async_when;
|
var old_async_when = $.async_when;
|
||||||
$.async_when = function() {
|
$.async_when = function() {
|
||||||
if (instance.connection.synch)
|
if (instance.session.synch)
|
||||||
return $.when.apply(this, arguments);
|
return $.when.apply(this, arguments);
|
||||||
else
|
else
|
||||||
return old_async_when.apply(this, arguments);
|
return old_async_when.apply(this, arguments);
|
||||||
|
@ -559,7 +559,7 @@ instance.web.unblockUI = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Setup default session */
|
/** Setup default session */
|
||||||
instance.connection = new instance.web.Session();
|
instance.session = new instance.web.Session();
|
||||||
|
|
||||||
/** Configure default qweb */
|
/** Configure default qweb */
|
||||||
instance.web._t = new instance.web.TranslationDataBase().build_translation_function();
|
instance.web._t = new instance.web.TranslationDataBase().build_translation_function();
|
||||||
|
@ -578,8 +578,8 @@ instance.web._lt = function (s) {
|
||||||
return {toString: function () { return instance.web._t(s); }}
|
return {toString: function () { return instance.web._t(s); }}
|
||||||
};
|
};
|
||||||
instance.web.qweb = new QWeb2.Engine();
|
instance.web.qweb = new QWeb2.Engine();
|
||||||
instance.web.qweb.default_dict['__debug__'] = instance.connection.debug; // Which one ?
|
instance.web.qweb.default_dict['__debug__'] = instance.session.debug; // Which one ?
|
||||||
instance.web.qweb.debug = instance.connection.debug;
|
instance.web.qweb.debug = instance.session.debug;
|
||||||
instance.web.qweb.default_dict = {
|
instance.web.qweb.default_dict = {
|
||||||
'_' : _,
|
'_' : _,
|
||||||
'_t' : instance.web._t
|
'_t' : instance.web._t
|
||||||
|
@ -636,7 +636,7 @@ var _t = instance.web._t;
|
||||||
_t('%d years ago');
|
_t('%d years ago');
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.connection.on('module_loaded', this, function () {
|
instance.session.on('module_loaded', this, function () {
|
||||||
// provide timeago.js with our own translator method
|
// provide timeago.js with our own translator method
|
||||||
$.timeago.settings.translator = instance.web._t;
|
$.timeago.settings.translator = instance.web._t;
|
||||||
});
|
});
|
||||||
|
|
|
@ -58,7 +58,7 @@ instance.web.Query = instance.web.Class.extend({
|
||||||
},
|
},
|
||||||
_execute: function () {
|
_execute: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
return instance.connection.rpc('/web/dataset/search_read', {
|
return instance.session.rpc('/web/dataset/search_read', {
|
||||||
model: this._model.name,
|
model: this._model.name,
|
||||||
fields: this._fields || false,
|
fields: this._fields || false,
|
||||||
domain: this._model.domain(this._filter),
|
domain: this._model.domain(this._filter),
|
||||||
|
@ -233,7 +233,7 @@ instance.web.Model = instance.web.Class.extend(/** @lends openerp.web.Model# */{
|
||||||
kwargs = args;
|
kwargs = args;
|
||||||
args = [];
|
args = [];
|
||||||
}
|
}
|
||||||
return instance.connection.rpc('/web/dataset/call_kw', {
|
return instance.session.rpc('/web/dataset/call_kw', {
|
||||||
model: this.name,
|
model: this.name,
|
||||||
method: method,
|
method: method,
|
||||||
args: args,
|
args: args,
|
||||||
|
@ -256,7 +256,7 @@ instance.web.Model = instance.web.Class.extend(/** @lends openerp.web.Model# */{
|
||||||
* @param {String} signal signal to trigger on the workflow
|
* @param {String} signal signal to trigger on the workflow
|
||||||
*/
|
*/
|
||||||
exec_workflow: function (id, signal) {
|
exec_workflow: function (id, signal) {
|
||||||
return instance.connection.rpc('/web/dataset/exec_workflow', {
|
return instance.session.rpc('/web/dataset/exec_workflow', {
|
||||||
model: this.name,
|
model: this.name,
|
||||||
id: id,
|
id: id,
|
||||||
signal: signal
|
signal: signal
|
||||||
|
@ -282,7 +282,7 @@ instance.web.Model = instance.web.Class.extend(/** @lends openerp.web.Model# */{
|
||||||
*/
|
*/
|
||||||
context: function (context) {
|
context: function (context) {
|
||||||
return new instance.web.CompoundContext(
|
return new instance.web.CompoundContext(
|
||||||
instance.connection.user_context, this._context, context || {});
|
instance.session.user_context, this._context, context || {});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Button action caller, needs to perform cleanup if an action is returned
|
* Button action caller, needs to perform cleanup if an action is returned
|
||||||
|
@ -292,7 +292,7 @@ instance.web.Model = instance.web.Class.extend(/** @lends openerp.web.Model# */{
|
||||||
* FIXME: remove when evaluator integrated
|
* FIXME: remove when evaluator integrated
|
||||||
*/
|
*/
|
||||||
call_button: function (method, args) {
|
call_button: function (method, args) {
|
||||||
return instance.connection.rpc('/web/dataset/call_button', {
|
return instance.session.rpc('/web/dataset/call_button', {
|
||||||
model: this.name,
|
model: this.name,
|
||||||
method: method,
|
method: method,
|
||||||
domain_id: null,
|
domain_id: null,
|
||||||
|
|
|
@ -1613,7 +1613,7 @@ instance.web.search.CustomFilters = instance.web.search.Input.extend({
|
||||||
}
|
}
|
||||||
var filter = {
|
var filter = {
|
||||||
name: $name.val(),
|
name: $name.val(),
|
||||||
user_id: private_filter ? instance.connection.uid : false,
|
user_id: private_filter ? instance.session.uid : false,
|
||||||
model_id: self.view.model,
|
model_id: self.view.model,
|
||||||
context: results.context,
|
context: results.context,
|
||||||
domain: results.domain
|
domain: results.domain
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
openerp.test_support = {
|
openerp.test_support = {
|
||||||
setup_connection: function (connection) {
|
setup_session: function (session) {
|
||||||
var origin = location.protocol+"//"+location.host;
|
var origin = location.protocol+"//"+location.host;
|
||||||
_.extend(connection, {
|
_.extend(session, {
|
||||||
origin: origin,
|
origin: origin,
|
||||||
prefix: origin,
|
prefix: origin,
|
||||||
server: origin, // keep chs happy
|
server: origin, // keep chs happy
|
||||||
//openerp.web.qweb.default_dict['_s'] = this.origin;
|
//openerp.web.qweb.default_dict['_s'] = this.origin;
|
||||||
rpc_function: connection.rpc_json,
|
rpc_function: session.rpc_json,
|
||||||
session_id: false,
|
session_id: false,
|
||||||
uid: false,
|
uid: false,
|
||||||
username: false,
|
username: false,
|
||||||
|
@ -22,7 +22,7 @@ openerp.test_support = {
|
||||||
shortcuts: [],
|
shortcuts: [],
|
||||||
active_id: null
|
active_id: null
|
||||||
});
|
});
|
||||||
return connection.session_reload();
|
return session.session_reload();
|
||||||
},
|
},
|
||||||
module: function (title, tested_core, nonliterals) {
|
module: function (title, tested_core, nonliterals) {
|
||||||
var conf = QUnit.config.openerp = {};
|
var conf = QUnit.config.openerp = {};
|
||||||
|
@ -31,10 +31,10 @@ openerp.test_support = {
|
||||||
QUnit.stop();
|
QUnit.stop();
|
||||||
var oe = conf.openerp = window.openerp.init();
|
var oe = conf.openerp = window.openerp.init();
|
||||||
window.openerp.web[tested_core](oe);
|
window.openerp.web[tested_core](oe);
|
||||||
var done = openerp.test_support.setup_connection(oe.connection);
|
var done = openerp.test_support.setup_session(oe.session);
|
||||||
if (nonliterals) {
|
if (nonliterals) {
|
||||||
done = done.pipe(function () {
|
done = done.pipe(function () {
|
||||||
return oe.connection.rpc('/tests/add_nonliterals', {
|
return oe.session.rpc('/tests/add_nonliterals', {
|
||||||
domains: nonliterals.domains || [],
|
domains: nonliterals.domains || [],
|
||||||
contexts: nonliterals.contexts || []
|
contexts: nonliterals.contexts || []
|
||||||
}).then(function (r) {
|
}).then(function (r) {
|
||||||
|
|
|
@ -1656,7 +1656,7 @@ instance.web.form.FormWidget = instance.web.Widget.extend(instance.web.form.Invi
|
||||||
template = 'WidgetLabel.tooltip';
|
template = 'WidgetLabel.tooltip';
|
||||||
}
|
}
|
||||||
return QWeb.render(template, {
|
return QWeb.render(template, {
|
||||||
debug: instance.connection.debug,
|
debug: instance.session.debug,
|
||||||
widget: widget
|
widget: widget
|
||||||
})},
|
})},
|
||||||
gravity: $.fn.tipsy.autoBounds(50, 'nw'),
|
gravity: $.fn.tipsy.autoBounds(50, 'nw'),
|
||||||
|
@ -1733,7 +1733,7 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
|
||||||
start: function() {
|
start: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.$element.click(this.on_click);
|
this.$element.click(this.on_click);
|
||||||
if (this.node.attrs.help || instance.connection.debug) {
|
if (this.node.attrs.help || instance.session.debug) {
|
||||||
this.do_attach_tooltip();
|
this.do_attach_tooltip();
|
||||||
}
|
}
|
||||||
this.setupFocus(this.$element);
|
this.setupFocus(this.$element);
|
||||||
|
@ -1930,7 +1930,7 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w
|
||||||
}, this));
|
}, this));
|
||||||
}
|
}
|
||||||
this.$label = this.view.$element.find('label[for=' + this.id_for_label + ']');
|
this.$label = this.view.$element.find('label[for=' + this.id_for_label + ']');
|
||||||
if (instance.connection.debug) {
|
if (instance.session.debug) {
|
||||||
this.do_attach_tooltip(this, this.$label[0] || this.$element);
|
this.do_attach_tooltip(this, this.$label[0] || this.$element);
|
||||||
this.$label.off('dblclick').on('dblclick', function() {
|
this.$label.off('dblclick').on('dblclick', function() {
|
||||||
console.log("Field '%s' of type '%s' in View: %o", self.name, (self.node.attrs.widget || self.field.type), self.view);
|
console.log("Field '%s' of type '%s' in View: %o", self.name, (self.node.attrs.widget || self.field.type), self.view);
|
||||||
|
|
|
@ -2059,7 +2059,7 @@ instance.web.list.Button = instance.web.list.Column.extend({
|
||||||
title: this.string || '',
|
title: this.string || '',
|
||||||
additional_attributes: isNaN(row_data["id"].value) && instance.web.BufferedDataSet.virtual_id_regex.test(row_data["id"].value) ?
|
additional_attributes: isNaN(row_data["id"].value) && instance.web.BufferedDataSet.virtual_id_regex.test(row_data["id"].value) ?
|
||||||
'disabled="disabled" class="oe_list_button_disabled"' : '',
|
'disabled="disabled" class="oe_list_button_disabled"' : '',
|
||||||
prefix: instance.connection.prefix,
|
prefix: instance.session.prefix,
|
||||||
icon: this.icon,
|
icon: this.icon,
|
||||||
alt: this.string || ''
|
alt: this.string || ''
|
||||||
});
|
});
|
||||||
|
@ -2086,7 +2086,7 @@ instance.web.list.Binary = instance.web.list.Column.extend({
|
||||||
var text = _t("Download");
|
var text = _t("Download");
|
||||||
var download_url = _.str.sprintf(
|
var download_url = _.str.sprintf(
|
||||||
'/web/binary/saveas?session_id=%s&model=%s&field=%s&id=%d',
|
'/web/binary/saveas?session_id=%s&model=%s&field=%s&id=%d',
|
||||||
instance.connection.session_id, options.model, this.id, options.id);
|
instance.session.session_id, options.model, this.id, options.id);
|
||||||
if (this.filename) {
|
if (this.filename) {
|
||||||
download_url += '&filename_field=' + this.filename;
|
download_url += '&filename_field=' + this.filename;
|
||||||
if (row_data[this.filename]) {
|
if (row_data[this.filename]) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ $(document).ready(function () {
|
||||||
// Context n should have base evaluation context + all of contexts
|
// Context n should have base evaluation context + all of contexts
|
||||||
// 0..n-1 in its own evaluation context
|
// 0..n-1 in its own evaluation context
|
||||||
var active_id = 4;
|
var active_id = 4;
|
||||||
var result = openerp.connection.test_eval_contexts([
|
var result = openerp.session.test_eval_contexts([
|
||||||
{
|
{
|
||||||
"__contexts": [
|
"__contexts": [
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test('non-literal_eval_contexts', function () {
|
test('non-literal_eval_contexts', function () {
|
||||||
var result = openerp.connection.test_eval_contexts([{
|
var result = openerp.session.test_eval_contexts([{
|
||||||
"__ref": "compound_context",
|
"__ref": "compound_context",
|
||||||
"__contexts": [
|
"__contexts": [
|
||||||
{"__ref": "context", "__debug": "{'type':parent.type}",
|
{"__ref": "context", "__debug": "{'type':parent.type}",
|
||||||
|
@ -141,9 +141,9 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
test('current_date', function () {
|
test('current_date', function () {
|
||||||
var current_date = openerp.web.date_to_str(new Date());
|
var current_date = openerp.web.date_to_str(new Date());
|
||||||
var result = openerp.connection.test_eval_domains(
|
var result = openerp.session.test_eval_domains(
|
||||||
[[],{"__ref":"domain","__debug":"[('name','>=',current_date),('name','<=',current_date)]","__id":"5dedcfc96648"}],
|
[[],{"__ref":"domain","__debug":"[('name','>=',current_date),('name','<=',current_date)]","__id":"5dedcfc96648"}],
|
||||||
openerp.connection.test_eval_get_context());
|
openerp.session.test_eval_get_context());
|
||||||
deepEqual(result, [
|
deepEqual(result, [
|
||||||
['name', '>=', current_date],
|
['name', '>=', current_date],
|
||||||
['name', '<=', current_date]
|
['name', '<=', current_date]
|
||||||
|
|
|
@ -7,7 +7,7 @@ $(document).ready(function () {
|
||||||
t.module('Dataset shortcuts', 'data');
|
t.module('Dataset shortcuts', 'data');
|
||||||
t.test('read_index', function (openerp) {
|
t.test('read_index', function (openerp) {
|
||||||
var ds = new openerp.web.DataSet(
|
var ds = new openerp.web.DataSet(
|
||||||
{session: openerp.connection}, 'some.model');
|
{session: openerp.session}, 'some.model');
|
||||||
ds.ids = [10, 20, 30, 40, 50];
|
ds.ids = [10, 20, 30, 40, 50];
|
||||||
ds.index = 2;
|
ds.index = 2;
|
||||||
t.expect(ds.read_index(['a', 'b', 'c']), function (result) {
|
t.expect(ds.read_index(['a', 'b', 'c']), function (result) {
|
||||||
|
@ -24,7 +24,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
t.test('default_get', function (openerp) {
|
t.test('default_get', function (openerp) {
|
||||||
var ds = new openerp.web.DataSet(
|
var ds = new openerp.web.DataSet(
|
||||||
{session: openerp.connection}, 'some.model', {foo: 'bar'});
|
{session: openerp.session}, 'some.model', {foo: 'bar'});
|
||||||
t.expect(ds.default_get(['a', 'b', 'c']), function (result) {
|
t.expect(ds.default_get(['a', 'b', 'c']), function (result) {
|
||||||
strictEqual(result.method, 'default_get');
|
strictEqual(result.method, 'default_get');
|
||||||
strictEqual(result.model, 'some.model');
|
strictEqual(result.model, 'some.model');
|
||||||
|
@ -38,7 +38,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
t.test('create', function (openerp) {
|
t.test('create', function (openerp) {
|
||||||
var ds = new openerp.web.DataSet({session: openerp.connection}, 'some.model');
|
var ds = new openerp.web.DataSet({session: openerp.session}, 'some.model');
|
||||||
t.expect(ds.create({foo: 1, bar: 2}), function (r) {
|
t.expect(ds.create({foo: 1, bar: 2}), function (r) {
|
||||||
strictEqual(r.method, 'create');
|
strictEqual(r.method, 'create');
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
t.test('write', function (openerp) {
|
t.test('write', function (openerp) {
|
||||||
var ds = new openerp.web.DataSet({session: openerp.connection}, 'mod');
|
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
||||||
t.expect(ds.write(42, {foo: 1}), function (r) {
|
t.expect(ds.write(42, {foo: 1}), function (r) {
|
||||||
strictEqual(r.method, 'write');
|
strictEqual(r.method, 'write');
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ $(document).ready(function () {
|
||||||
// });
|
// });
|
||||||
});
|
});
|
||||||
t.test('unlink', function (openerp) {
|
t.test('unlink', function (openerp) {
|
||||||
var ds = new openerp.web.DataSet({session: openerp.connection}, 'mod');
|
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
||||||
t.expect(ds.unlink([42]), function (r) {
|
t.expect(ds.unlink([42]), function (r) {
|
||||||
strictEqual(r.method, 'unlink');
|
strictEqual(r.method, 'unlink');
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
t.test('call', function (openerp) {
|
t.test('call', function (openerp) {
|
||||||
var ds = new openerp.web.DataSet({session: openerp.connection}, 'mod');
|
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
||||||
t.expect(ds.call('frob', ['a', 'b', 42]), function (r) {
|
t.expect(ds.call('frob', ['a', 'b', 42]), function (r) {
|
||||||
strictEqual(r.method, 'frob');
|
strictEqual(r.method, 'frob');
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
t.test('name_get', function (openerp) {
|
t.test('name_get', function (openerp) {
|
||||||
var ds = new openerp.web.DataSet({session: openerp.connection}, 'mod');
|
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
||||||
t.expect(ds.name_get([1, 2], null), function (r) {
|
t.expect(ds.name_get([1, 2], null), function (r) {
|
||||||
strictEqual(r.method, 'name_get');
|
strictEqual(r.method, 'name_get');
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
t.test('name_search, name', function (openerp) {
|
t.test('name_search, name', function (openerp) {
|
||||||
var ds = new openerp.web.DataSet({session: openerp.connection}, 'mod');
|
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
||||||
t.expect(ds.name_search('bob'), function (r) {
|
t.expect(ds.name_search('bob'), function (r) {
|
||||||
strictEqual(r.method, 'name_search');
|
strictEqual(r.method, 'name_search');
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
t.test('name_search, domain & operator', function (openerp) {
|
t.test('name_search, domain & operator', function (openerp) {
|
||||||
var ds = new openerp.web.DataSet({session: openerp.connection}, 'mod');
|
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
||||||
t.expect(ds.name_search(0, [['foo', '=', 3]], 'someop'), function (r) {
|
t.expect(ds.name_search(0, [['foo', '=', 3]], 'someop'), function (r) {
|
||||||
strictEqual(r.method, 'name_search');
|
strictEqual(r.method, 'name_search');
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
t.test('exec_workflow', function (openerp) {
|
t.test('exec_workflow', function (openerp) {
|
||||||
var ds = new openerp.web.DataSet({session: openerp.connection}, 'mod');
|
var ds = new openerp.web.DataSet({session: openerp.session}, 'mod');
|
||||||
t.expect(ds.exec_workflow(42, 'foo'), function (r) {
|
t.expect(ds.exec_workflow(42, 'foo'), function (r) {
|
||||||
strictEqual(r['service'], 'object');
|
strictEqual(r['service'], 'object');
|
||||||
strictEqual(r.method, 'exec_workflow');
|
strictEqual(r.method, 'exec_workflow');
|
||||||
|
@ -147,7 +147,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
t.test('DataSetSearch#read_slice', function (openerp) {
|
t.test('DataSetSearch#read_slice', function (openerp) {
|
||||||
var ds = new openerp.web.DataSetSearch({session: openerp.connection}, 'mod');
|
var ds = new openerp.web.DataSetSearch({session: openerp.session}, 'mod');
|
||||||
t.expect(ds.read_slice(['foo', 'bar'], {
|
t.expect(ds.read_slice(['foo', 'bar'], {
|
||||||
domain: [['foo', '>', 42], ['qux', '=', 'grault']],
|
domain: [['foo', '>', 42], ['qux', '=', 'grault']],
|
||||||
context: {peewee: 'herman'},
|
context: {peewee: 'herman'},
|
||||||
|
@ -167,7 +167,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
t.test('DataSetSearch#read_slice sorted', function (openerp) {
|
t.test('DataSetSearch#read_slice sorted', function (openerp) {
|
||||||
var ds = new openerp.web.DataSetSearch({session: openerp.connection}, 'mod');
|
var ds = new openerp.web.DataSetSearch({session: openerp.session}, 'mod');
|
||||||
ds.sort('foo');
|
ds.sort('foo');
|
||||||
ds.sort('foo');
|
ds.sort('foo');
|
||||||
ds.sort('bar');
|
ds.sort('bar');
|
||||||
|
@ -194,7 +194,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
t.test('Dataset', function (openerp) {
|
t.test('Dataset', function (openerp) {
|
||||||
var ds = new openerp.web.DataSetSearch(
|
var ds = new openerp.web.DataSetSearch(
|
||||||
{session: openerp.connection}, 'mod');
|
{session: openerp.session}, 'mod');
|
||||||
var c = new openerp.web.CompoundContext(
|
var c = new openerp.web.CompoundContext(
|
||||||
{a: 'foo', b: 3, c: 5}, openerp.contexts[0]);
|
{a: 'foo', b: 3, c: 5}, openerp.contexts[0]);
|
||||||
t.expect(ds.read_slice(['foo', 'bar'], {
|
t.expect(ds.read_slice(['foo', 'bar'], {
|
||||||
|
@ -220,7 +220,7 @@ $(document).ready(function () {
|
||||||
parent: {model: 'qux'}
|
parent: {model: 'qux'}
|
||||||
};
|
};
|
||||||
var ds = new openerp.web.DataSet(
|
var ds = new openerp.web.DataSet(
|
||||||
{session: openerp.connection}, 'mod',
|
{session: openerp.session}, 'mod',
|
||||||
new openerp.web.CompoundContext({})
|
new openerp.web.CompoundContext({})
|
||||||
.set_eval_context(eval_context));
|
.set_eval_context(eval_context));
|
||||||
var domain = new openerp.web.CompoundDomain(openerp.domains[0])
|
var domain = new openerp.web.CompoundDomain(openerp.domains[0])
|
||||||
|
|
|
@ -87,10 +87,10 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
asyncTest('toggle-edition-save', 4, function () {
|
asyncTest('toggle-edition-save', 4, function () {
|
||||||
instance.connection.responses['/web/dataset/call_kw:create'] = function () {
|
instance.session.responses['/web/dataset/call_kw:create'] = function () {
|
||||||
return { result: 42 };
|
return { result: 42 };
|
||||||
};
|
};
|
||||||
instance.connection.responses['/web/dataset/call_kw:read'] = function () {
|
instance.session.responses['/web/dataset/call_kw:read'] = function () {
|
||||||
return { result: [{
|
return { result: [{
|
||||||
id: 42,
|
id: 42,
|
||||||
a: false,
|
a: false,
|
||||||
|
@ -125,7 +125,7 @@ $(document).ready(function () {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
asyncTest('toggle-edition-cancel', 2, function () {
|
asyncTest('toggle-edition-cancel', 2, function () {
|
||||||
instance.connection.responses['/web/dataset/call_kw:create'] = function () {
|
instance.session.responses['/web/dataset/call_kw:create'] = function () {
|
||||||
return { result: 42 };
|
return { result: 42 };
|
||||||
};
|
};
|
||||||
var e = new instance.web.list.Editor({
|
var e = new instance.web.list.Editor({
|
||||||
|
@ -153,7 +153,7 @@ $(document).ready(function () {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
asyncTest('toggle-save-required', 2, function () {
|
asyncTest('toggle-save-required', 2, function () {
|
||||||
instance.connection.responses['/web/dataset/call_kw:create'] = function () {
|
instance.session.responses['/web/dataset/call_kw:create'] = function () {
|
||||||
return { result: 42 };
|
return { result: 42 };
|
||||||
};
|
};
|
||||||
var e = new instance.web.list.Editor({
|
var e = new instance.web.list.Editor({
|
||||||
|
@ -191,7 +191,7 @@ $(document).ready(function () {
|
||||||
baseSetup();
|
baseSetup();
|
||||||
|
|
||||||
var records = {};
|
var records = {};
|
||||||
_.extend(instance.connection.responses, {
|
_.extend(instance.session.responses, {
|
||||||
'/web/listview/load': function () {
|
'/web/listview/load': function () {
|
||||||
return {result: {
|
return {result: {
|
||||||
type: 'tree',
|
type: 'tree',
|
||||||
|
@ -227,7 +227,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
asyncTest('newrecord', 6, function () {
|
asyncTest('newrecord', 6, function () {
|
||||||
var got_defaults = false;
|
var got_defaults = false;
|
||||||
instance.connection.responses['/web/dataset/call_kw:default_get'] = function (params) {
|
instance.session.responses['/web/dataset/call_kw:default_get'] = function (params) {
|
||||||
var fields = params.params.args[0];
|
var fields = params.params.args[0];
|
||||||
deepEqual(
|
deepEqual(
|
||||||
fields, ['a', 'b', 'c'],
|
fields, ['a', 'b', 'c'],
|
||||||
|
@ -267,7 +267,7 @@ $(document).ready(function () {
|
||||||
module('list-edition-events', {
|
module('list-edition-events', {
|
||||||
setup: function () {
|
setup: function () {
|
||||||
baseSetup();
|
baseSetup();
|
||||||
_.extend(instance.connection.responses, {
|
_.extend(instance.session.responses, {
|
||||||
'/web/listview/load': function () {
|
'/web/listview/load': function () {
|
||||||
return {result: {
|
return {result: {
|
||||||
type: 'tree',
|
type: 'tree',
|
||||||
|
|
|
@ -164,8 +164,8 @@ $(document).ready(function () {
|
||||||
instance.dummy = {};
|
instance.dummy = {};
|
||||||
instance.dummy.DummyWidget = instance.web.search.Field.extend(
|
instance.dummy.DummyWidget = instance.web.search.Field.extend(
|
||||||
dummy_widget_attributes || {});
|
dummy_widget_attributes || {});
|
||||||
if (!('/web/searchview/load' in instance.connection.responses)) {
|
if (!('/web/searchview/load' in instance.session.responses)) {
|
||||||
instance.connection.responses['/web/searchview/load'] = function () {
|
instance.session.responses['/web/searchview/load'] = function () {
|
||||||
return {result: {fields_view: {
|
return {result: {fields_view: {
|
||||||
type: 'search',
|
type: 'search',
|
||||||
fields: {
|
fields: {
|
||||||
|
@ -186,10 +186,10 @@ $(document).ready(function () {
|
||||||
}}};
|
}}};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
instance.connection.responses['/web/searchview/get_filters'] = function () {
|
instance.session.responses['/web/searchview/get_filters'] = function () {
|
||||||
return {result: []};
|
return {result: []};
|
||||||
};
|
};
|
||||||
instance.connection.responses['/web/searchview/fields_get'] = function () {
|
instance.session.responses['/web/searchview/fields_get'] = function () {
|
||||||
return {result: {fields: {
|
return {result: {fields: {
|
||||||
dummy: {type: 'char', string: 'Dummy'}
|
dummy: {type: 'char', string: 'Dummy'}
|
||||||
}}};
|
}}};
|
||||||
|
@ -321,7 +321,7 @@ $(document).ready(function () {
|
||||||
{attrs: {name: 'dummy', string: 'Dummy'}},
|
{attrs: {name: 'dummy', string: 'Dummy'}},
|
||||||
{relation: 'dummy.model.name'},
|
{relation: 'dummy.model.name'},
|
||||||
view);
|
view);
|
||||||
instance.connection.responses['/web/dataset/call_kw'] = function (req) {
|
instance.session.responses['/web/dataset/call_kw'] = function (req) {
|
||||||
equal(req.params.method, 'name_get',
|
equal(req.params.method, 'name_get',
|
||||||
"m2o should resolve default id");
|
"m2o should resolve default id");
|
||||||
equal(req.params.model, f.attrs.relation,
|
equal(req.params.model, f.attrs.relation,
|
||||||
|
@ -357,7 +357,7 @@ $(document).ready(function () {
|
||||||
{attrs: {name: 'dummy', string: 'Dummy'}},
|
{attrs: {name: 'dummy', string: 'Dummy'}},
|
||||||
{relation: 'dummy.model.name'},
|
{relation: 'dummy.model.name'},
|
||||||
view);
|
view);
|
||||||
instance.connection.responses['/web/dataset/call_kw'] = function (req) {
|
instance.session.responses['/web/dataset/call_kw'] = function (req) {
|
||||||
return {result: []};
|
return {result: []};
|
||||||
};
|
};
|
||||||
f.facet_for_defaults({dummy: id})
|
f.facet_for_defaults({dummy: id})
|
||||||
|
@ -573,7 +573,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
asyncTest("M2O", 15, function () {
|
asyncTest("M2O", 15, function () {
|
||||||
instance.connection.responses['/web/dataset/call_kw'] = function (req) {
|
instance.session.responses['/web/dataset/call_kw'] = function (req) {
|
||||||
equal(req.params.method, "name_search");
|
equal(req.params.method, "name_search");
|
||||||
equal(req.params.model, "dummy.model");
|
equal(req.params.model, "dummy.model");
|
||||||
deepEqual(req.params.args, []);
|
deepEqual(req.params.args, []);
|
||||||
|
@ -607,7 +607,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
asyncTest("M2O no match", 5, function () {
|
asyncTest("M2O no match", 5, function () {
|
||||||
instance.connection.responses['/web/dataset/call_kw'] = function (req) {
|
instance.session.responses['/web/dataset/call_kw'] = function (req) {
|
||||||
equal(req.params.method, "name_search");
|
equal(req.params.method, "name_search");
|
||||||
equal(req.params.model, "dummy.model");
|
equal(req.params.model, "dummy.model");
|
||||||
deepEqual(req.params.args, []);
|
deepEqual(req.params.args, []);
|
||||||
|
@ -1070,7 +1070,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
asyncTest('checkboxing', 6, function () {
|
asyncTest('checkboxing', 6, function () {
|
||||||
var view = makeSearchView();
|
var view = makeSearchView();
|
||||||
instance.connection.responses['/web/searchview/get_filters'] = function () {
|
instance.session.responses['/web/searchview/get_filters'] = function () {
|
||||||
return {result: [{
|
return {result: [{
|
||||||
name: "filter name",
|
name: "filter name",
|
||||||
user_id: 42
|
user_id: 42
|
||||||
|
@ -1099,7 +1099,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
asyncTest('removal', 1, function () {
|
asyncTest('removal', 1, function () {
|
||||||
var view = makeSearchView();
|
var view = makeSearchView();
|
||||||
instance.connection.responses['/web/searchview/get_filters'] = function () {
|
instance.session.responses['/web/searchview/get_filters'] = function () {
|
||||||
return {result: [{
|
return {result: [{
|
||||||
name: "filter name",
|
name: "filter name",
|
||||||
user_id: 42
|
user_id: 42
|
||||||
|
|
|
@ -33,28 +33,28 @@ openerp.testing = (function () {
|
||||||
instance.web.qweb.add_template(doc);
|
instance.web.qweb.add_template(doc);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Alter provided instance's ``connection`` attribute to make response
|
* Alter provided instance's ``session`` attribute to make response
|
||||||
* mockable:
|
* mockable:
|
||||||
*
|
*
|
||||||
* * The ``responses`` parameter can be used to provide a map of (RPC)
|
* * The ``responses`` parameter can be used to provide a map of (RPC)
|
||||||
* paths (e.g. ``/web/view/load``) to a function returning a response
|
* paths (e.g. ``/web/view/load``) to a function returning a response
|
||||||
* to the query.
|
* to the query.
|
||||||
* * ``instance,connection`` grows a ``responses`` attribute which is
|
* * ``instance.session`` grows a ``responses`` attribute which is
|
||||||
* a map of the same (and is in fact initialized to the ``responses``
|
* a map of the same (and is in fact initialized to the ``responses``
|
||||||
* parameter if one is provided)
|
* parameter if one is provided)
|
||||||
*
|
*
|
||||||
* Note that RPC requests to un-mocked URLs will be rejected with an
|
* Note that RPC requests to un-mocked URLs will be rejected with an
|
||||||
* error message: only explicitly specified urls will get a response.
|
* error message: only explicitly specified urls will get a response.
|
||||||
*
|
*
|
||||||
* Mocked connections will *never* perform an actual RPC connection.
|
* Mocked sessions will *never* perform an actual RPC connection.
|
||||||
*
|
*
|
||||||
* @param instance openerp instance being initialized
|
* @param instance openerp instance being initialized
|
||||||
* @param {Object} [responses]
|
* @param {Object} [responses]
|
||||||
*/
|
*/
|
||||||
mockifyRPC: function (instance, responses) {
|
mockifyRPC: function (instance, responses) {
|
||||||
var connection = instance.connection;
|
var session = instance.session;
|
||||||
connection.responses = responses || {};
|
session.responses = responses || {};
|
||||||
connection.rpc_function = function (url, payload) {
|
session.rpc_function = function (url, payload) {
|
||||||
var fn = this.responses[url.url + ':' + payload.params.method]
|
var fn = this.responses[url.url + ':' + payload.params.method]
|
||||||
|| this.responses[url.url];
|
|| this.responses[url.url];
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
||||||
this.aggregates = {};
|
this.aggregates = {};
|
||||||
this.group_operators = ['avg', 'max', 'min', 'sum', 'count'];
|
this.group_operators = ['avg', 'max', 'min', 'sum', 'count'];
|
||||||
this.qweb = new QWeb2.Engine();
|
this.qweb = new QWeb2.Engine();
|
||||||
this.qweb.debug = instance.connection.debug;
|
this.qweb.debug = instance.session.debug;
|
||||||
this.qweb.default_dict = _.clone(QWeb.default_dict);
|
this.qweb.default_dict = _.clone(QWeb.default_dict);
|
||||||
this.has_been_loaded = $.Deferred();
|
this.has_been_loaded = $.Deferred();
|
||||||
this.search_domain = this.search_context = this.search_group_by = null;
|
this.search_domain = this.search_context = this.search_group_by = null;
|
||||||
|
@ -132,7 +132,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
||||||
node.children = [{
|
node.children = [{
|
||||||
tag: 'img',
|
tag: 'img',
|
||||||
attrs: {
|
attrs: {
|
||||||
src: instance.connection.prefix + '/web/static/src/img/icons/' + node.attrs['data-icon'] + '.png',
|
src: instance.session.prefix + '/web/static/src/img/icons/' + node.attrs['data-icon'] + '.png',
|
||||||
width: '16',
|
width: '16',
|
||||||
height: '16'
|
height: '16'
|
||||||
}
|
}
|
||||||
|
@ -760,7 +760,7 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({
|
||||||
url = "/web/static/src/img/placeholder.png";
|
url = "/web/static/src/img/placeholder.png";
|
||||||
} else {
|
} else {
|
||||||
id = escape(JSON.stringify(id));
|
id = escape(JSON.stringify(id));
|
||||||
url = instance.connection.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + id;
|
url = instance.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + id;
|
||||||
if (cache !== undefined) {
|
if (cache !== undefined) {
|
||||||
// Set the cache duration in seconds.
|
// Set the cache duration in seconds.
|
||||||
url += '&cache=' + parseInt(cache, 10);
|
url += '&cache=' + parseInt(cache, 10);
|
||||||
|
|
Loading…
Reference in New Issue