diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-03-07 18:46:38 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-03-07 18:46:38 +0100 |
| commit | 4aa5ec3fa511e42a08318fe66dde3bd57f0d1f09 (patch) | |
| tree | d3de91d0113164ce313d7eff44c2f25c7e95f743 /addons/website_form | |
| parent | 3c821d4035d0c85f691653c47986d8f4c3dfc51d (diff) | |
| parent | d67b410dfcd67d2540628d4f6be0daf8861c4a46 (diff) | |
[MERGE] forward port branch 11.0 up to d67b410dfcd
Diffstat (limited to 'addons/website_form')
| -rw-r--r-- | addons/website_form/controllers/main.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/addons/website_form/controllers/main.py b/addons/website_form/controllers/main.py index f4fd9716aa2..b37ca97ea79 100644 --- a/addons/website_form/controllers/main.py +++ b/addons/website_form/controllers/main.py @@ -171,7 +171,8 @@ class WebsiteForm(http.Controller): return data def insert_record(self, request, model, values, custom, meta=None): - record = request.env[model.model].sudo().with_context(mail_create_nosubscribe=True).create(values) + model_name = model.sudo().model + record = request.env[model_name].sudo().with_context(mail_create_nosubscribe=True).create(values) if custom or meta: default_field = model.website_form_default_field_id @@ -183,13 +184,13 @@ class WebsiteForm(http.Controller): # If there is a default field configured for this model, use it. # If there isn't, put the custom data in a message instead if default_field.name: - if default_field.ttype == 'html' or model.model == 'mail.mail': + if default_field.ttype == 'html' or model_name == 'mail.mail': custom_content = nl2br(custom_content) record.update({default_field.name: custom_content}) else: values = { 'body': nl2br(custom_content), - 'model': model.model, + 'model': model_name, 'message_type': 'comment', 'no_auto_thread': False, 'res_id': record.id, @@ -201,7 +202,8 @@ class WebsiteForm(http.Controller): # Link all files attached on the form def insert_attachment(self, model, id_record, files): orphan_attachment_ids = [] - record = model.env[model.model].browse(id_record) + model_name = model.sudo().model + record = model.env[model_name].browse(id_record) authorized_fields = model.sudo()._get_form_writable_fields() for file in files: custom_field = file.field_name not in authorized_fields @@ -209,7 +211,7 @@ class WebsiteForm(http.Controller): 'name': file.filename, 'datas': base64.encodestring(file.read()), 'datas_fname': file.filename, - 'res_model': model.model, + 'res_model': model_name, 'res_id': record.id, } attachment_id = request.env['ir.attachment'].sudo().create(attachment_value) @@ -221,10 +223,10 @@ class WebsiteForm(http.Controller): # If some attachments didn't match a field on the model, # we create a mail.message to link them to the record if orphan_attachment_ids: - if model.model != 'mail.mail': + if model_name != 'mail.mail': values = { 'body': _('<p>Attached files : </p>'), - 'model': model.model, + 'model': model_name, 'message_type': 'comment', 'no_auto_thread': False, 'res_id': id_record, |
