[FIX] website_form: binary work with website_crm_phone_validation

With this change, a binary field in a website form works when
website_crm_phone_validation (website_crm in 13.0) is installed.

The module website_crm_phone_validation would call `extract_data` method
to do some things, but when extract_data was called a second time to
really save data, the FileStorage werkzeug object would already consumed
and files would erroneously appear as empty.

opw-2191873

closes odoo/odoo#46241

X-original-commit: a168fe23cc6d9b817b44c189822952a1ee98d81d
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
Nicolas Lempereur
2020-02-25 13:19:39 +00:00
parent 5da3454499
commit 36d4ff5c4c
+1
View File
@@ -134,6 +134,7 @@ class WebsiteForm(http.Controller):
# If it's not, we'll use attachments instead
if field_name in authorized_fields and authorized_fields[field_name]['type'] == 'binary':
data['record'][field_name] = base64.b64encode(field_value.read())
field_value.stream.seek(0) # do not consume value forever
if authorized_fields[field_name]['manual'] and field_name + "_filename" in dest_model:
data['record'][field_name + "_filename"] = field_value.filename
else: