From 7ff683a7e1d852f59594cd353424ec6e66d4662c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Lef=C3=A8vre?= Date: Fri, 30 Aug 2019 10:03:26 +0000 Subject: [PATCH] [FIX] portal: Allow to edit without state From the user's frontend "My Account" page: - Try to edit your details. - Complete the form with all required fields. - Select a country for which there are no states (the `state_id` field is hidden) - And confirm => Internal server error The state was not filled, therefore the value sent to the server is an empty string. This empty string is used in the UPDATE query to register the state value. Since it's a string and not a valid (integer) id, the query fails. closes odoo/odoo#36272 Signed-off-by: Yannick Tivisse (yti) --- addons/portal/controllers/portal.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/portal/controllers/portal.py b/addons/portal/controllers/portal.py index 0b6ea4c7983..32ddca6ea22 100644 --- a/addons/portal/controllers/portal.py +++ b/addons/portal/controllers/portal.py @@ -175,6 +175,8 @@ class CustomerPortal(Controller): 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({'zip': values.pop('zipcode', '')}) + if values.get('state_id') == '': + values.update({'state_id': False}) partner.sudo().write(values) if redirect: return request.redirect(redirect)