<commit_before>odoo.define('partner.autocomplete.core', function (require) {
'use strict';

var rpc = require('web.rpc');
var concurrency = require('web.concurrency');

return {
    _dropPreviousOdoo: new concurrency.DropPrevious(),
    _dropPreviousClearbit: new concurrency.DropPrevious(),
    _timeout : 1000, // Timeout for Clearbit autocomplete in ms
    
    //--------------------------------------------------------------------------
    // Public
    //--------------------------------------------------------------------------

    /**
     * Get list of companies via Autocomplete API
     *
     * @param {string} value
     * @returns {Deferred}
     * @private
     */
    autocomplete: function (value) {
        value = value.trim();
        var def = $.Deferred(),
            isVAT = this._isVAT(value),
            odooSuggestions = [],
            clearbitSuggestions = [];

        var odooPromise = this._getOdooSuggestions(value, isVAT).then(function (suggestions){
            odooSuggestions = suggestions;
        });

        // Only get Clearbit suggestions if not a VAT number
        var clearbitPromise = isVAT ? false : this._getClearbitSuggestions(value).then(function (suggestions){
            clearbitSuggestions = suggestions;
        });

        var concatResults = function () {
            // Add Clearbit result with Odoo result (with unique domain)
            if (clearbitSuggestions && clearbitSuggestions.length) {
                var websites = odooSuggestions.map(function (suggestion) {
                    return suggestion.website;
                });
                clearbitSuggestions.forEach(function (suggestion) {
                    if (websites.indexOf(suggestion.domain) < 0) {
                        websites.push(suggestion.domain);
                        odooSuggestions.push(suggestion);
                    }
                });
            }

            return def.resolve(odooSuggestions);
        };

        this._whenAll([odooPromise, clearbitPromise]).then(concatResults, concatResults);

        return def;
    },

    /**
     * Get enrichment data
     *
     * @param {Object} company
     * @returns {Deferred}
     * @private
     */
    enrichCompany: function (company) {
        return rpc.query({
            model: 'res.partner',
            method: 'enrich_company',<commit_msg>[FIX] partner_autocomplete: Remove companies from suggestions<commit_after>odoo.define('partner.autocomplete.core', function (require) {
'use strict';

var rpc = require('web.rpc');
var concurrency = require('web.concurrency');

return {
    _dropPreviousOdoo: new concurrency.DropPrevious(),
    _dropPreviousClearbit: new concurrency.DropPrevious(),
    _timeout : 1000, // Timeout for Clearbit autocomplete in ms
    
    //--------------------------------------------------------------------------
    // Public
    //--------------------------------------------------------------------------

    /**
     * Get list of companies via Autocomplete API
     *
     * @param {string} value
     * @returns {Deferred}
     * @private
     */
    autocomplete: function (value) {
        value = value.trim();
        var def = $.Deferred(),
            isVAT = this._isVAT(value),
            odooSuggestions = [],
            clearbitSuggestions = [];

        var odooPromise = this._getOdooSuggestions(value, isVAT).then(function (suggestions){
            odooSuggestions = suggestions;
        });

        // Only get Clearbit suggestions if not a VAT number
        var clearbitPromise = isVAT ? false : this._getClearbitSuggestions(value).then(function (suggestions){
            clearbitSuggestions = suggestions;
        });

        var concatResults = function () {
            // Add Clearbit result with Odoo result (with unique domain)
            if (clearbitSuggestions && clearbitSuggestions.length) {
                var websites = odooSuggestions.map(function (suggestion) {
                    return suggestion.website;
                });
                clearbitSuggestions.forEach(function (suggestion) {
                    if (websites.indexOf(suggestion.domain) < 0) {
                        websites.push(suggestion.domain);
                        odooSuggestions.push(suggestion);
                    }
                });
            }

            odooSuggestions = _.filter(odooSuggestions, function (suggestion) {
                return !suggestion.ignored;
            });
            return def.resolve(odooSuggestions);
        };

        this._whenAll([odooPromise, clearbitPromise]).then(concatResults, concatResults);

        return def;
    },

    /**
     * Get enrichment data
     *
     * @param {Object} company
     * @returns {Deferred}
     * @private
     */
    enrichCompany: function (company) {
        return rpc.query({
            model: 'res.partner',
            method: 'enrich_company',
{'fraction_non_alphanumeric': 0.15860105734038227, 'fraction_numerical': 0.0020333468889792597, 'mean_word_length': 1.6574824419232848, 'pattern_counts': {'":': 0, '<': 5, '<?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': '983029', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1206, 'n_words': 268}