2
# -*- encoding: utf-8 -*-
3
###########################################################################
4
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (C) 2013 Vauxoo (<http://vauxoo.com>).
7
###############Credits######################################################
8
# Coded by: vauxoo consultores (info@vauxoo.com)
9
#############################################################################
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU Affero General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
15
# This program is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU Affero General Public License for more details.
20
# You should have received a copy of the GNU Affero General Public License
21
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
################################################################################
25
from openerp.osv import osv, fields
26
from openerp import tools, SUPERUSER_ID
28
class mail_compose_message(osv.TransientModel):
30
_inherit = 'mail.compose.message'
32
def generate_email_for_composer(self, cr, uid, template_id, res_id, context=None):
34
values = super(mail_compose_message, self).generate_email_for_composer(cr, uid,
35
template_id, res_id, context=context)
37
if values.get('partner_ids', False):
38
partners_to_notify = set([])
39
partner_follower = self.pool.get('mail.followers')
41
fol_ids = partner_follower.search(cr, SUPERUSER_ID, [
42
('res_model', '=', context.get('active_model')),
43
('res_id', '=', context.get('active_id')),
46
partners_to_notify |= set(fo.partner_id.id\
47
for fo in partner_follower.browse(cr, SUPERUSER_ID, fol_ids, context=context))
49
partners_followers_notify = values.get('partner_ids', []) + list(partners_to_notify)
50
values.update({'partner_ids': list(set(partners_followers_notify))})