[FIX] don't fuck up name ordering in exported file: match what was requested by the user

bzr revid: xmo@openerp.com-20110831110439-5q04tn4uqqu0ytf2
This commit is contained in:
Xavier Morel 2011-08-31 13:04:39 +02:00
parent 4442c1f43b
commit 781db2f3b3
2 changed files with 10 additions and 7 deletions

View File

@ -1228,18 +1228,21 @@ class Export(View):
Model = req.session.model(model)
ids = ids or Model.search(domain, context=context)
field = fields.keys()
result = Model.export_data(ids, field, context).get('datas',[])
field_names = map(operator.itemgetter('name'), fields)
import_data = Model.export_data(ids, field_names, context).get('datas',[])
if import_compat:
columns_headers = field_names
else:
columns_headers = [val['label'].strip() for val in fields]
if not import_compat:
field = [val.strip() for val in fields.values()]
req.httpresponse.headers['Content-Disposition'] = \
'attachment; filename="%s"' % self.filename(model)
req.httpresponse.cookie['fileToken'] = int(token)
req.httpresponse.cookie['fileToken']['path'] = '/'
req.httpresponse.headers['Content-Type'] = self.content_type
return self.from_data(field, result)
return self.from_data(columns_headers, import_data)
class CSVExport(Export):
_cp_path = '/base/export/csv'

View File

@ -381,9 +381,9 @@ openerp.base.DataExport = openerp.base.Dialog.extend({
},
on_click_export_data: function() {
$.blockUI(this.$element);
var exported_fields = {};
var exported_fields = [];
this.$element.find("#fields_list option").each(function() {
exported_fields[$(this).val()] = $(this).text();
exported_fields.push({name: $(this).val(), label: $(this).text()});
});
if (_.isEmpty(exported_fields)) {
alert('Please select fields to export...');