summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/data.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js
index 046930e4baf..01962f829e6 100644
--- a/addons/web/static/src/js/data.js
+++ b/addons/web/static/src/js/data.js
@@ -722,7 +722,24 @@ openerp.web.BufferedDataSet = openerp.web.DataSetStatic.extend({
throw "Record not correctly loaded";
}
}
+ var sort_fields = self._sort,
+ compare = function (v1, v2) {
+ return (v1 < v2) ? -1
+ : (v1 > v2) ? 1
+ : 0;
+ };
+ records.sort(function (a, b) {
+ return _.reduce(sort_fields, function (acc, field) {
+ if (acc) { return acc; }
+ var sign = 1;
+ if (field[0] === '-') {
+ sign = -1;
+ field = field.slice(1);
+ }
+ return sign * compare(a[field], b[field]);
+ }, 0);
+ });
completion.resolve(records);
};
if(to_get.length > 0) {