From f5585731f41939c38abf3f09df2ab51a7bbe84cc Mon Sep 17 00:00:00 2001 From: nafex Date: Wed, 10 Jun 2015 12:43:11 +0200 Subject: [PATCH] [FIX] website_sale: allow to reset field When filling the form (for invoice or delivery details), once a field has been filled, it's no longer possible to remove the value of this field. e.g. set a company, not possible to remove it when modifies the address This is due to the `get(key)` call that is considered as False with empty strings. Instead, check the existance of the key. Still not accepting mandatory in the form (not checked in this method). Fixes #7017 --- addons/website_sale/controllers/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index af25f578802..b4a93597630 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -464,7 +464,7 @@ class website_sale(http.Controller): # set data if isinstance(data, dict): query = dict((prefix + field_name, data[prefix + field_name]) - for field_name in all_fields if data.get(prefix + field_name)) + for field_name in all_fields if prefix + field_name in data) else: query = dict((prefix + field_name, getattr(data, field_name)) for field_name in all_fields if getattr(data, field_name)) @@ -482,7 +482,7 @@ class website_sale(http.Controller): if not remove_prefix: return query - return dict((field_name, data[prefix + field_name]) for field_name in all_fields if data.get(prefix + field_name)) + return dict((field_name, data[prefix + field_name]) for field_name in all_fields if prefix + field_name in data) def checkout_form_validate(self, data): cr, uid, context, registry = request.cr, request.uid, request.context, request.registry