Reputation: 21
I want to add a new event to "mail.Chatter" widget(mail/static/src/js/chatter.js) in Odoo 10.so I want to extend the "mail.Chatter" widget.
odoo.define('override_chatter.override_chatter', function (require) {
"use strict";
var Chatter = require('mail.Chatter');
console.log('Chatter', Chatter)
});
But from the console, I got some error. Please check below.
Chatter function Class(){if(this.constructor!==OdooClass){throw new Error("You can only instanciate objects with the 'new' operator");}
Please correct me if am wrong.Is there any other method to extend this "mail.Chatter" widget?
Upvotes: 0
Views: 924
Reputation: 21
This works for me
odoo.define('override_chatter.override_chatter', function (require) {
"use strict";
var core = require('web.core');
var Chatter = require('mail.Chatter');
var MailThread = core.form_widget_registry.get('mail_thread');
var MailThreadOverride = MailThread.include({
init: function () {
this._super.apply(this, arguments);
},
});
Upvotes: 2
Reputation: 1155
In the file JS chatter.js you have 2 init function.
For ChatterComposer
init: function (parent, dataset, options) {
this._super(parent, options);
this.thread_dataset = dataset;
this.suggested_partners = [];
this.options = _.defaults(this.options, {
display_mode: 'textarea',
record_name: false,
is_log: false,
});
if (this.options.is_log) {
this.options.send_text = _t('Log');
}
this.events = _.extend(this.events, {
'click .o_composer_button_full_composer': 'on_open_full_composer',
});
},
And for Chatter
init: function () {
this._super.apply(this, arguments);
this.model = this.view.dataset.model;
this.res_id = undefined;
this.context = this.options.context || {};
this.dp = new web_utils.DropPrevious();
},
And if I seeing your code. You try to overwrite the init of Chatter whit the init params of ChatterComposer .
Upvotes: 0