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

[10.0] [MIG] product_multi_image (supersede) #359

Closed

Conversation

FFernandez-PlanetaTIC
Copy link
Member

Hi,

Supersedes #201 and improves uninstall hook to move images from multi to single mode.

Requires of OCA/server-tools#1286 to do it.

Thanks!

@FFernandez-PlanetaTIC
Copy link
Member Author

Hi,

This PR requires OCA/server-tools#1286 but the latter is pending reviewers.

Those interested can collaborate in the revision.

Thanks!

@pedrobaeza
Copy link
Member

Now that the other module has been merged, please review this one and fix lint and CI errors

@FFernandez-PlanetaTIC FFernandez-PlanetaTIC force-pushed the 10.0-MIG-product_multi_image branch 4 times, most recently from ac4f402 to 922f31a Compare July 5, 2018 11:28
Copy link
Member Author

@FFernandez-PlanetaTIC FFernandez-PlanetaTIC left a comment

Choose a reason for hiding this comment

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

846709c avoids resizing large image to small/medium when saved from single image. This fix is required to pass product_default_image tests.

Copy link
Member Author

@FFernandez-PlanetaTIC FFernandez-PlanetaTIC left a comment

Choose a reason for hiding this comment

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

922f31a fixes error in product_default_image install hook when product_multi_image changes image field to computed and non-store

@FFernandez-PlanetaTIC
Copy link
Member Author

@LRovira-PlanetaTIC Please, could you review this? Thanks

Copy link
Member

@LRovira-PlanetaTIC LRovira-PlanetaTIC left a comment

Choose a reason for hiding this comment

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

OK, it works correctly. Now, you can uninstall the module and the main image is saved as a product image.

def _set_multi_image_main_medium(self):
# on save product module resizes large image to medium
# medium image should not overwrite the large
pass
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about this inheritance break, as you are not calling super here in any case. Can you discriminate any way when to not call super? What is the use case for always inhibiting this method?

Copy link
Member Author

Choose a reason for hiding this comment

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

There was an issue saving an image as the main of a product, it was resized to small before saving:

This happens because:

  1. product module resizes an image to all sizes before saving it.
    https://github.com/OCA/OCB/blob/7a824c376ffe0ef6326c7c03a12e9105f9ce9f51/addons/product/models/product_template.py#L289
    https://github.com/OCA/OCB/blob/7a824c376ffe0ef6326c7c03a12e9105f9ce9f51/odoo/tools/image.py#L266
  2. product_multi_image redefines image fields for all sizes as related from main image.
  3. base_multi_image saves main image for all sizes in the same field:
    https://github.com/OCA/server-tools/blob/201129d9905f1312405bf4f3e08bf6e082312ac9/base_multi_image/models/owner.py#L19

Consequently the images for all sizes are saved in the same field and the last one, in this case the small one, wins 🐥🏆

As an image is always saved for all sizes and, to not lose quality, I always save it as the largest, I fix the issue not saving it for the rest of sizes.

I can not think of a better solution... 😕

Choose a reason for hiding this comment

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

Have studied this also. I think the solution is good because it's an exception for products only, necessary because products have already this built-in resizing on write. As base_multi_image mentions clearly, the _set_multi_image_main_* family of functions is meant only as a compatibility layer. Product IMO could be an exception to this rule - the images are still saved correctly and without loss.

@pedrobaeza
Copy link
Member

I have squashed a bit the commit history before reviewing.

)
self.assertFalse(len(images))

def test_uninstall_hook_teplate(self):

Choose a reason for hiding this comment

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

typo here.

def _set_multi_image_main_medium(self):
# on save product module resizes large image to medium
# medium image should not overwrite the large
pass

Choose a reason for hiding this comment

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

Have studied this also. I think the solution is good because it's an exception for products only, necessary because products have already this built-in resizing on write. As base_multi_image mentions clearly, the _set_multi_image_main_* family of functions is meant only as a compatibility layer. Product IMO could be an exception to this rule - the images are still saved correctly and without loss.

Copy link
Member

@fuentes73 fuentes73 left a comment

Choose a reason for hiding this comment

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

Please can you rebase and resolve conflicts?

@FFernandez-PlanetaTIC
Copy link
Member Author

@fuentes010 , done.

Regards! 👋

@FFernandez-PlanetaTIC
Copy link
Member Author

Can we merge this?

Copy link
Member

@nikul-serpentcs nikul-serpentcs left a comment

Choose a reason for hiding this comment

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

Nitpicking

product_multi_image/__manifest__.py Outdated Show resolved Hide resolved
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@pedrobaeza
Copy link
Member

/ocabot merge

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Rebased to 10.0-ocabot-merge-pr-359-by-pedrobaeza-bump-no, awaiting test results.

@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at ab78d90. Thanks a lot for contributing to OCA. ❤️

PS: Don't worry if GitHub says there are unmerged commits: it is due to a rebase before merge. All commits of this PR have been merged into 10.0.

OCA-git-bot added a commit that referenced this pull request Jul 10, 2019
Signed-off-by pedrobaeza
@FFernandez-PlanetaTIC FFernandez-PlanetaTIC deleted the 10.0-MIG-product_multi_image branch July 10, 2019 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants