Files
odoo_source/addons/mail/models/models.py
T
Xavier-Do 581a74143e [REF] mail: simplify notification code
Purpose of this commit is to clean notification process: calls, methods
API, method name, variable propagation.

Contains notably

  * simplify API of methods used to group recipients when sending notification
    emails;
  * improve and rename methods used in email notification process;
  * move some methods on model itself as non mail thread records could be
    mass-mailed and _notify_email_headers could be called on other records;

Related to task 1943901
Linked to PR #32404
2019-05-29 13:34:32 +00:00

35 lines
961 B
Python

# -*- coding: utf-8 -*-
from odoo import models, api
from lxml.builder import E
class BaseModel(models.AbstractModel):
_inherit = 'base'
@api.model
def _get_default_activity_view(self):
""" Generates an empty activity view.
:returns: a activity view as an lxml document
:rtype: etree._Element
"""
field = E.field(name=self._rec_name_fallback())
activity_box = E.div(field, {'t-name': "activity-box"})
templates = E.templates(activity_box)
return E.activity(templates, string=self._description)
@api.multi
def _notify_email_headers(self):
"""
Generate the email headers based on record
"""
if not self:
return {}
self.ensure_one()
return repr(self._notify_email_header_dict())
def _notify_email_header_dict(self):
return {
'X-Odoo-Objects': "%s-%s" % (self._name, self.id),
}