Can anyone give me minimal code so that any method I can override for JS method, I tried this code but it doesn't work for me?
I want to override the method for this line https://github.com/odoo/odoo/blob/12.0/addons/im_livechat/static/src/js/website_livechat_window.js#L65
Here is my code file
odoo.define('poc.test', function(require){
"use strict";
console.log('111XXX');
var WebsiteLivechatWindowXXX = require('im_livechat.WebsiteLivechatWindow');
var LivechatWindowTest = WebsiteLivechatWindowXXX.extend({
events: _.extend(WebsiteLivechatWindowXXX.prototype.events, {
'input .o_composer_text_field': '_onInputX',
}),
/**
* @override
* @param {im_livechat.im_livechat.LivechatButton} parent
* @param {im_livechat.model.WebsiteLivechat} thread
*/
init: function (parent, thread) {
this._super.apply(this, arguments);
this._thread = thread;
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* @override
* @private
* @param {Object} messageData
*/
_postMessage: function (messageData) {
console.log('222XXX');
this._super.apply(this, arguments);
},
_onInputX: function () {
console.log('this.$input.val().length');
console.log(this.$input.val().length);
console.log(this.hasThread());
console.log(this._thread);
console.log(this._thread.hasTypingNotification());
},
});
return LivechatWindowTest;
});
In the console, I can see the log '111XXX' which confirm the JS custom code is loaded but when I tried to send message It doesn't print '222XXX' in the console. Also, If I type anything I got an error message in the console which say 'Error: Couldn't find method '_onInputX' in widget'.
I have included in JS file by creating template view and the template inherit 'inherit_id="website.assets_frontend"' and also I have added depends 'im_livechat' in __manifest__.py file.
https://www.youtube.com/watch?v=VuUMvzycXQY&list=PLqRRLx0cl0hpSfSgbUNxokOuCqs-hh5LM