Skip to content

Commit

Permalink
[FIX] base_import_map: prevent duplicate map settings controls
Browse files Browse the repository at this point in the history
Because in the custom init function the original (prototype) 'opts' array
was mutated, every time the function was called (which happens everytime one
opens the import wizard) 3 opts were added, resulting in duplicate map
controls.
Solve the bug by using concat + reassignment instead of mutation.
  • Loading branch information
LeartS authored and Ivan Yelizariev committed Apr 23, 2018
1 parent 3518c78 commit 59f12d7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions base_import_map/static/src/js/base_import_map.js
Expand Up @@ -11,9 +11,15 @@ odoo.define('base_import_map.map', function (require) {

BaseImport.DataImport.include({
init: function() {
this.opts.push({name: 'settings', label: _lt("Settings:"), value: ''});
this.opts.push({name: 'save_settings', label: _lt("Save settings:"), value: ''});
this.opts.push({name: 'file_read_hook', label: _lt("File read hook:"), value: ''});
// Assign a new array instead of pushing values to the
// original one, because otherwise we would change the
// prototype array, meaning that each time 'init' is called
// the values are pushed again, resulting in duplicate entries
this.opts = this.opts.concat([
{name: 'settings', label: _lt("Settings:"), value: ''},
{name: 'save_settings', label: _lt("Save settings:"), value: ''},
{name: 'file_read_hook', label: _lt("File read hook:"), value: ''}
])
this._super.apply(this, arguments);
},
start: function() {
Expand Down

0 comments on commit 59f12d7

Please sign in to comment.