Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在JavaScriptOdoo10中扩展mail.Chatter小部件_Javascript_Openerp_Odoo 10 - Fatal编程技术网

如何在JavaScriptOdoo10中扩展mail.Chatter小部件

如何在JavaScriptOdoo10中扩展mail.Chatter小部件,javascript,openerp,odoo-10,Javascript,Openerp,Odoo 10,我想在ODOO10中的“mail.Chatter”小部件(mail/static/src/js/Chatter.js)中添加一个新事件。因此我想扩展“mail.Chatter”小部件 但是从控制台上,我发现了一些错误。请在下面查看 Chatter function Class(){if(this.constructor!==OdooClass){throw new Error("You can only instanciate objects with the 'new' operator");

我想在ODOO10中的“mail.Chatter”小部件(mail/static/src/js/Chatter.js)中添加一个新事件。因此我想扩展“mail.Chatter”小部件

但是从控制台上,我发现了一些错误。请在下面查看

Chatter function Class(){if(this.constructor!==OdooClass){throw new Error("You can only instanciate objects with the 'new' operator");}

如果我错了,请纠正我。是否有其他方法扩展此“mail.Chatter”小部件?

在JS Chatter.JS文件中,您有2 init函数

为查特composer

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',
    });
},
还有闲聊

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();
},

如果我看到你的代码。您试图用ChatterComposer的init参数覆盖Chatter的init

在JS chatter.JS文件中有2个init函数

为查特composer

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',
    });
},
还有闲聊

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();
},
如果我看到你的代码。您试图用ChatterComposer的init参数覆盖Chatter的init

这对我有用

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);

    },

});
这对我有用

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);

    },

});

尝试聊天。仅扩展。因为Chatter只返回Chatterobject@Burmesepythislog('Chatter',Chatter)。我在控制台Chatter变量try Chatter.extend时出错。因为Chatter只返回Chatterobject@Burmesepythislog('Chatter',Chatter)。我在控制台Chatter变量var Chatter=require('mail.Chatter')时出错;log('Chatter',Chatter)我控制“Chatter”。这里我得到了这个错误“Chatter function Class(){if(this.constructor!==OdooClass){throw new error(“您只能用'new'运算符实例化对象”);}”它与“init”函数无关。我想。@jo541这个消息通常是这样的。您可以尝试调用未初始化的Class.var Chatter=require('mail.Chatter');console.log('Chatter',Chatter.Chatter)。在控制台中获取“未定义”。似乎Chatter无法扩展??Chatter可以扩展,因为在Chatter.js文件的末尾可以看到“return Chatter”.Hello@robinjoseph90,你得到什么答案了吗?因为,我有同样的问题,没有任何解决这个问题的线索。如果你有解决方案,请在这里发布。var Chatter=require('mail.Chatter');console.log('Chatter',Chatter)我控制台“Chatter”。这里我得到了这个错误“Chatter函数类(){if(this.constructor!==OdooClass){throw new error(“您只能用'new'操作符实例化对象”);}”与“init”无关函数。我认为。@jo541此消息正常。您尝试调用未初始化的类。var Chatter=require('mail.Chatter');console.log('Chatter',Chatter.Chatter')。在控制台中获取“未定义”。似乎Chatter无法扩展??Chatter可以扩展,因为在Chatter.js文件的末尾可以看到“return Chatter”.Hello@robinjoseph90,你得到什么答案了吗?因为,我也有同样的问题,没有解决这个问题的任何线索。如果你有解决方案,请在这里发布。