[FIX] web_editor: images converted to public attachments
Before this commit, since [1], when an image was pasted or dropped, it was converted to a public attachment on save. This was an oversight, and this commit fixes it by creating such attachment as a private one instead, much like when uploading an image via the "/image" command. Attachments created via the website remain public. [1]: https://github.com/odoo/odoo/pull/128452/commits/1b3877191ee9d97d2c50ccacb41461827b42fd56 closes odoo/odoo#131975 X-original-commit: d939fc83ab645ebced6859e04269fb65bf47f323 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -1153,7 +1153,7 @@ export class Wysiwyg extends Component {
|
||||
*/
|
||||
savePendingImages($editable = this.$editable) {
|
||||
const defs = Array.from($editable).map(async (editableEl) => {
|
||||
const {oeModel: resModel, oeId: resId} = editableEl.dataset;
|
||||
const {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.
|
||||
@@ -2926,6 +2926,8 @@ export class Wysiwyg extends Component {
|
||||
name: el.dataset.fileName || '',
|
||||
data: el.getAttribute('src').split(',')[1],
|
||||
is_image: true,
|
||||
res_model: resModel,
|
||||
res_id: resId,
|
||||
},
|
||||
);
|
||||
if (attachment.mimetype === 'image/webp') {
|
||||
@@ -2935,7 +2937,19 @@ export class Wysiwyg extends Component {
|
||||
el.dataset.fileName = attachment.name;
|
||||
this._saveModifiedImage(el, resModel, resId);
|
||||
} else {
|
||||
el.setAttribute('src', attachment.image_src);
|
||||
let src = attachment.image_src;
|
||||
if (!attachment.public) {
|
||||
let accessToken = attachment.access_token;
|
||||
if (!accessToken) {
|
||||
[accessToken] = await this.orm.call(
|
||||
'ir.attachment',
|
||||
'generate_access_token',
|
||||
[attachment.id],
|
||||
);
|
||||
}
|
||||
src += `?access_token=${encodeURIComponent(accessToken)}`;
|
||||
}
|
||||
el.setAttribute('src', src);
|
||||
}
|
||||
el.classList.remove('o_b64_image_to_save');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user