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

Hi everyone


I am trying to override the function  async onClickCancel()


which is located in addons/mail/static/src/models/activity_view.js


My goal is to check is the connecter user is the one who created the activity, and if not, display error message, then do nothing

If he is, I call the super() to let the standard behavior


In my custom module I am facing an issue with the 'require' line code,  I have js error in my console, saying

TypeError: Cannot read properties of undefined (reading 'recordMethods')

I tried manythings ... require('mail/ActivityView') and many other things


Thank you for your help


(my custom code is loaded so I can face this issue, I think the problem is in this require line, not in the manifest or anywhere else)

​
var activityView = require('@mail/models/activity_view');


activityView.ActivityView.recordMethods.include(mycustomcode)


形象
丢弃
编写者 最佳答案

Hi Cybrosys


Thank you very much for your help

However it does not work ... I do not run through this custom code (but it is well loaded I can see it in DOM)

形象
丢弃
最佳答案

Hi,

Try this code:

/** @odoo-module **/


import { registerPatch } from '@mail/model/model_core';


import Dialog from 'web.Dialog';


registerPatch({

    name: 'ActivityView',

    recordMethods: {

        /**

         * @override

         */

        async onClickCancel(ev) {

            if (!this.exists()) {

                return;

            }

            await this._super();

        },

    },

});


Hope it helps

形象
丢弃