[IMP] web: export: keep compatible fields when switching export type

Previously all the fields were removed when switching export type, even
if they are available in the newly selected export type. This commit
fixes that.
This commit is contained in:
Simon Lejeune
2016-08-26 18:16:35 +02:00
parent f4738e7bb5
commit 1871b33dbf
@@ -222,13 +222,22 @@ var DataExport = Dialog.extend({
var got_fields = new $.Deferred();
this.$import_compat_radios.change(function(e) {
self.$fields_list.empty();
self.$('.o_field_tree_structure').remove();
self.rpc("/web/export/get_fields", {
model: self.dataset.model,
import_compat: !!$(e.target).val(),
}).done(function (records) {
var compatible_fields = _.map(records, function (record) {return record.id});
self.$fields_list
.find('option')
.filter(function () {
var option_field = $(this).attr('value');
if (compatible_fields.indexOf(option_field) === -1) {
return true;
}
})
.remove();
got_fields.resolve();
self.on_show_data(records);
});