Skip to content
Permalink
Browse files

[FIX] website_form: link attachments to binary fields

If the name of a file input field is 'x_binary_input', before
commit 9be2937 (opw 2092653),
self.form_fields would have names of the form 'x_binary_input[i]'.
After this commit, they are of the form 'x_binary_input[i][j]'.
When calling extract_data, field_name would then be 'x_binary_input[i]'
instead of 'x_binary_input'. Therefore, the file would be considered as orphan
instead of being attached to x_binary_input.
We thus change the split so that it always returns 'x_binary_input'.

opw 2122624

closes #41110

Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
  • Loading branch information
fah-odoo committed Nov 29, 2019
1 parent af184e7 commit 21ed2b971f66879fa3fa53dbd2c349ab39fa3fdb
Showing with 1 addition and 1 deletion.
  1. +1 −1 addons/website_form/controllers/main.py
@@ -123,7 +123,7 @@ def extract_data(self, model, values):
# If the value of the field if a file
if hasattr(field_value, 'filename'):
# Undo file upload field name indexing
field_name = field_name.rsplit('[', 1)[0]
field_name = field_name.split('[', 1)[0]

# If it's an actual binary field, convert the input file
# If it's not, we'll use attachments instead

0 comments on commit 21ed2b9

Please sign in to comment.
You can’t perform that action at this time.