Skip to Content
Menu
This question has been flagged

I have some customization in search field in Odoo 10..

I did changes in  svnodoo10\addons\web\static\src\js\widgets\auto_complete.js

Original Code:

odoo.define('web.AutoComplete', function (require) {

"use strict";

var Widget = require('web.Widget');

return Widget.extend({

    template: "SearchView.autocomplete",

render_search_results: function (results) {

   var self = this;

  // this._super();

   var $list = this.$el;

   $list.empty();

   results.forEach(function (result) {

       var $item = self.make_list_item(result).appendTo($list);

       result.$el = $item;

   });

   this.show();

    // My customization

   if(this.history)

   {

                   var $first_list = self.$('li:first-child');

   }

       //End

},

});


Extended auto_complete_history.js

odoo.define('product.auto_complete_history', function (require) {

"use strict";  

var AutoComplete = require('SearchView.autocomplete');

return AutoComplete.extend({

     template: "SearchView.autocomplete",

    render_search_results: function (results) {

               this._super();

             if(this.history)

   { 

       var $first_list = self.$('li:first-child');

   }

},

});

});


But extended file doesnt override the code.

Please anyone help to us how to extend this file.

Avatar
Discard
Best Answer

I think that you could do it like this:

odoo.define('product.auto_complete_history', function (require) {
"use strict";  
var AutoComplete = require('SearchView.autocomplete');
AutoComplete.include({
    template: "SearchView.autocomplete",
   render_search_results: function (results) {
    this._super();
        if(this.history){ 
        var $first_list = self.$('li:first-child');
    }
}
});
});


s

Avatar
Discard
Related Posts Replies Views Activity
0
Jan 19
7222
0
Dec 17
3210
1
Jun 24
317
1
Oct 23
757
1
Aug 22
48