[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) <nle@odoo.com>
This commit is contained in:
@@ -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'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user