summaryrefslogtreecommitdiff
path: root/addons/base/static/src/js/data.js
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2011-05-10 13:07:23 +0200
committerXavier Morel <xmo@openerp.com>2011-05-10 13:07:23 +0200
commit45f47ae65c0e22e7a780806f69eedcaa57c37259 (patch)
treef5409cb3f528ad7d9b80a7a4c351a2ce05a78e7f /addons/base/static/src/js/data.js
parent0dcd78a54e59f89567cc079bd3399bbf73b5ea16 (diff)
[ADD] display groups in a most dreadful manner, need to cleanup the generation function and to handle displaying it in the correct table
bzr revid: xmo@openerp.com-20110510110723-ic13ty3rs92zg9z9
Diffstat (limited to 'addons/base/static/src/js/data.js')
-rw-r--r--addons/base/static/src/js/data.js23
1 files changed, 20 insertions, 3 deletions
diff --git a/addons/base/static/src/js/data.js b/addons/base/static/src/js/data.js
index bb190e068c6..c3683ed592e 100644
--- a/addons/base/static/src/js/data.js
+++ b/addons/base/static/src/js/data.js
@@ -37,7 +37,19 @@ openerp.base.DataGroup = openerp.base.Controller.extend( /** @lends openerp.bas
group_by_fields: this.group_by
}, function () { }).then(function (response) {
self.groups = response.result;
- d.resolveWith(self, [response.result]);
+ // read_group results are annoying: they use the name of the
+ // field grouped on to hold the value and the count, so no
+ // generic access to those values is possible.
+ // Alias them to `value` and `length`.
+ d.resolveWith(self, [_(response.result).map(function (group) {
+ var field_name = self.group_by[0];
+ return _.extend({}, group, {
+ // provide field used for grouping
+ grouped_on: field_name,
+ length: group[field_name + '_count'],
+ value: group[field_name]
+ });
+ })]);
}, function () {
d.rejectWith.apply(d, self, [arguments]);
});
@@ -52,9 +64,14 @@ openerp.base.DataGroup = openerp.base.Controller.extend( /** @lends openerp.bas
* :js:func:`~openerp.base.DataGroup.list` beforehand will likely result
* in an error.
*
+ * The resulting :js:class:`~openerp.base.DataGroup` or
+ * :js:class:`~openerp.base.DataSet` will be provided through the relevant
+ * callback function. In both functions, the current DataGroup will be
+ * provided as context (``this``)
+ *
* @param {Number} index the index of the group to open in the datagroup's collection
- * @param {Function} ifDataSet executed if the item results in a DataSet, provided with the dataset as parameter and as context
- * @param {Function} ifDataGroup executed if the item results in a DataSet, provided with the datagroup as parameter and as context
+ * @param {Function} ifDataSet executed if the item results in a DataSet, provided with the new dataset as parameter
+ * @param {Function} ifDataGroup executed if the item results in a DataSet, provided with the new datagroup as parameter
*/
get: function (index, ifDataSet, ifDataGroup) {
var group = this.groups[index];