[FIX] fetching of export data after reloading from saved list in a different mode than original

If a field name can not be found in the `records` mapping, use it
as-is. May fail in some cases (for nested id fields) but will
generally work better when reloading a list created in "all" mode
while in "export compatible" mode, as there may be saved fields
missing from the currently available list.

Better fixes would be:

* Ignore (gray out?) unavailable fields for this mode (and re-allow
  when the mode changes)
* Display an error message of some sort and refuse to load the list
* Pre-load all export lists and filter selectable ones by mode

lp bug: https://launchpad.net/bugs/915245 fixed

bzr revid: xmo@openerp.com-20120116095337-ko0y6xha6oqx4vw1
This commit is contained in:
Xavier Morel 2012-01-16 10:53:37 +01:00
parent 61b4bedcab
commit 33b25edc78
1 changed files with 7 additions and 6 deletions

View File

@ -362,11 +362,12 @@ openerp.web.DataExport = openerp.web.Dialog.extend({
return export_field;
},
on_click_export_data: function() {
var exported_fields = [], self = this;
this.$element.find("#fields_list option").each(function() {
var fieldname = self.records[$(this).val()];
exported_fields.push({name: fieldname, label: $(this).text()});
});
var exported_fields = this.$element.find('#fields_list option').map(function () {
// DOM property is textContent, but IE8 only knows innerText
return {name: this.value,
label: this.textContent || this.innerText};
}).get();
if (_.isEmpty(exported_fields)) {
alert(_t("Please select fields to export..."));
return;
@ -383,7 +384,7 @@ openerp.web.DataExport = openerp.web.Dialog.extend({
ids: this.dataset.ids,
domain: this.dataset.domain,
import_compat: Boolean(
this.$element.find("#import_compat").val())
this.$element.find("#import_compat").val())
})},
complete: $.unblockUI
});