[FIX] *: convert image route size param to int and use named param

* = tools, base, web, website_profile, website_slides

Before this commit it was impossible to pass those parameters in the URL because
they were received as string but expected as int.

The opportunity is also taken to properly use named parameters when calling
`image_process`.

closes odoo/odoo#33506

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
Sébastien Theys
2019-05-21 10:34:40 +00:00
parent 9613483241
commit d445f46806
6 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -1049,7 +1049,7 @@ class Binary(http.Controller):
if not (width or height):
width, height = odoo.tools.image_guess_size_from_field_name(field)
image_base64 = image_process(image_base64, (width, height), crop=crop)
image_base64 = image_process(image_base64, size=(int(width), int(height)), crop=crop)
content = base64.b64decode(image_base64)
headers = http.set_safe_image_headers(headers, content)
+1 -1
View File
@@ -95,7 +95,7 @@ class WebsiteProfile(http.Controller):
if not (width or height):
width, height = tools.image_guess_size_from_field_name(field)
image_base64 = tools.image_process(image_base64, (width, height), crop=crop)
image_base64 = tools.image_process(image_base64, size=(int(width), int(height)), crop=crop)
content = base64.b64decode(image_base64)
headers = http.set_safe_image_headers(headers, content)
+1 -1
View File
@@ -544,7 +544,7 @@ class WebsiteSlides(WebsiteProfile):
if not (width or height):
width, height = tools.image_guess_size_from_field_name(field)
image_base64 = tools.image_process(image_base64, (width, height), crop=crop)
image_base64 = tools.image_process(image_base64, size=(int(width), int(height)), crop=crop)
content = base64.b64decode(image_base64)
headers = http.set_safe_image_headers(headers, content)
+1 -1
View File
@@ -155,7 +155,7 @@ class Company(models.Model):
@api.depends('partner_id', 'partner_id.image')
def _compute_logo_web(self):
for company in self:
company.logo_web = tools.image_process(company.partner_id.image, (180, None))
company.logo_web = tools.image_process(company.partner_id.image, size=(180, 0))
@api.onchange('state_id')
def _onchange_state(self):
+1 -1
View File
@@ -64,7 +64,7 @@ class test_ir_http_mimetype(common.TransactionCase):
'type': 'binary',
})
resized = odoo.tools.image_process(prop.value_binary, odoo.tools.IMAGE_SMALL_SIZE)
resized = odoo.tools.image_process(prop.value_binary, size=odoo.tools.IMAGE_SMALL_SIZE)
# Simul computed field which resize and that is not attachement=True (E.G. on product)
prop.write({'value_binary': resized})
status, headers, content = self.env['ir.http'].binary_content(
+1 -1
View File
@@ -387,5 +387,5 @@ if __name__=="__main__":
assert len(sys.argv)==3, 'Usage to Test: image.py SRC.png DEST.png'
img = base64.b64encode(open(sys.argv[1],'rb').read())
new = image_process(img, (128, 100))
new = image_process(img, size=(128, 100))
open(sys.argv[2], 'wb').write(base64.b64decode(new))