diff options
| author | Nicolas Lempereur <nle@odoo.com> | 2020-02-19 18:20:04 +0000 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2020-02-24 19:40:58 +0000 |
| commit | 1bcab2f42eebf98127416e54f31cd6e351938b7f (patch) | |
| tree | 5acf8dd32aabf795e3efdfbd03af5edb2b44f6d1 | |
| parent | c78bfb1da9431e90500af1c54efb182b57ecf13a (diff) | |
[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>
| -rw-r--r-- | addons/website_form/controllers/main.py | 4 |
1 files 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']) |
