From b8ccf99f4091751ea7c2d527c32d6696e44bd1b5 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Mon, 11 May 2020 07:53:31 +0000 Subject: [PATCH] [FIX] portal: Fix 7ff683a and 009b632 Purpose ======= Followup of https://github.com/odoo/odoo/pull/36272 - state_id should be casted into an integer. - On the other hand, https://github.com/odoo/odoo/commit/009b632c552822cb9892a2ccdbe9d79947d88a34 is broken too as we cast into an integer something that could be equal to '', leading then to a ValueError. closes odoo/odoo#51028 X-original-commit: 46cd2fef8576f73aa70cc166037abd8cf0581412 Signed-off-by: Yannick Tivisse (yti) --- addons/portal/controllers/portal.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/portal/controllers/portal.py b/addons/portal/controllers/portal.py index 87e3108a2b3..74137213769 100644 --- a/addons/portal/controllers/portal.py +++ b/addons/portal/controllers/portal.py @@ -174,10 +174,12 @@ class CustomerPortal(Controller): if not error: values = {key: post[key] for key in self.MANDATORY_BILLING_FIELDS} values.update({key: post[key] for key in self.OPTIONAL_BILLING_FIELDS if key in post}) - values.update({'country_id': int(values.pop('country_id', 0))}) + for field in set(['country_id', 'state_id']) & set(values.keys()): + try: + values[field] = int(values[field]) + except: + values[field] = False values.update({'zip': values.pop('zipcode', '')}) - if values.get('state_id') == '': - values.update({'state_id': False}) partner.sudo().write(values) if redirect: return request.redirect(redirect)