[FIX] mail: reload attachments after upload from dropzone
Steps to reproduce ================== - Go to Accounting > Customer Invoices - Open any record with no attachments - Drag & drop a pdf attachment on the chatter => The PDF viewer is empty Cause of the issue ================== When uploading an attachment from the FileUploader, the parent view is reloaded. This is not the case when uploading an attachment from the dropzone. opw-3748853 closes odoo/odoo#157232 Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
This commit is contained in:
@@ -131,7 +131,11 @@ export class Chatter extends Component {
|
||||
return;
|
||||
}
|
||||
}
|
||||
files.forEach((file) => this.attachmentUploader.uploadFile(file));
|
||||
Promise.all(files.map((file) => this.attachmentUploader.uploadFile(file))).then(() => {
|
||||
if (this.props.hasParentReloadOnAttachmentsChanged) {
|
||||
this.reloadParentView();
|
||||
}
|
||||
})
|
||||
this.state.isAttachmentBoxOpened = true;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -115,6 +115,16 @@ insertModelFields("res.users.settings", {
|
||||
is_discuss_sidebar_category_channel_open: { default: true },
|
||||
is_discuss_sidebar_category_chat_open: { default: true },
|
||||
});
|
||||
insertModelFields("res.partner", {
|
||||
message_main_attachment_id: {
|
||||
name: "message_main_attachment_id",
|
||||
readonly: false,
|
||||
relation: "ir.attachment",
|
||||
required: false,
|
||||
string: "Main attachment",
|
||||
type: "many2one",
|
||||
}
|
||||
});
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Insertion of records
|
||||
|
||||
@@ -6,7 +6,7 @@ import { DELAY_FOR_SPINNER } from "@mail/core/web/chatter";
|
||||
import { patchUiSize, SIZES } from "@mail/../tests/helpers/patch_ui_size";
|
||||
import { start } from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
import { makeDeferred, patchWithCleanup, triggerHotkey } from "@web/../tests/helpers/utils";
|
||||
import { getFixture, makeDeferred, patchWithCleanup, triggerHotkey } from "@web/../tests/helpers/utils";
|
||||
import {
|
||||
click,
|
||||
contains,
|
||||
@@ -228,6 +228,50 @@ QUnit.test("chatter: drop attachments", async () => {
|
||||
await contains(".o-mail-AttachmentCard", { count: 3 });
|
||||
});
|
||||
|
||||
QUnit.test("chatter: drop attachment should refresh thread data with hasParentReloadOnAttachmentsChange prop", async () => {
|
||||
patchUiSize({ size: SIZES.XXL });
|
||||
const pyEnv = await startServer();
|
||||
const partnerId = pyEnv["res.partner"].create({});
|
||||
const views = {
|
||||
"res.partner,false,form": `
|
||||
<form>
|
||||
<sheet>
|
||||
<field name="name"/>
|
||||
</sheet>
|
||||
<div class="o_attachment_preview" />
|
||||
<div class="oe_chatter">
|
||||
<field name="message_main_attachment_id" invisible="1" on_change="1" />
|
||||
<field name="message_ids" options="{'post_refresh': 'always'}"/>
|
||||
</div>
|
||||
</form>`,
|
||||
};
|
||||
const target = getFixture();
|
||||
target.classList.add("o_web_client");
|
||||
const { openFormView } = await start({
|
||||
serverData: { views },
|
||||
target,
|
||||
async mockRPC(route) {
|
||||
if (route === "/mail/attachment/upload") {
|
||||
const attachmentId = pyEnv["ir.attachment"].create([
|
||||
{ res_id: partnerId, res_model: "res.partner", mimetype: "application/pdf" }
|
||||
]);
|
||||
pyEnv["res.partner"].write([partnerId], { message_main_attachment_id: attachmentId });
|
||||
return Promise.resolve();
|
||||
}
|
||||
},
|
||||
});
|
||||
await openFormView("res.partner", partnerId);
|
||||
const files = [
|
||||
await createFile({
|
||||
contentType: "application/pdf",
|
||||
name: "text.pdf",
|
||||
}),
|
||||
];
|
||||
await dragenterFiles(".o-mail-Chatter", files);
|
||||
await dropFiles(".o-mail-Dropzone", files);
|
||||
await contains(".o-mail-Attachment iframe", { count: 1 });
|
||||
});
|
||||
|
||||
QUnit.test("should display subject when subject isn't infered from the record", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const partnerId = pyEnv["res.partner"].create({});
|
||||
|
||||
Reference in New Issue
Block a user