Skip to Content
Menu
This question has been flagged
1 Reply
6237 Views

I need to inherit a js funtion in mail module. Here's the file path  of the file that I want to inherit : mail\static\src\models\activity\activity.js

The function I want to inherit is 

async markAsDone({ attachments = [], feedback = false }) {
const attachmentIds = attachments.map(attachment => attachment.id);
await this.async(() => this.env.services.rpc({
model: 'mail.activity',
method: 'action_feedback',
args: [[this.id]],
kwargs: {
attachment_ids: attachmentIds,
feedback,
},
}));
this.thread.refresh();
this.delete();
}

I want to add location.reload(); before this.delete();
The reason for this is that I want to update screen after an attachment is uploaded.

Thanks.

Avatar
Discard
Best Answer

Hi,

Try to inherit function like below.

odoo.define( YOUR odoo.define PATH, function (require) {
'use strict';
const {
registerInstancePatchModel,
registerFieldPatchModel,
} = require('mail/static/src/model/model_core.js');
const { attr, one2one } = require('mail/static/src/model/model_field.js');
registerInstancePatchModel('mail.activity', YOUR odoo.define PATH, {
async markAsDone ({attachments = [], feedback = false }) {
const attachmentIds = attachments.map (attachment => attachment.id);
await this .async (() => this .env.services.rpc ({
model: 'mail.activity' ,
method: 'action_feedback' ,
args: [[ this .id]],
kwargs: {
attachment_ids: attachmentIds,
feedback ,
},
}));
           this.thread.refresh ();
           location.reload();
           this.delete();
}
});
});

Regards

Avatar
Discard
Author

Thanks @cybrosis

Related Posts Replies Views Activity
0
May 22
656
2
Dec 16
4694
1
Apr 15
3937
0
Oct 24
186
1
Jun 20
2884