[IMP] crm*: update crm modules to new mail module (wip)
[odoo/odoo.git] / addons / crm_helpdesk / wizard / email_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 import tools
25
26 class email_compose_message(osv.osv_memory):
27     _inherit = 'email.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(email_compose_message, self).get_value(cr, uid,  model, resource_id, context=context)
40         if model == 'crm.helpdesk' and resource_id:
41             model_obj = self.pool.get(model)
42             data = model_obj.browse(cr, uid , resource_id, context)
43             result.update({
44                     'subject' : data.name or False,
45                     'email_to' : data.email_from or False,
46                     'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
47                     'body_text' : '\n' + (tools.ustr(data.user_id.signature or '')),
48                     'email_cc' : tools.ustr(data.email_cc or ''),
49                     'model': model,
50                     'res_id': resource_id,
51                 })
52         return result
53
54 email_compose_message()
55
56 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: