Skip to content

Commit

Permalink
[MIG] storage_thumbnail: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminSForgeFlow committed Oct 25, 2023
1 parent c4765d2 commit 606c9f1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion storage_thumbnail/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Storage Thumbnail",
"summary": "Abstract module that add the possibility to have thumbnail",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Storage",
"website": "https://github.com/OCA/storage",
"author": " Akretion, Odoo Community Association (OCA)",
Expand Down
8 changes: 4 additions & 4 deletions storage_thumbnail/models/storage_thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import requests

from odoo import api, fields, models
from odoo.tools import ImageProcess
from odoo.tools import image_process

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -56,9 +56,9 @@ def _resize(self, image, size_x, size_y, fmt):
if image_resize_server and image.backend_id.served_by != "odoo":
values = {"url": image.url, "width": size_x, "height": size_y, "fmt": fmt}
url = image_resize_server.format(**values)
return base64.encodebytes(requests.get(url).content)
image_process = ImageProcess(image.data)
return image_process.resize(max_width=size_x, max_height=size_y).image_base64()
return base64.encodebytes(requests.get(url, timeout=15).content)
image_processed = base64.b64encode(image_process(image.data))
return image_processed

def _get_default_backend_id(self):
"""Choose the correct backend.
Expand Down
2 changes: 1 addition & 1 deletion storage_thumbnail/models/thumbnail_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def get_or_create_thumbnail(self, size_x, size_y, url_key=None):
# storage.thumbnail is not defined as a one2many to this mixin.
# As consequence, the ORM is not able to trigger the invalidation
# of thumbnail_ids on our mixin
self.thumbnail_ids.refresh()
self.thumbnail_ids.invalidate_recordset()
return thumbnail

def generate_odoo_thumbnail(self):
Expand Down
2 changes: 1 addition & 1 deletion storage_thumbnail/tests/test_thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_urls(self):
self.assertRecordValues(images, expected)
# Unless we enforce it
image1.backend_id.backend_view_use_internal_url = True
images.invalidate_cache()
images.invalidate_recordset()
expected = [
{
"url": f"{cdn}/akretion-logo-{image1.file_id.id}.png",
Expand Down

0 comments on commit 606c9f1

Please sign in to comment.