[FIX] mail: call rpc before remove attachment or message
* Current Status - when remove attachment or message, The system will perform deletion on the interface before performing deletion in the DB. However, in some situations, exceptions will occur during the deletion process. So it will happen that the attachment or message has been deleted on the interface but still exists under the database. From a function that helps optimize user experience, it will cause a worse situation with user experience * Solution - Make rpc calls before deleting messages or attachments on the interface closes odoo/odoo#161023 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -38,7 +38,6 @@ export class AttachmentService {
|
||||
* @param {Attachment} attachment
|
||||
*/
|
||||
async delete(attachment) {
|
||||
this.remove(attachment);
|
||||
if (attachment.id > 0) {
|
||||
await this.rpc(
|
||||
"/mail/attachment/delete",
|
||||
@@ -48,6 +47,7 @@ export class AttachmentService {
|
||||
)
|
||||
);
|
||||
}
|
||||
this.remove(attachment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,18 +55,18 @@ export class MessageService {
|
||||
}
|
||||
|
||||
async delete(message) {
|
||||
if (message.isStarred) {
|
||||
this.store.discuss.starred.counter--;
|
||||
this.store.discuss.starred.messages.delete(message);
|
||||
}
|
||||
message.body = "";
|
||||
message.attachments = [];
|
||||
await this.rpc("/mail/message/update_content", {
|
||||
attachment_ids: [],
|
||||
attachment_tokens: [],
|
||||
body: "",
|
||||
message_id: message.id,
|
||||
});
|
||||
if (message.isStarred) {
|
||||
this.store.discuss.starred.counter--;
|
||||
this.store.discuss.starred.messages.delete(message);
|
||||
}
|
||||
message.body = "";
|
||||
message.attachments = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user