From 1bcab2f42eebf98127416e54f31cd6e351938b7f Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 19 Feb 2020 18:20:04 +0000 Subject: [PATCH] [FIX] website_form: binary field do not need _filename When a binary field is added to studio, the system will try to write the name to {binary_field_name}_filename: this works if the field was created with studio but could not work eg. if just a binary field is created manually. opw-2191873 closes #45994 closes odoo/odoo#46164 X-original-commit: 13b65d878d5240f07b279045e30d53915d176a61 Signed-off-by: Nicolas Lempereur (nle) --- addons/website_form/controllers/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website_form/controllers/main.py b/addons/website_form/controllers/main.py index 7a0eecf0704..a39ce5eaeb0 100644 --- a/addons/website_form/controllers/main.py +++ b/addons/website_form/controllers/main.py @@ -111,6 +111,7 @@ class WebsiteForm(http.Controller): # Extract all data sent by the form and sort its on several properties def extract_data(self, model, values): + dest_model = request.env[model.sudo().model] data = { 'record': {}, # Values to create record @@ -133,7 +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()) - if authorized_fields[field_name]['manual']: + if authorized_fields[field_name]['manual'] and field_name + "_filename" in dest_model: data['record'][field_name + "_filename"] = field_value.filename else: field_value.field_name = field_name @@ -167,7 +168,6 @@ class WebsiteForm(http.Controller): # def website_form_input_filter(self, values): # values['name'] = '%s\'s Application' % values['partner_name'] # return values - dest_model = request.env[model.sudo().model] if hasattr(dest_model, "website_form_input_filter"): data['record'] = dest_model.website_form_input_filter(request, data['record'])