[ADD] doc files lost during git conversion
[odoo/odoo.git] / addons / portal / mail_thread.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2013-TODAY OpenERP S.A (<http://www.openerp.com>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 from openerp import SUPERUSER_ID
23 from openerp.osv import osv
24
25
26 class mail_thread(osv.AbstractModel):
27     """ Update of mail_mail class, to add the signin URL to notifications. """
28     _inherit = 'mail.thread'
29
30     def _get_inbox_action_xml_id(self, cr, uid, context=None):
31         """ For a given message, return an action that either
32             - opens the form view of the related document if model, res_id, and
33               read access to the document
34             - opens the Inbox with a default search on the conversation if model,
35               res_id
36             - opens the Inbox with context propagated
37         """
38         cur_user = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context)
39         # if uid is a portal user -> action is different
40         if any(group.is_portal for group in cur_user.groups_id):
41             return ('portal', 'action_mail_inbox_feeds_portal')
42         else:
43             return super(mail_thread, self)._get_inbox_action_xml_id(cr, uid, context=context)