From 36d4ff5c4c9e68a9b5eb2b2425670aecf2f9a53a Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 19 Feb 2020 18:20:15 +0000 Subject: [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) --- addons/website_form/controllers/main.py | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/website_form/controllers') diff --git a/addons/website_form/controllers/main.py b/addons/website_form/controllers/main.py index a39ce5eaeb0..1e3614bf3d5 100644 --- a/addons/website_form/controllers/main.py +++ b/addons/website_form/controllers/main.py @@ -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: -- cgit v1.2.3