From 1871b33dbf0837e18342c78748cbd63b3b10dab2 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Fri, 26 Aug 2016 18:03:53 +0200 Subject: [PATCH] [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. --- addons/web/static/src/js/widgets/data_export.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/widgets/data_export.js b/addons/web/static/src/js/widgets/data_export.js index 14cdc4c5e3e..712adfb89e5 100644 --- a/addons/web/static/src/js/widgets/data_export.js +++ b/addons/web/static/src/js/widgets/data_export.js @@ -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); });