Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
464 Näkymät

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)


Avatar
Hylkää
Tekijä Paras vastaus

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)

Avatar
Hylkää
Paras vastaus

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

Avatar
Hylkää