Skip to Content
Menu
This question has been flagged
1 Reply
6212 Views

I am working on odoo 14. I have the following public widget defined in the core/addons/website_sale module that I need to extend/override.

My goal for this question is, how do I define a call from another module, too this widget, that lets me access the widget, and overwrite for example xmlDependencies: field, and the start: function () method.

I am unsure of how I should approch accessing this widget externally, since it has no return, if it is at all possible.

odoo.define('website_sale.s_products_searchbar', function (require) {

'use strict';

const concurrency = require('web.concurrency');

const publicWidget = require('web.public.widget');

const { qweb } = require('web.core');

publicWidget.registry.productsSearchBar = publicWidget.Widget.extend({ 

selector: '.o_wsale_products_searchbar_form', 

xmlDependencies: ['/website_sale/static/src/xml/website_sale_utils.xml'], 

events: { 

    'input .search-query': '_onInput', 

    'focusout': '_onFocusOut', 

    'keydown .search-query': '_onKeydown', 

    }, 

    autocompleteMinWidth: 300,

    /** 

    * @constructor 

    */ 

    init: function () { 

        this._super.apply(this, arguments);
        this._dp = new concurrency.DropPrevious();
        this._onInput = _.debounce(this._onInput, 400); 

        this._onFocusOut = _.debounce(this._onFocusOut, 100); 

    }, 

    /** 

    * @override 

    */ 

    start: function () { 

        this.$input = this.$('.search-query');
        this.order = this.$('.o_wsale_search_order_by').val(); 

        this.limit = parseInt(this.$input.data('limit')); 

        this.displayDescription = !!this.$input.data('displayDescription'); 

        this.displayPrice = !!this.$input.data('displayPrice'); 

        this.displayImage = !!this.$input.data('displayImage');
        if (this.limit) { 

                this.$input.attr('autocomplete', 'off'); 

        }
    return this._super.apply(this, arguments); 

    },
    /* ..... REST OF FILE .....*/

});
});


Avatar
Discard
Best Answer

Hi,

You can access it by

const publicWidget = require('web.public.widget');

//extending
publicWidget.registry.productsSearchBarNew = publicWidget.registry.productsSearchBar.extend({})

//including
publicWidget.registry.productsSearchBar.include({})

Regards

Avatar
Discard
Related Posts Replies Views Activity
1
Jul 16
3298
1
Jun 23
2266
0
Jan 21
2124
2
Dec 19
7655
1
Dec 19
5152