summaryrefslogtreecommitdiff
path: root/addons/website_form/models/models.py
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2017-06-29 14:07:01 +0200
committerNicolas Martinelli <nim@odoo.com>2017-06-30 10:20:56 +0200
commitd1e92c312f2fdfd63d59ea8ec27eb264750873b7 (patch)
tree02153fc18491bd8f5521269ab5ac876546919d67 /addons/website_form/models/models.py
parentaf11e74c2e1f5d37e01c71d29ee1fad2eedcd060 (diff)
[FIX] website_form: send email with subject
- Use the form builder to send an email - Customize the snippet to include the subject and the body - Send a mail => The subject is not included in the email This is because the subject is filtered out and considered as a blacklisted field. It happens because `mail.mail` inherits from `mail.message`. The field property `website_form_blacklisted` is set to: - `True` for `mail.mail` - `False` for `mail.message` Since we go through all inherited models, the property on `mail.mail` is overriden by the property on `mail.message`. It is actually not necessary to go through all inherited models, since in the case of `inherits`, we copy the fields of the inherited model to the target model. The check is simplified by only checking the fields of the current model. Based on work of @nla-odoo opw-748926
Diffstat (limited to 'addons/website_form/models/models.py')
-rw-r--r--addons/website_form/models/models.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/addons/website_form/models/models.py b/addons/website_form/models/models.py
index 16aba290a2a..d2f04b7f930 100644
--- a/addons/website_form/models/models.py
+++ b/addons/website_form/models/models.py
@@ -20,12 +20,6 @@ class website_form_model(models.Model):
website_form_default_field_id = fields.Many2one('ir.model.fields', 'Field for custom form data', domain="[('model', '=', model), ('ttype', '=', 'text')]", help="Specify the field which will contain meta and custom form fields datas.")
website_form_label = fields.Char("Label for form action", help="Form action label. Ex: crm.lead could be 'Send an e-mail' and project.issue could be 'Create an Issue'.")
- def _all_inherited_model_ids(self):
- return list(itertools.chain(
- [self.id],
- *(m._all_inherited_model_ids() for m in self.inherited_model_ids)
- ))
-
def _get_form_writable_fields(self):
"""
Restriction of "authorized fields" (fields which can be used in the
@@ -33,16 +27,16 @@ class website_form_model(models.Model):
builders and are writable. By default no field is writable by the
form builder.
"""
- excluded = {
+ included = {
field.name
for field in self.env['ir.model.fields'].sudo().search([
- ('model_id', 'in', self._all_inherited_model_ids()),
- ('website_form_blacklisted', '=', True)
+ ('model_id', '=', self.id),
+ ('website_form_blacklisted', '=', False)
])
}
return {
k: v for k, v in self.get_authorized_fields().iteritems()
- if k not in excluded
+ if k in included
}
@api.multi