[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) <yti@odoo.com>
This commit is contained in:
Yannick Tivisse
2020-05-11 11:37:32 +00:00
parent 3e4b6f939d
commit b8ccf99f40
+5 -3
View File
@@ -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)