Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
7419 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks @cybrosis

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 5 22
656
2
thg 12 16
5774
1
thg 4 15
4905
0
thg 10 24
1480
1
thg 6 20
3920