diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-03-06 14:19:32 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-03-06 14:19:32 +0100 |
| commit | cc86634b81627fdb06d4942baaee1dbba718eb58 (patch) | |
| tree | bdcfe5aba79587a600532bd555c3209b73d28e72 /addons/website_form/controllers | |
| parent | b771dd8a5cb9fdc37b9ed3e071c00ac9404d9074 (diff) | |
| parent | 5ddb3fdb0e9375607bf07b134c3cf61d6a5cda93 (diff) | |
[MERGE] forward port branch saas-14 up to 5ddb3fdb0e9
Diffstat (limited to 'addons/website_form/controllers')
| -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 960fd7a5d7e..e7e48ba372f 100644 --- a/addons/website_form/controllers/main.py +++ b/addons/website_form/controllers/main.py @@ -170,7 +170,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 @@ -182,13 +183,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, @@ -200,7 +201,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 @@ -208,7 +210,7 @@ class WebsiteForm(http.Controller): 'name': file.field_name if custom_field else 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) @@ -220,10 +222,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, |
