diff --git a/addons/base/controllers/main.py b/addons/base/controllers/main.py
index 41737d63179..ef693e27d12 100644
--- a/addons/base/controllers/main.py
+++ b/addons/base/controllers/main.py
@@ -349,10 +349,14 @@ class DataSet(openerpweb.Controller):
if not ids:
ids = Model.search(domain or [], offset or 0, limit or False,
sort or False, request.context)
+
if fields and fields == ['id']:
# shortcut read if we only want the ids
return map(lambda id: {'id': id}, ids)
- return Model.read(ids, fields or False, request.context)
+
+ reads = Model.read(ids, fields or False, request.context)
+ reads.sort(key=lambda obj: ids.index(obj['id']))
+ return reads
@openerpweb.jsonrequest
def get(self, request, model, ids, fields=False):
@@ -563,11 +567,11 @@ class ListView(View):
@openerpweb.jsonrequest
def fill(self, request, model, id, domain,
- offset=0, limit=False, ids=False):
- return self.do_fill(request, model, id, domain, offset, limit, ids)
+ offset=0, limit=False, sort=None, ids=False):
+ return self.do_fill(request, model, id, domain, offset, limit, sort=sort, ids=ids)
def do_fill(self, request, model, id, domain,
- offset=0, limit=False, ids=False):
+ offset=0, limit=False, sort=None, ids=False):
""" Returns all information needed to fill a table:
* view with processed ``editable`` flag
@@ -587,11 +591,22 @@ class ListView(View):
"""
view = self.fields_view_get(request, model, id, toolbar=True)
+ print sort
rows = DataSet().do_search_read(request, model,
offset=offset, limit=limit,
- domain=domain, ids=ids)
+ domain=domain, sort=sort, ids=ids)
eval_context = request.session.evaluation_context(
request.context)
+
+ if sort:
+ sort_criteria = sort.split(',')[0].split(' ')
+ print sort, sort_criteria
+ view['sorted'] = {
+ 'field': sort_criteria[0],
+ 'reversed': sort_criteria[1] == 'DESC'
+ }
+ else:
+ view['sorted'] = {}
return {
'view': view,
'records': [
diff --git a/addons/base/static/lib/qweb/qweb-benchmark.html b/addons/base/static/lib/qweb/qweb-benchmark.html
new file mode 100644
index 00000000000..0cc67e7e54f
--- /dev/null
+++ b/addons/base/static/lib/qweb/qweb-benchmark.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+Please, check your console for results
+
+
+
+
diff --git a/addons/base/static/lib/qweb/qweb-benchmark.xml b/addons/base/static/lib/qweb/qweb-benchmark.xml
new file mode 100644
index 00000000000..71452572e51
--- /dev/null
+++ b/addons/base/static/lib/qweb/qweb-benchmark.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+ d.iter = 'one,two,three,four,five'.split(',')
+
+
+
+ +
+
+
+ 1
+ true
+
+
+
+
height: 200px; border: 1px solid red;
+
+
+ * :
+
+ Ok this is good
!
+
Hi there !
+ [
]
+
+
+ ()
+
+
+
+
+
+
+
x
+
+
Here's your value : () !!
+
+
+
+
diff --git a/addons/base/static/lib/qweb/qweb2.js b/addons/base/static/lib/qweb/qweb2.js
index 18e38c30c52..edf8f8b2b21 100644
--- a/addons/base/static/lib/qweb/qweb2.js
+++ b/addons/base/static/lib/qweb/qweb2.js
@@ -20,8 +20,18 @@ var QWeb2 = {
}
throw prefix + ": " + message;
},
- js_escape: function(s) {
- return "'" + s.replace(/\r?\n/g, "\\n").replace(/'/g, "\\'") + "'";
+ trim: function(s, mode) {
+ switch (mode) {
+ case "left":
+ return s.replace(/^\s*/, "");
+ case "right":
+ return s.replace(/\s*$/, "");
+ default:
+ return s.replace(/^\s*|\s*$/g, "");
+ }
+ },
+ js_escape: function(s, noquotes) {
+ return (noquotes ? '' : "'") + s.replace(/\r?\n/g, "\\n").replace(/'/g, "\\'") + (noquotes ? '' : "'");
},
html_escape: function(s, attribute) {
if (s === null || s === undefined) {
@@ -126,7 +136,7 @@ var QWeb2 = {
new_dict[as_index] = index;
new_dict[as_first] = index === 0;
new_dict[as_parity] = (j % 2 == 1 ? 'odd' : 'even');
- new_dict[as] = v;
+ new_dict[as] = k;
callback(context, new_dict);
index += 1;
}
@@ -143,6 +153,7 @@ QWeb2.Engine = (function() {
function Engine() {
// TODO: handle prefix at template level : t-prefix="x"
this.prefix = 't';
+ this.debug = false;
this.templates_resources = []; // TODO: implement this.reload()
this.templates = {};
this.compiled_templates = {};
@@ -176,7 +187,7 @@ QWeb2.Engine = (function() {
},
load_xml : function(s) {
s = s.replace(/^\s*|\s*$/g, '');
- if (s[0] === '
|
-
+ |
+
|
diff --git a/openerpweb/nonliterals.py b/openerpweb/nonliterals.py
index a0805c9c0c2..1584628f777 100644
--- a/openerpweb/nonliterals.py
+++ b/openerpweb/nonliterals.py
@@ -80,10 +80,6 @@ class Domain(object):
def get_domain_string(self):
""" Retrieves the domain string linked to this non-literal domain in
the provided session.
-
- :param session: the OpenERP Session used to store the domain string in
- the first place.
- :type session: openerpweb.openerpweb.OpenERPSession
"""
return self.session.domains_store[self.key]
@@ -129,10 +125,6 @@ class Context(object):
def get_context_string(self):
""" Retrieves the context string linked to this non-literal context in
the provided session.
-
- :param session: the OpenERP Session used to store the context string in
- the first place.
- :type session: openerpweb.openerpweb.OpenERPSession
"""
return self.session.contexts_store[self.key]