Skip to content

Commit

Permalink
[FIX] bug image extension
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieudelva committed Aug 14, 2024
1 parent b05efd5 commit 1cdeb9e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions account_move_adyen_import/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down
6 changes: 5 additions & 1 deletion zip_product_image/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import base64
import imghdr

from odoo import api, models

LIMIT = 500
Expand Down Expand Up @@ -29,4 +31,6 @@ def _product_image_data(self):
if self.image:
return (base64.b64encode(self.image.getvalue()), self.image.extension)
return (False, False)
return (self.image_1920 or False, '.jpg')
image_data = base64.b64decode(self.image_1920)
image_type = imghdr.what(None, h=image_data)
return (self.image_1920 or False, f".{image_type}")
7 changes: 4 additions & 3 deletions zip_product_image/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down
4 changes: 1 addition & 3 deletions zip_product_image/wizards/export_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def _get_zip_product_images(self, products):
name = ""
for field in self._product_field_names():
name = name or prd[field]
zip_file.writestr(
f"{name}{extension}", img_data
)
zip_file.writestr(f"{name}.{extension}", img_data)
else:
logger.warning(f"Product {prd.display_name} has no image")
if zip_file.filelist:
Expand Down

0 comments on commit 1cdeb9e

Please sign in to comment.