[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
This commit is contained in:
nafex 2015-06-10 12:43:11 +02:00 committed by Martin Trigaux
parent d1c5aa79d5
commit f5585731f4
1 changed files with 2 additions and 2 deletions

View File

@ -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