diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 35dbebac724..25ef94d3ee9 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1159,7 +1159,10 @@ export class Wysiwyg extends Component { */ savePendingImages($editable = this.$editable) { const defs = Array.from($editable).map(async (editableEl) => { - const {res_model: resModel, res_id: resId} = this.options.recordInfo; + let { oeModel: resModel, oeId: resId } = editableEl.dataset; + if (!resModel) { + ({ res_model: resModel, res_id: resId } = this.options.recordInfo); + } // When saving a webp, o_b64_image_to_save is turned into // o_modified_image_to_save by _saveB64Image to request the saving // of the pre-converted webp resizes and all the equivalent jpgs. diff --git a/addons/web_editor/static/tests/html_field_tests.js b/addons/web_editor/static/tests/html_field_tests.js index 8097edc83b3..1c435383ab6 100644 --- a/addons/web_editor/static/tests/html_field_tests.js +++ b/addons/web_editor/static/tests/html_field_tests.js @@ -293,7 +293,7 @@ QUnit.module("WebEditor.HtmlField", ({ beforeEach }) => { QUnit.module('Save scenarios'); QUnit.test("Ensure that urgentSave works even with modified image to save", async (assert) => { - assert.expect(3); + assert.expect(5); let formController; // Patch to get the controller instance. patchWithCleanup(FormController.prototype, { @@ -377,6 +377,8 @@ QUnit.module("WebEditor.HtmlField", ({ beforeEach }) => { route === `/web_editor/modify_image/${imageRecord.id}` ) { if (modifyImageCount === 0) { + assert.equal(args.res_model, 'partner'); + assert.equal(args.res_id, 1); await modifyImagePromise; return newImageSrc; } else { @@ -437,7 +439,7 @@ QUnit.module("WebEditor.HtmlField", ({ beforeEach }) => { }); QUnit.test("Pasted/dropped images are converted to attachments on save", async (assert) => { - assert.expect(4); + assert.expect(6); // Patch to get a promise to get the htmlField component instance when // the wysiwyg is instancied. @@ -457,6 +459,9 @@ QUnit.module("WebEditor.HtmlField", ({ beforeEach }) => { const mockRPC = async function (route, args) { if (route === '/web_editor/attachment/add_data') { + // Check that the correct record model and id were sent. + assert.equal(args.res_model, 'partner'); + assert.equal(args.res_id, 1); return { image_src: '/test_image_url.png', access_token: '1234',