[FW][FIX] product: always compute zoomable with bin_size=False
#192593
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changing a product template's image with the
can_image_1024_be_zoomed
field present in the view produces a crash on save.STEPS TO REPRODUCE
can_image_1024_be_zoomed
fieldThe product will be updated, but this error will be thrown:
CAUSE
odoo/addons/product/models/product_template.py
Lines 186 to 188 in a746847
In the
RecordSet
's context,bin_size=True
, so accessingimage_<size>
returns a size instead of a binary._compute_can_image_1024_be_zoomed
callstools.is_image_size_above
with this binary size, while the method expects the full base64 encoded image. Ultimately, this causesbase64.b64decode
to crash with the above error.FIX Update the
RecordSet
's context tobin_size=False
. Accessingimage_<size>
from theRecordSet
will then return the full binary instead of the size.NOTES
In versions <17.0, read and write were done in separate network calls causing the recompute to happen during the flush of the write, which doesn't have
bin_size=True
in the context. Because the field is stored, the read will not cause a recompute and thus avoids any error. In >=17.0, because the read occurs before the flush, and the write has invalidated the field, the recompute will occur with the context of the read (bin_size=True
), causing the issue.opw-4413647
Forward-Port-Of: #192409
Forward-Port-Of: #192047