diff options
| author | Jamin Shah <jas@openerp.com> | 2015-08-24 12:50:06 +0530 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2015-11-26 11:26:46 +0100 |
| commit | 3560cf04eee4dde7683218428fc8211bb1365633 (patch) | |
| tree | 06a1f9d4755ad34817e4dd498f250919e0bec096 /addons/project/project.py | |
| parent | 60c010d30649fccd61e9ca4b2356d63e815c8c55 (diff) | |
[IMP] mail: headers to notification emails
>
> This merge adds some basic data to notification emails headers. It contains the related
> record of the notification. This allows users to classify / perform action based on
> headers.
>
> Headers :
> - X-Odoo-Objects: list of records
> - X-Odoo-db-uuid: database uid
In task and issue, we had the parent project and the tags in the headers.
Diffstat (limited to 'addons/project/project.py')
| -rw-r--r-- | addons/project/project.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/addons/project/project.py b/addons/project/project.py index aeee91eb948..8f9c0c598af 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -9,6 +9,7 @@ from openerp import api from openerp import SUPERUSER_ID from openerp import tools from openerp.osv import fields, osv +from openerp.tools.safe_eval import safe_eval as eval from openerp.tools.translate import _ from openerp.exceptions import UserError @@ -833,6 +834,24 @@ class task(osv.osv): data._message_add_suggested_recipient(recipients, partner=data.partner_id, reason=reason) return recipients + def message_get_email_values(self, cr, uid, ids, notif_mail=None, context=None): + res = super(task, self).message_get_email_values(cr, uid, ids, notif_mail=notif_mail, context=context) + current_task = self.browse(cr, uid, ids[0], context=context) + headers = {} + if res.get('headers'): + try: + headers.update(eval(res['headers'])) + except Exception: + pass + if current_task.project_id: + current_objects = filter(None, headers.get('X-Odoo-Objects', '').split(',')) + current_objects.insert(0, 'project.project-%s, ' % current_task.project_id.id) + headers['X-Odoo-Objects'] = ','.join(current_objects) + if current_task.tag_ids: + headers['X-Odoo-Tags'] = ','.join([tag.name for tag in current_task.tag_ids]) + res['headers'] = repr(headers) + return res + class account_analytic_account(osv.osv): _inherit = 'account.analytic.account' |
