Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
7213 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore

Thanks @cybrosis

Post correlati Risposte Visualizzazioni Attività
0
mag 22
656
2
dic 16
5568
1
apr 15
4695
0
ott 24
1196
1
giu 20
3693