跳至内容
菜单
此问题已终结
1 回复
4574 查看

I want to add one more event in "mail.Chatter" template(mail/static/src/js/chatter.js). so I extend the "mail.Chatter" like below

odoo.define('override_chatter.override_chatter', function (require) {

"use strict";

var Chatter = require('mail.Chatter');

console.log('Chatter', Chatter)

var Chatter_Extend = Chatter.Chatter.extend({

     init: function (parent, dataset, options) {

          this._super(parent, options);

          this.events = _.extend(this.events, {

                  "click .o_composer_button_chatter_link": "on_open_o_composer_button_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 override this "mail.Chatter" template?

形象
丢弃
编写者 最佳答案

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 NewLink = MailThread.include({

    

         init: function () {

               this._super.apply(this, arguments);

               this.events = _.extend(this.events, {

                          "click .o_chatter_button_new_link": "on_open_get_new_link",

                          });

             },

        on_open_get_new_link: function () {

              },

      });


});

形象
丢弃
相关帖文 回复 查看 活动
0
9月 21
2194
2
4月 20
4993
7
12月 18
5850
1
4月 18
7147
0
4月 18
2755