Mohammed Shekha(Open ERP) has proposed merging
lp:~openerp-dev/openerp-web/6.1-opw-579391-msh into lp:openerp-web/6.1.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/6.1-opw-579391-msh/+merge/125925
Hello,
Fixed the issue of sorted data of selection field on graph view, the data of
selection field should not be sorted in alphabetical order it should shown as
it is defined in selection field, because the data defined on selection field
have intention order, for example name of the months, state field which have
some specified order.
So changed the code and skipped alphabetical ordering on selection field.
Thanks.
--
https://code.launchpad.net/~openerp-dev/openerp-web/6.1-opw-579391-msh/+merge/125925
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openerp-web/6.1-opw-579391-msh.
=== modified file 'addons/web_graph/static/src/js/graph.js'
--- addons/web_graph/static/src/js/graph.js 2012-08-31 10:32:55 +0000
+++ addons/web_graph/static/src/js/graph.js 2012-09-24 05:36:18 +0000
@@ -104,6 +104,9 @@
if (this.group_field) { fields.push(this.group_field); }
// transform search result into usable records (convert from OpenERP
// value shapes to usable atomic types
+ if(self.fields[self.abscissa].type == 'selection'){
+ results = self.sortSelection(results);
+ }
var records = _(results).map(function (result) {
var point = {};
_(result).each(function (value, field) {
@@ -170,9 +173,11 @@
if (!r) { graph_data.push(datapoint); }
});
- graph_data = _(graph_data).sortBy(function (point) {
- return point[self.abscissa] + '[[--]]' + point[self.group_field];
- });
+ if(self.fields[self.abscissa].type != 'selection'){
+ graph_data = _(graph_data).sortBy(function (point) {
+ return point[self.abscissa] + '[[--]]' + point[self.group_field];
+ });
+ }
if (_.include(['bar','line','area'],this.chart)) {
return this.schedule_bar_line_area(graph_data);
} else if (this.chart == "pie") {
@@ -391,6 +396,20 @@
}
this.renderer = setTimeout(renderer, 0);
},
+ sortSelection: function(results){
+ var self = this;
+ var grouped_data = _(results).groupBy(function(result){
+ return result[self.abscissa];
+ });
+ var options = _(self.fields[self.abscissa].selection).map(function(option){ return option[0]; })
+ var sorted_data = _(options).chain().map(function(option){
+ return grouped_data[option];
+ }).filter(function(data){ return data != undefined; }).value();
+ if(sorted_data.length){
+ sorted_data = _.reduceRight(sorted_data, function(a, b){ return b.concat(a);})
+ }
+ return sorted_data;
+ },
open_list_view : function (id){
var self = this;
// unconditionally nuke tooltips before switching view
_______________________________________________
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