diff options
| author | Christophe Simonis <chs@odoo.com> | 2014-12-02 16:18:08 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2014-12-02 16:18:08 +0100 |
| commit | 1d3f8eba879f02da7fc0bb46c9801029eccbc8c8 (patch) | |
| tree | 10ef917de1be8ef9755cba4f3c9ac951af176b18 /addons/mail/mail_thread.py | |
| parent | 7878b2fd0cb42827b71bd00a1fd8199e73269fe4 (diff) | |
| parent | 591e329bb0efe4997677a0bee2e6f3b558e35df8 (diff) | |
[MERGE] forward port of branch 8.0 up to 591e329
Diffstat (limited to 'addons/mail/mail_thread.py')
| -rw-r--r-- | addons/mail/mail_thread.py | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index fa4d7cf5530..db1ea225713 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1785,6 +1785,26 @@ class mail_thread(osv.AbstractModel): user_field_lst.append(name) return user_field_lst + def _message_auto_subscribe_notify(self, cr, uid, ids, partner_ids, context=None): + """ Send notifications to the partners automatically subscribed to the thread + Override this method if a custom behavior is needed about partners + that should be notified or messages that should be sent + """ + # find first email message, set it as unread for auto_subscribe fields for them to have a notification + if partner_ids: + for record_id in ids: + message_obj = self.pool.get('mail.message') + msg_ids = message_obj.search(cr, SUPERUSER_ID, [ + ('model', '=', self._name), + ('res_id', '=', record_id), + ('type', '=', 'email')], limit=1, context=context) + if not msg_ids: + msg_ids = message_obj.search(cr, SUPERUSER_ID, [ + ('model', '=', self._name), + ('res_id', '=', record_id)], limit=1, context=context) + if msg_ids: + self.pool.get('mail.notification')._notify(cr, uid, msg_ids[0], partners_to_notify=partner_ids, context=context) + def message_auto_subscribe(self, cr, uid, ids, updated_fields, context=None, values=None): """ Handle auto subscription. Two methods for auto subscription exist: @@ -1863,20 +1883,7 @@ class mail_thread(osv.AbstractModel): subtypes = list(subtypes) if subtypes is not None else None self.message_subscribe(cr, uid, ids, [pid], subtypes, context=context) - # find first email message, set it as unread for auto_subscribe fields for them to have a notification - if user_pids: - for record_id in ids: - message_obj = self.pool.get('mail.message') - msg_ids = message_obj.search(cr, SUPERUSER_ID, [ - ('model', '=', self._name), - ('res_id', '=', record_id), - ('type', '=', 'email')], limit=1, context=context) - if not msg_ids: - msg_ids = message_obj.search(cr, SUPERUSER_ID, [ - ('model', '=', self._name), - ('res_id', '=', record_id)], limit=1, context=context) - if msg_ids: - self.pool.get('mail.notification')._notify(cr, uid, msg_ids[0], partners_to_notify=user_pids, context=context) + self._message_auto_subscribe_notify(cr, uid, ids, user_pids, context=context) return True |
