From dc61861f90d15797b19f8ebddfb0c8a66d0afa88 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 8 Jan 2018 14:46:35 +0100 Subject: [PATCH] [FIX] payment: py3 error payment icon save Code to thumbnail payment icon image had an error for python3 because from RPC the image would be a text string instead of an expected bytestring. This change accepts both and made another small fix in the view since image_medium doesn't exist (and image is already thumbnailed). A third fix was that removing an image caused an error. opw-803722 closes #22088 --- addons/payment/models/payment_acquirer.py | 10 ++++++---- addons/payment/views/payment_views.xml | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 82033d4375b..198f8c5d336 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -437,15 +437,17 @@ class PaymentIcon(models.Model): @api.model def create(self, vals): if 'image' in vals: - vals['image_payment_form'] = image_resize_image(vals['image'], size=(45,30)) - vals['image'] = image_resize_image(vals['image'], size=(64,64)) + image = ustr(vals['image'] or '').encode('utf-8') + vals['image_payment_form'] = image_resize_image(image, size=(45,30)) + vals['image'] = image_resize_image(image, size=(64,64)) return super(PaymentIcon, self).create(vals) @api.multi def write(self, vals): if 'image' in vals: - vals['image_payment_form'] = image_resize_image(vals['image'], size=(45,30)) - vals['image'] = image_resize_image(vals['image'], size=(64,64)) + image = ustr(vals['image'] or '').encode('utf-8') + vals['image_payment_form'] = image_resize_image(image, size=(45,30)) + vals['image'] = image_resize_image(image, size=(64,64)) return super(PaymentIcon, self).write(vals) class PaymentTransaction(models.Model): diff --git a/addons/payment/views/payment_views.xml b/addons/payment/views/payment_views.xml index f97812a15c7..21f63f8cf14 100644 --- a/addons/payment/views/payment_views.xml +++ b/addons/payment/views/payment_views.xml @@ -416,7 +416,7 @@
- +