Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] web_editor, mass_mailing: shapes don't save #164703

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented May 7, 2024

Current behavior:

When logged as a mass mailing user, in a mailing, using the editor,
when applying a shape to an image, the image disappears.

Steps to reproduce:

  1. Make sure Marc Demo has the role User
  2. Log in as Marc Demo
  3. Create a new mailing
  4. Select a template
  5. Insert a picture
  6. Select the picture
  7. Change its shape to round
  8. (preview works fine)
  9. Save the mailing
  10. Picture disappears

Cause of the issue:

When applying a shape to an image, the resulting file is of mimetype 'image/svg+xml',
when sending it to the server, the attachment is going to go through _check_contents

not self.env['ir.ui.view'].with_user(user).check_access_rights('write', False))
and if the mimetype is "xml_like", it will check for views write rights,
without what the mimetype will be forced to text/plain.

But in web_editor, when computing the image src

attachment.image_src = False
if the mimetype is not a supported image type, src will be False.

Fix:

Override of _writeShape to use canvas to convert the image from svg to png.

opw-3672798


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #164013
Forward-Port-Of: #159497

@robodoo
Copy link
Contributor

robodoo commented May 7, 2024

Pull request status dashboard.

@fw-bot
Copy link
Contributor Author

fw-bot commented May 7, 2024

@ande-odoo cherrypicking of pull request #159497 failed.

stdout:

Auto-merging addons/mass_mailing/static/src/js/mass_mailing_snippets.js
CONFLICT (content): Merge conflict in addons/mass_mailing/static/src/js/mass_mailing_snippets.js
Auto-merging addons/web_editor/static/src/js/editor/snippets.options.js
CONFLICT (content): Merge conflict in addons/web_editor/static/src/js/editor/snippets.options.js

stderr:

12:53:42.895837 git.c:463               trace: built-in: git cherry-pick b270e23dd90bf8e81a2b77f8025dfe9d57341caa
error: could not apply b270e23dd90b... [FIX] web_editor, mass_mailing: shapes don't save
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
----------
status:

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

In the former case, you may want to edit this PR message as well.

⚠️ after resolving this conflict, you will need to merge it via @robodoo.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label May 7, 2024
@robodoo robodoo added forwardport This PR was created by @fw-bot conflict There was an error while creating this forward-port PR labels May 7, 2024
@ande-odoo ande-odoo force-pushed the 17.0-16.0-OPW_3672798-mass_mailing-shapes_not_saving-ande-WsbS-fw branch from 17fe187 to 99828d9 Compare May 7, 2024 17:15
@C3POdoo C3POdoo requested review from a team May 7, 2024 17:18
@ande-odoo
Copy link
Contributor

Hi @reth-odoo @Goaman I had to adapt my fix and the code around in this forward port, could you give me a review ? Thanks

Copy link
Contributor

@reth-odoo reth-odoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems probably ok but I'll leave editor review to team editor. Just leaving a comment as runbot is red 👀

addons/web_editor/static/src/js/editor/snippets.options.js Outdated Show resolved Hide resolved
@ande-odoo ande-odoo force-pushed the 17.0-16.0-OPW_3672798-mass_mailing-shapes_not_saving-ande-WsbS-fw branch from 99828d9 to 8c5574d Compare May 16, 2024 10:05
@ande-odoo
Copy link
Contributor

Hi @odoo/rd-framework-editor Could you review my fw port, as I had to adapt my fix for this version ? Thanks !

@dmo-odoo
Copy link
Contributor

@ande-odoo I assume it would make more sense for @bvr-odoo to have a look now since the additional changes you made seem to be the lines added in #134979.

@bvr-odoo
Copy link
Contributor

@ande-odoo I assume it would make more sense for @bvr-odoo to have a look now since the additional changes you made seem to be the lines added in #134979.

@ande-odoo Hello, I tested the branch and hover effect are no longer works with your changes.
Try not to change the order in which things happen when a shape is applied. This will help keep things from breaking ;)
Thanks 👍

Current behavior:
When logged as a mass mailing user,
In a mailing, using the editor, when applying
a shape to an image, the image disappears.

Steps to reproduce:
1. Make sure Marc Demo has the role User
2. Log in as Marc Demo
3. Create a new mailing
4. Select a template
5. Insert a picture
6. Select the picture
7. Change its shape to round
8. (preview works fine)
9. Save the mailing
10. Picture disappears

Cause of the issue:
When applying a shape to an image, the resulting file is of
mimetype 'image/svg+xml', when sending it to the server,
the attachment is going to go through _check_contents
https://github.com/odoo/odoo/blob/d752abb24d9b25bb6d10e411961447c8c8e28bba/odoo/addons/base/models/ir_attachment.py#L364
and if the mimetype is "xml_like", it will check for views write
rights, without what the mimetype will be forced to text/plain.
But in web_editor, when computing the image src
https://github.com/odoo/odoo/blob/b6392e2c7dbc8e1ece326e28a9698801142714b7/addons/web_editor/models/ir_attachment.py#L34
if the mimetype is not a supported image type, src will be False.

Fix:
Override of _writeShape to use canvas to convert
the image from svg to png.

opw-3672798

X-original-commit: 1c5c9af
@ande-odoo ande-odoo force-pushed the 17.0-16.0-OPW_3672798-mass_mailing-shapes_not_saving-ande-WsbS-fw branch from 8c5574d to 5a9f3fe Compare May 31, 2024 16:48
@ande-odoo
Copy link
Contributor

Hi @bvr-odoo It seems like everything is working now, can you have a look ? Thanks !

@bvr-odoo
Copy link
Contributor

bvr-odoo commented Jun 6, 2024

Hi @bvr-odoo It seems like everything is working now, can you have a look ? Thanks !

@ande-odoo LGTM 👍 , I tested it in Website and everything works, thanks

@ande-odoo
Copy link
Contributor

@robodoo r+

@robodoo robodoo closed this in d99f988 Jun 7, 2024
loouis-t pushed a commit to odoo-dev/odoo that referenced this pull request Jun 10, 2024
Current behavior:
When logged as a mass mailing user,
In a mailing, using the editor, when applying
a shape to an image, the image disappears.

Steps to reproduce:
1. Make sure Marc Demo has the role User
2. Log in as Marc Demo
3. Create a new mailing
4. Select a template
5. Insert a picture
6. Select the picture
7. Change its shape to round
8. (preview works fine)
9. Save the mailing
10. Picture disappears

Cause of the issue:
When applying a shape to an image, the resulting file is of
mimetype 'image/svg+xml', when sending it to the server,
the attachment is going to go through _check_contents
https://github.com/odoo/odoo/blob/d752abb24d9b25bb6d10e411961447c8c8e28bba/odoo/addons/base/models/ir_attachment.py#L364
and if the mimetype is "xml_like", it will check for views write
rights, without what the mimetype will be forced to text/plain.
But in web_editor, when computing the image src
https://github.com/odoo/odoo/blob/b6392e2c7dbc8e1ece326e28a9698801142714b7/addons/web_editor/models/ir_attachment.py#L34
if the mimetype is not a supported image type, src will be False.

Fix:
Override of _writeShape to use canvas to convert
the image from svg to png.

opw-3672798

closes odoo#164703

X-original-commit: 1c5c9af
Signed-off-by: Antoine Demany (ande) <ande@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflict There was an error while creating this forward-port PR forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants