<commit_before>odoo.define('base_import_map.map', function (require) {
    "use strict";

    var ControlPanelMixin = require('web.ControlPanelMixin');
    var BaseImport = require('base_import.import');
    var core = require('web.core');

    var QWeb = core.qweb;
    var _lt = core._lt;
    var _t = core._t;

    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: ''});
            this._super.apply(this, arguments);
        },
        start: function() {
            var self = this;
            this.setup_settings_picker();
            this._super();
        },
        setup_settings_picker: function(){
            var self = this;
            self._rpc({
                model: 'base_import_map.map',
                method: 'search_read',
                args: [
                    [['model', '=', this.res_model]],
                    ['name']
                ]
            }).then(function(res) {
                var suggestions = [];
                if (res) {
                    res.forEach(function (item) {
                        suggestions.push({id: item.id, text: item.name});
                    });
                } else {
                    suggestions.push({id: "None", text: _t("None")});
                }
                self.$('input.oe_import_settings').select2({
                    width: '160px',
                    query: function (q) {
                        if (q.term) {
                            suggestions.unshift({id: q.term, text: q.term});
                        }
                        q.callback({results: suggestions});
                    },
                    initSelection: function (e, c) {
                        return c({id: "None", text: _t("None")});
                    },
                });
            });
        },
    });
});
<commit_msg>[FIX] base_import_map: prevent duplicate map settings controls<commit_after>odoo.define('base_import_map.map', function (require) {
    "use strict";

    var ControlPanelMixin = require('web.ControlPanelMixin');
    var BaseImport = require('base_import.import');
    var core = require('web.core');

    var QWeb = core.qweb;
    var _lt = core._lt;
    var _t = core._t;

    BaseImport.DataImport.include({
        init: function() {
            // 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() {
            var self = this;
            this.setup_settings_picker();
            this._super();
        },
        setup_settings_picker: function(){
            var self = this;
            self._rpc({
                model: 'base_import_map.map',
                method: 'search_read',
                args: [
                    [['model', '=', this.res_model]],
                    ['name']
                ]
            }).then(function(res) {
                var suggestions = [];
                if (res) {
                    res.forEach(function (item) {
                        suggestions.push({id: item.id, text: item.name});
                    });
                } else {
                    suggestions.push({id: "None", text: _t("None")});
                }
                self.$('input.oe_import_settings').select2({
                    width: '160px',
                    query: function (q) {
                        if (q.term) {
                            suggestions.unshift({id: q.term, text: q.term});
                        }
                        q.callback({results: suggestions});
                    },
                    initSelection: function (e, c) {
                        return c({id: "None", text: _t("None")});
                    },
                });
            });
        },
    });
});

{'fraction_non_alphanumeric': 0.13787778513125964, 'fraction_numerical': 0.0017648356496801235, 'mean_word_length': 1.3156281920326864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4222366', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1142, 'n_words': 256}