[IMP] replaced all oe_form_topbar with the new <header> style
[odoo/odoo.git] / addons / crm / wizard / crm_phonecall_to_meeting.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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 osv import osv
23 from tools.translate import _
24
25 class crm_phonecall2meeting(osv.osv_memory):
26     """ Phonecall to Meeting """
27
28     _name = 'crm.phonecall2meeting'
29     _description = 'Phonecall To Meeting'
30
31     def action_cancel(self, cr, uid, ids, context=None):
32         """
33         Closes Phonecall to Meeting form
34         @param self: The object pointer
35         @param cr: the current row, from the database cursor,
36         @param uid: the current user’s ID for security checks,
37         @param ids: List of Phonecall to Meeting IDs
38         @param context: A standard dictionary for contextual values
39
40         """
41         return {'type':'ir.actions.act_window_close'}
42
43     def action_make_meeting(self, cr, uid, ids, context=None):
44         """
45         This opens Meeting's calendar view to schedule meeting on current Phonecall
46         @param self: The object pointer
47         @param cr: the current row, from the database cursor,
48         @param uid: the current user’s ID for security checks,
49         @param ids: List of Phonecall to Meeting IDs
50         @param context: A standard dictionary for contextual values
51
52         @return : Dictionary value for created Meeting view
53         """
54         value = {}
55         record_id = context and context.get('active_id', False) or False
56
57         if record_id:
58             phonecall_obj = self.pool.get('crm.phonecall')
59             data_obj = self.pool.get('ir.model.data')
60
61             # Get meeting views
62             result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter')
63             res = data_obj.read(cr, uid, result, ['res_id'])
64             id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet')
65             id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet')
66             id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet')
67             if id1:
68                 id1 = data_obj.browse(cr, uid, id1, context=context).res_id
69             if id2:
70                 id2 = data_obj.browse(cr, uid, id2, context=context).res_id
71             if id3:
72                 id3 = data_obj.browse(cr, uid, id3, context=context).res_id
73
74             phonecall = phonecall_obj.browse(cr, uid, record_id, context=context)
75             context = {
76                         'default_phonecall_id': phonecall.id,
77                         'default_partner_id': phonecall.partner_id and phonecall.partner_id.id or False,
78                         'default_email': phonecall.email_from ,
79                         'default_name': phonecall.name
80                     }
81
82             value = {
83                 'name': _('Meetings'),
84                 'domain' : "[('user_id','=',%s)]" % (uid),
85                 'context': context,
86                 'view_type': 'form',
87                 'view_mode': 'calendar,form,tree',
88                 'res_model': 'crm.meeting',
89                 'view_id': False,
90                 'views': [(id1, 'calendar'), (id2, 'form'), (id3, 'tree')],
91                 'type': 'ir.actions.act_window',
92                 'search_view_id': res['res_id']
93                 }
94
95         return value
96
97 crm_phonecall2meeting()
98
99 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: