[FIX] website_form: set filename on studio binary

Using studio, add a file field on a form. Using the web form builder,
append that field on a form. Upload a file, `x_field_filename` is left
empty thus the filename is lost.

opw-2028071

closes odoo/odoo#34491

Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
This commit is contained in:
Julien Castiaux
2019-07-01 13:20:51 +00:00
parent 2d03ed43a5
commit 0e2f3b1445
+2
View File
@@ -129,6 +129,8 @@ 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']:
data['record'][field_name + "_filename"] = field_value.filename
else:
field_value.field_name = field_name
data['attachments'].append(field_value)