[IMP] account: unique description for wizard model
[odoo/odoo.git] / addons / project_scrum / wizard / mail_compose_message.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2010-Today OpenERP SA (<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 General Public License as published by
9 #    the Free Software Foundation, either version 3 of the License, or
10 #    (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 General Public License for more details.
16 #
17 #    You should have received a copy of the GNU General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>
19 #
20 ##############################################################################
21
22 from osv import osv
23 from osv import fields
24 from tools.translate import _
25
26 class mail_compose_message(osv.osv_memory):
27     _inherit = 'mail.compose.message'
28
29     def get_value(self, cr, uid, model, resource_id, context=None):
30         '''
31         To get values of the resource_id for the model
32         @param model: Object
33         @param resource_id: id of a record for which values to be read
34
35         @return: Returns a dictionary
36         '''
37         if context is None:
38             context = {}
39         result = super(mail_compose_message, self).get_value(cr, uid,  model, resource_id, context=context)
40         if model == 'project.scrum.meeting' and resource_id:
41             meeting_pool = self.pool.get('project.scrum.meeting')
42             user_pool = self.pool.get('res.users')
43             meeting = meeting_pool.browse(cr, uid, resource_id, context=context)
44
45             sprint = meeting.sprint_id
46             user_data = user_pool.browse(cr, uid, uid, context=context)
47             result.update({'email_from': user_data.address_id and user_data.address_id.email or False})
48
49             if sprint.scrum_master_id and sprint.scrum_master_id.user_email:
50                 result.update({'email_to': sprint.scrum_master_id.user_email})
51             if sprint.product_owner_id and sprint.product_owner_id.user_email:
52                 result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' +  sprint.product_owner_id.user_email or sprint.product_owner_id.user_email})
53
54             subject = _("Scrum Meeting : %s") %(meeting.date)
55             message = _("Hello  , \nI am sending you Scrum Meeting : %s for the Sprint  '%s' of Project '%s'") %(meeting.date, sprint.name, sprint.project_id.name)
56             result.update({
57                        'subject': subject,
58                        'body_text': message,
59                        'model': model,
60                        'res_id': resource_id
61                     })
62         return result
63
64
65 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: