OpenERP Online has proposed merging
lp:~openerp-dev/openerp-web/trunk-qweb_manifest2-chs into lp:openerp-web.
Requested reviews:
OpenERP R&D Web Team (openerp-dev-web)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-qweb_manifest2-chs/+merge/81001
--
https://code.launchpad.net/~openerp-dev/openerp-web/trunk-qweb_manifest2-chs/+merge/81001
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openerp-web/trunk-qweb_manifest2-chs.
=== modified file 'addons/web/__openerp__.py'
--- addons/web/__openerp__.py 2011-10-25 08:36:48 +0000
+++ addons/web/__openerp__.py 2011-11-02 11:13:23 +0000
@@ -52,4 +52,7 @@
"static/src/css/data_export.css",
"static/src/css/data_import.css",
],
+ 'qweb' : [
+ "static/src/xml/*.xml",
+ ],
}
=== modified file 'addons/web/controllers/main.py'
--- addons/web/controllers/main.py 2011-10-24 14:06:58 +0000
+++ addons/web/controllers/main.py 2011-11-02 11:13:23 +0000
@@ -24,6 +24,32 @@
# OpenERP Web web Controllers
#----------------------------------------------------------
+
+def concat_xml(file_list):
+ """Concatenate xml files
+ return (concat,timestamp)
+ concat: concatenation of file content
+ timestamp: max(os.path.getmtime of file_list)
+ """
+ root = None
+ files_timestamp = 0
+ for fname in file_list:
+ ftime = os.path.getmtime(fname)
+ if ftime > files_timestamp:
+ files_timestamp = ftime
+
+ xml = ElementTree.parse(fname).getroot()
+
+ if root is None:
+ root = ElementTree.Element(xml.tag)
+ #elif root.tag != xml.tag:
+ # raise ValueError("Root tags missmatch: %r != %r" % (root.tag, xml.tag))
+
+ for child in xml.getchildren():
+ root.append(child)
+ return ElementTree.tostring(root, 'utf-8'), files_timestamp
+
+
def concat_files(file_list):
""" Concatenate file content
return (concat,timestamp)
@@ -98,6 +124,10 @@
def jslist(self, req, mods=None):
return self.manifest_list(req, mods, 'js')
+ @openerpweb.jsonrequest
+ def qweblist(self, req, mods=None):
+ return self.manifest_list(req, mods, 'qweb')
+
@openerpweb.httprequest
def css(self, req, mods=None):
files = [f[0] for f in self.manifest_glob(req, mods, 'css')]
@@ -113,6 +143,14 @@
return req.make_response(content, [('Content-Type', 'application/javascript')])
@openerpweb.httprequest
+ def qweb(self, req, mods=None):
+ files = [f[0] for f in self.manifest_glob(req, mods, 'qweb')]
+ content,timestamp = concat_xml(files)
+ # TODO use timestamp to set Last mofified date and E-tag
+ return req.make_response(content, [('Content-Type', 'text/xml')])
+
+
+ @openerpweb.httprequest
def home(self, req, s_action=None, **kw):
js = "\n ".join('<script type="text/javascript" src="%s"></script>'%i for i in self.manifest_list(req, None, 'js'))
css = "\n ".join('<link rel="stylesheet" href="%s">'%i for i in self.manifest_list(req, None, 'css'))
=== modified file 'addons/web/static/src/js/boot.js'
--- addons/web/static/src/js/boot.js 2011-09-27 11:14:02 +0000
+++ addons/web/static/src/js/boot.js 2011-11-02 11:13:23 +0000
@@ -21,7 +21,16 @@
*
* @param {Array} modules list of modules to initialize
*/
- init: function(modules) {
+ init: function(modules, connection, callback) {
+
+ if (/^(function|undefined)$/.test(typeof connection)) {
+ callback = connection;
+ connection = {
+ host: document.location.protocol + '//' + document.location.host,
+ };
+ }
+
+
var new_instance = {
// links to the global openerp
_openerp: openerp,
@@ -39,6 +48,20 @@
for(var i=0; i < modules.length; i++) {
openerp[modules[i]](new_instance);
}
+
+ new_instance.connector = new new_instance.web.Connection(connection.host);
+ if (connection.login) {
+ new_instance.connector.login(connection.database, connection.login, connection.password, function() {
+ if (callback) {
+ callback(new_instance);
+ }
+ });
+ } else {
+ if (callback) {
+ callback(new_instance);
+ }
+ }
+
return new_instance;
}
};
=== modified file 'addons/web/static/src/js/chrome.js'
--- addons/web/static/src/js/chrome.js 2011-10-28 08:52:12 +0000
+++ addons/web/static/src/js/chrome.js 2011-11-02 11:13:23 +0000
@@ -136,10 +136,10 @@
}
});
-openerp.web.CrashManager = openerp.web.SessionAware.extend({
- init: function(parent) {
- this._super((parent || {}).session);
- this.session.on_rpc_error.add(this.on_rpc_error);
+openerp.web.CrashManager = openerp.web.CallbackEnabled.extend({
+ init: function() {
+ this._super();
+ openerp.connector.on_rpc_error.add(this.on_rpc_error);
},
on_rpc_error: function(error) {
this.error = error;
@@ -959,17 +959,15 @@
this._super(null, element_id);
openerp.webclient = this;
- QWeb.add_template("/web/static/src/xml/base.xml");
var params = {};
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.notification = new openerp.web.Notification();
- this.session = new openerp.web.Session();
+ this.notification = new openerp.web.Notification(this);
this.loading = new openerp.web.Loading(this,"oe_loading");
- this.crashmanager = new openerp.web.CrashManager(this);
+ this.crashmanager = new openerp.web.CrashManager();
this.header = new openerp.web.Header(this);
this.login = new openerp.web.Login(this);
=== modified file 'addons/web/static/src/js/core.js'
--- addons/web/static/src/js/core.js 2011-10-27 12:45:03 +0000
+++ addons/web/static/src/js/core.js 2011-11-02 11:13:23 +0000
@@ -237,8 +237,8 @@
* registry was created.
*
* An object path is simply a dotted name from the openerp root to the
- * object pointed to (e.g. ``"openerp.web.Session"`` for an OpenERP
- * session object).
+ * object pointed to (e.g. ``"openerp.web.Connection"`` for an OpenERP
+ * connection object).
*
* @constructs openerp.web.Registry
* @param {Object} mapping a mapping of keys to object-paths
@@ -338,9 +338,9 @@
}
});
-openerp.web.Session = openerp.web.CallbackEnabled.extend( /** @lends openerp.web.Session# */{
+openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp.web.Connection# */{
/**
- * @constructs openerp.web.Session
+ * @constructs openerp.web.Connection
* @extends openerp.web.CallbackEnabled
*
* @param {String} [server] JSON-RPC endpoint hostname
@@ -364,7 +364,9 @@
// TODO: session should have an optional name indicating that they'll
// be saved to (and revived from) cookies
this.name = 'session';
+ this.do_load_qweb(['/web/webclient/qweb']);
},
+
start: function() {
this.session_restore();
},
@@ -487,9 +489,11 @@
self.user_context = result.context;
self.db = result.db;
self.session_save();
+ self.on_session_valid();
return true;
}).then(success_callback);
},
+ login: function() { this.session_login.apply(this, arguments); },
/**
* Reloads uid and session_id from local storage, if they exist
*/
@@ -577,6 +581,7 @@
self.rpc('/web/webclient/jslist', {"mods": modules}, function(files) {
self.do_load_js(file_list.concat(files));
});
+ self.rpc('/web/webclient/qweblist', {"mods": modules}, self.do_load_qweb);
openerp._modules_loaded = true;
});
});
@@ -610,6 +615,19 @@
this.on_modules_loaded();
}
},
+ do_load_qweb: function(files) {
+ var self = this;
+ _.each(files, function(file) {
+ $.ajax({
+ url: file,
+ type: 'get',
+ async: false,
+ dataType: 'text',
+ }).then(function(xml) {
+ openerp.web.qweb.add_template(_(xml).trim());
+ });
+ });
+ },
on_modules_loaded: function() {
for(var j=0; j<this.module_list.length; j++) {
var mod = this.module_list[j];
@@ -716,36 +734,6 @@
}
});
-openerp.web.SessionAware = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.SessionAware# */{
- /**
- * Utility class that any class is allowed to extend to easy common manipulations.
- *
- * It provides rpc calls, callback on all methods preceded by "on_" or "do_" and a
- * logging facility.
- *
- * @constructs openerp.web.SessionAware
- * @extends openerp.web.CallbackEnabled
- *
- * @param {openerp.web.Session} session
- */
- init: function(session) {
- this._super();
- this.session = session;
- },
- /**
- * Performs a JSON-RPC call
- *
- * @param {String} url endpoint url
- * @param {Object} data RPC parameters
- * @param {Function} success RPC call success callback
- * @param {Function} error RPC call error callback
- * @returns {jQuery.Deferred} deferred object for the RPC call
- */
- rpc: function(url, data, success, error) {
- return this.session.rpc(url, data, success, error);
- }
-});
-
/**
* Base class for all visual components. Provides a lot of functionalities helpful
* for the management of a part of the DOM.
@@ -756,8 +744,6 @@
* destroyed too).
* - Insertion in DOM.
*
- * Widget also extends SessionAware for ease of use.
- *
* Guide to create implementations of the Widget class:
* ==============================================
*
@@ -798,7 +784,7 @@
*
* That will kill the widget in a clean way and erase its content from the dom.
*/
-openerp.web.Widget = openerp.web.SessionAware.extend(/** @lends openerp.web.Widget# */{
+openerp.web.Widget = openerp.web.CallbackEnabled.extend(/** @lends openerp.web.Widget# */{
/**
* The name of the QWeb template that will be used for rendering. Must be
* redefined in subclasses or the default render() method can not be used.
@@ -817,7 +803,7 @@
* Construct the widget and set its parent if a parent is given.
*
* @constructs openerp.web.Widget
- * @extends openerp.web.SessionAware
+ * @extends openerp.web.CallbackEnabled
*
* @param {openerp.web.Widget} parent Binds the current instance to the given Widget instance.
* When that widget is destroyed by calling stop(), the current instance will be
@@ -828,7 +814,8 @@
* for new components this argument should not be provided any more.
*/
init: function(parent, /** @deprecated */ element_id) {
- this._super((parent || {}).session);
+ this._super();
+ this.session = openerp.connector;
// if given an element_id, try to get the associated DOM element and save
// a reference in this.$element. Else just generate a unique identifier.
this.element_id = element_id;
@@ -967,7 +954,7 @@
rpc: function(url, data, success, error) {
var def = $.Deferred().then(success, error);
var self = this;
- this._super(url, data). then(function() {
+ openerp.connector.rpc(url, data). then(function() {
if (!self.widget_is_stopped)
def.resolve.apply(def, arguments);
}, function() {
=== modified file 'addons/web/static/src/js/data.js'
--- addons/web/static/src/js/data.js 2011-10-21 12:06:45 +0000
+++ addons/web/static/src/js/data.js 2011-11-02 11:13:23 +0000
@@ -32,7 +32,7 @@
* @constructs openerp.web.DataGroup
* @extends openerp.web.Widget
*
- * @param {openerp.web.Session} session Current OpenERP session
+ * @param {openerp.web.Widget} parent widget
* @param {String} model name of the model managed by this DataGroup
* @param {Array} domain search domain for this DataGroup
* @param {Object} context context of the DataGroup's searches
@@ -785,11 +785,15 @@
on_unlink: function(ids) {}
});
-openerp.web.Model = openerp.web.SessionAware.extend({
- init: function(session, model_name) {
- this._super(session);
+openerp.web.Model = openerp.web.CallbackEnabled.extend({
+ init: function(_, model_name) {
+ this._super();
this.model_name = model_name;
},
+ rpc: function() {
+ var c = openerp.connector;
+ return c.rpc.apply(c, arguments);
+ },
get_func: function(method_name) {
var self = this;
return function() {
=== modified file 'addons/web/static/src/js/search.js'
--- addons/web/static/src/js/search.js 2011-10-24 15:26:12 +0000
+++ addons/web/static/src/js/search.js 2011-11-02 11:13:23 +0000
@@ -433,6 +433,7 @@
* @param view the ancestor view of this widget
*/
init: function (view) {
+ this._super(view);
this.view = view;
},
/**
@@ -473,10 +474,8 @@
this._super();
},
render: function (defaults) {
- return QWeb.render(
- this.template, _.extend(this, {
- defaults: defaults
- }));
+ // FIXME
+ return this._super(_.extend(this, {defaults: defaults}));
}
});
openerp.web.search.add_expand_listener = function($root) {
=== modified file 'addons/web_calendar/__openerp__.py'
--- addons/web_calendar/__openerp__.py 2011-10-05 14:36:07 +0000
+++ addons/web_calendar/__openerp__.py 2011-11-02 11:13:23 +0000
@@ -11,5 +11,8 @@
"css": ['static/lib/dhtmlxScheduler/codebase/dhtmlxscheduler.css',
'static/lib/dhtmlxScheduler/codebase/ext/dhtmlxscheduler_ext.css'
],
+ 'qweb' : [
+ "static/src/xml/*.xml",
+ ],
'active': True
}
=== modified file 'addons/web_calendar/static/src/js/calendar.js'
--- addons/web_calendar/static/src/js/calendar.js 2011-10-20 10:39:26 +0000
+++ addons/web_calendar/static/src/js/calendar.js 2011-11-02 11:13:23 +0000
@@ -5,7 +5,6 @@
openerp.web_calendar = function(openerp) {
var _t = openerp.web._t;
var QWeb = openerp.web.qweb;
-QWeb.add_template('/web_calendar/static/src/xml/web_calendar.xml');
openerp.web.views.add('calendar', 'openerp.web_calendar.CalendarView');
openerp.web_calendar.CalendarView = openerp.web.View.extend({
// Dhtmlx scheduler ?
=== modified file 'addons/web_dashboard/__openerp__.py'
--- addons/web_dashboard/__openerp__.py 2011-10-05 14:36:07 +0000
+++ addons/web_dashboard/__openerp__.py 2011-11-02 11:13:23 +0000
@@ -7,5 +7,8 @@
'static/src/js/dashboard.js'
],
"css": ['static/src/css/dashboard.css'],
+ 'qweb' : [
+ "static/src/xml/*.xml",
+ ],
'active': True
}
=== modified file 'addons/web_dashboard/static/src/js/dashboard.js'
--- addons/web_dashboard/static/src/js/dashboard.js 2011-10-27 12:45:03 +0000
+++ addons/web_dashboard/static/src/js/dashboard.js 2011-11-02 11:13:23 +0000
@@ -1,6 +1,5 @@
openerp.web_dashboard = function(openerp) {
var QWeb = openerp.web.qweb;
-QWeb.add_template('/web_dashboard/static/src/xml/web_dashboard.xml');
if (!openerp.web_dashboard) {
/** @namespace */
=== modified file 'addons/web_diagram/__openerp__.py'
--- addons/web_diagram/__openerp__.py 2011-10-05 14:36:07 +0000
+++ addons/web_diagram/__openerp__.py 2011-11-02 11:13:23 +0000
@@ -13,5 +13,8 @@
'css' : [
"static/src/css/base_diagram.css",
],
+ 'qweb' : [
+ "static/src/xml/*.xml",
+ ],
'active': True,
}
=== modified file 'addons/web_diagram/static/src/js/diagram.js'
--- addons/web_diagram/static/src/js/diagram.js 2011-10-26 13:52:20 +0000
+++ addons/web_diagram/static/src/js/diagram.js 2011-11-02 11:13:23 +0000
@@ -4,7 +4,6 @@
openerp.web_diagram = function (openerp) {
var QWeb = openerp.web.qweb;
-QWeb.add_template('/web_diagram/static/src/xml/base_diagram.xml');
openerp.web.views.add('diagram', 'openerp.web.DiagramView');
openerp.web.DiagramView = openerp.web.View.extend({
searchable: false,
=== modified file 'addons/web_gantt/__openerp__.py'
--- addons/web_gantt/__openerp__.py 2011-10-05 14:36:07 +0000
+++ addons/web_gantt/__openerp__.py 2011-11-02 11:13:23 +0000
@@ -9,5 +9,8 @@
'static/src/js/gantt.js'
],
"css": ['static/lib/dhtmlxGantt/codebase/dhtmlxgantt.css'],
+ 'qweb' : [
+ "static/src/xml/*.xml",
+ ],
'active': True
}
=== modified file 'addons/web_gantt/static/src/js/gantt.js'
--- addons/web_gantt/static/src/js/gantt.js 2011-10-24 10:10:15 +0000
+++ addons/web_gantt/static/src/js/gantt.js 2011-11-02 11:13:23 +0000
@@ -3,7 +3,6 @@
*---------------------------------------------------------*/
openerp.web_gantt = function (openerp) {
var QWeb = openerp.web.qweb;
-QWeb.add_template('/web_gantt/static/src/xml/web_gantt.xml');
openerp.web.views.add('gantt', 'openerp.web_gantt.GanttView');
openerp.web_gantt.GanttView = openerp.web.View.extend({
=== modified file 'addons/web_graph/__openerp__.py'
--- addons/web_graph/__openerp__.py 2011-10-05 14:36:07 +0000
+++ addons/web_graph/__openerp__.py 2011-11-02 11:13:23 +0000
@@ -7,5 +7,8 @@
"static/lib/dhtmlxGraph/codebase/dhtmlxchart_debug.js",
"static/src/js/graph.js"],
"css": ["static/lib/dhtmlxGraph/codebase/dhtmlxchart.css"],
+ 'qweb' : [
+ "static/src/xml/*.xml",
+ ],
"active": True
}
=== modified file 'addons/web_graph/static/src/js/graph.js'
--- addons/web_graph/static/src/js/graph.js 2011-10-28 12:26:08 +0000
+++ addons/web_graph/static/src/js/graph.js 2011-11-02 11:13:23 +0000
@@ -13,7 +13,6 @@
'#cc0000', '#d400a8'];
var QWeb = openerp.web.qweb;
-QWeb.add_template('/web_graph/static/src/xml/web_graph.xml');
openerp.web.views.add('graph', 'openerp.web_graph.GraphView');
openerp.web_graph.GraphView = openerp.web.View.extend({
=== modified file 'addons/web_kanban/__openerp__.py'
--- addons/web_kanban/__openerp__.py 2011-10-05 14:36:07 +0000
+++ addons/web_kanban/__openerp__.py 2011-11-02 11:13:23 +0000
@@ -9,5 +9,8 @@
"css": [
"static/src/css/kanban.css"
],
+ 'qweb' : [
+ "static/src/xml/*.xml",
+ ],
'active': True
}
=== modified file 'addons/web_kanban/static/src/js/kanban.js'
--- addons/web_kanban/static/src/js/kanban.js 2011-10-27 16:01:51 +0000
+++ addons/web_kanban/static/src/js/kanban.js 2011-11-02 11:13:23 +0000
@@ -16,7 +16,7 @@
this.all_display_data = false;
this.groups = [];
this.qweb = new QWeb2.Engine();
- this.qweb.debug = (window.location.search.indexOf('?debug') !== -1);
+ this.qweb.debug = openerp.connector.debug;
this.aggregates = {};
this.NO_OF_COLUMNS = 3;
this.form_dialog = new openerp.web.FormDialog(this, {}, this.options.action_views_ids.form, dataset).start();
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp