[IMP] mail: add optional mail subtypes

This commit adds a way to filter out mail message subtypes for specific
records.

Task ID: 2585025

closes odoo/odoo#74764

Related: odoo/upgrade#2719
Related: odoo/enterprise#20096
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
William Braeckman
2021-08-30 13:27:50 +00:00
parent 2b832269f4
commit 5b05352c99
2 changed files with 9 additions and 4 deletions
+4 -4
View File
@@ -49,12 +49,12 @@ class DiscussController(http.Controller):
follower = request.env['mail.followers'].sudo().browse(follower_id)
follower.ensure_one()
request.env[follower.res_model].check_access_rights("read")
request.env[follower.res_model].browse(follower.res_id).check_access_rule("read")
record = request.env[follower.res_model].browse(follower.res_id)
record.check_access_rule("read")
# find current model subtypes, add them to a dictionary
subtypes = request.env['mail.message.subtype'].search([
'&', ('hidden', '=', False),
'|', ('res_model', '=', follower.res_model), ('res_model', '=', False)])
subtypes = record._mail_get_message_subtypes()
followed_subtypes_ids = set(follower.subtype_ids.ids)
subtypes_list = [{
'name': subtype.name,
+5
View File
@@ -198,6 +198,11 @@ class BaseModel(models.AbstractModel):
# GATEWAY: NOTIFICATION
# ------------------------------------------------------------
def _mail_get_message_subtypes(self):
return self.env['mail.message.subtype'].search([
'&', ('hidden', '=', False),
'|', ('res_model', '=', self._name), ('res_model', '=', False)])
def _notify_email_headers(self):
"""
Generate the email headers based on record