-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
[10.0] [MIG] product_multi_image (supersede) #359
Conversation
Hi, This PR requires OCA/server-tools#1286 but the latter is pending reviewers. Those interested can collaborate in the revision. Thanks! |
Now that the other module has been merged, please review this one and fix lint and CI errors |
ac4f402
to
922f31a
Compare
There was a problem hiding this 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.
There was a problem hiding this 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
@LRovira-PlanetaTIC Please, could you review this? Thanks |
There was a problem hiding this 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.
4e16434
to
bb4dca2
Compare
def _set_multi_image_main_medium(self): | ||
# on save product module resizes large image to medium | ||
# medium image should not overwrite the large | ||
pass |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
- 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 - product_multi_image redefines image fields for all sizes as related from main image.
- 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... 😕
There was a problem hiding this comment.
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.
I have squashed a bit the commit history before reviewing. |
) | ||
self.assertFalse(len(images)) | ||
|
||
def test_uninstall_hook_teplate(self): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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?
* Upgrade product_multi_image to v9 * Add server-tools to oca_dependencies
* Migrate product_multi_image to v10 * Remove old api from `product.product` * Add test coverage for hooks and variant count * Fix oca depends * Add uninstall hook
multi to single mode
when saved from single image
bb4dca2
to
b068943
Compare
@fuentes010 , done. Regards! 👋 |
Can we merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking
This PR has the |
/ocabot merge |
Hey, thanks for contributing! Proceeding to merge this for you. |
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 |
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!