تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
7215 أدوات العرض

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.

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
الكاتب

Thanks @cybrosis

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
مايو 22
656
2
ديسمبر 16
5568
1
أبريل 15
4695
0
أكتوبر 24
1196
1
يونيو 20
3693