diff options
| author | Nicolas Lempereur <nle@odoo.com> | 2018-01-08 14:46:35 +0100 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2018-01-08 15:58:30 +0100 |
| commit | dc61861f90d15797b19f8ebddfb0c8a66d0afa88 (patch) | |
| tree | 9b32e3341e59257f4c19d6a1ff659c81d3a9d2e8 | |
| parent | 10c3b31d0f1221641e04365a33160b693abb6cdc (diff) | |
[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
| -rw-r--r-- | addons/payment/models/payment_acquirer.py | 10 | ||||
| -rw-r--r-- | 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 @@ <field name="arch" type="xml"> <form string="Payment Icon"> <sheet> - <field name="image" widget="image" class="oe_avatar" options='{"preview_image": "image_medium"}'/> + <field name="image" widget="image" class="oe_avatar"/> <div class="oe_title"> <h1><field name="name" placeholder="Name"/></h1> </div> |
