1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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.
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.
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/>.
20 ##############################################################################
23 from tools.translate import _
27 #===============================================================================
28 # Put original wizard because of action in init
29 # Remove it after solution foraction in init
30 #===============================================================================
32 class phonecall2meeting(wizard.interface):
34 def _makeMeeting(self, cr, uid, data, context=None):
35 pool = pooler.get_pool(cr.dbname)
36 phonecall_case_obj = pool.get('crm.phonecall')
37 data_obj = pool.get('ir.model.data')
38 result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter')
39 id = data_obj.read(cr, uid, result, ['res_id'])
40 id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet')
41 id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet')
42 id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet')
44 id1 = data_obj.browse(cr, uid, id1, context=context).res_id
46 id2 = data_obj.browse(cr, uid, id2, context=context).res_id
48 id3 = data_obj.browse(cr, uid, id3, context=context).res_id
49 phonecall = phonecall_case_obj.browse(cr, uid, data['id'], context=context)
50 partner_id = phonecall.partner_id and phonecall.partner_id.id or False
52 email = phonecall.email_from
53 section_id = phonecall.section_id and phonecall.section_id.id or False
55 'name': _('Meetings'),
56 'domain' : "[('user_id','=',%s)]"%(uid),
57 'context': {'default_partner_id': partner_id, 'default_section_id': section_id, 'default_email_from': email, 'default_state':'open', 'default_name':name},
59 'view_mode': 'calendar,form,tree',
60 'res_model': 'crm.meeting',
62 'views': [(id1,'calendar'),(id2,'form'),(id3,'tree')],
63 'type': 'ir.actions.act_window',
64 'search_view_id': id['res_id']
70 'result': {'type': 'action', 'action': _makeMeeting, 'state': 'order'}
74 'result': {'type': 'state', 'state': 'end'}
77 phonecall2meeting('crm.phonecall.meeting_set')
79 class crm_phonecall2meeting(osv.osv_memory):
80 """ Phonecall to Meeting """
82 _name = 'crm.phonecall2meeting'
83 _description = 'Phonecall To Meeting'
85 def action_cancel(self, cr, uid, ids, context=None):
87 Closes Phonecall to Meeting form
88 @param self: The object pointer
89 @param cr: the current row, from the database cursor,
90 @param uid: the current user’s ID for security checks,
91 @param ids: List of Phonecall to Meeting IDs
92 @param context: A standard dictionary for contextual values
95 return {'type':'ir.actions.act_window_close'}
97 def action_make_meeting(self, cr, uid, ids, context=None):
99 This opens Meeting's calendar view to schedule meeting on current Phonecall
100 @param self: The object pointer
101 @param cr: the current row, from the database cursor,
102 @param uid: the current user’s ID for security checks,
103 @param ids: List of Phonecall to Meeting IDs
104 @param context: A standard dictionary for contextual values
106 @return : Dictionary value for created Meeting view
109 record_id = context and context.get('active_id', False) or False
112 phonecall_obj = self.pool.get('crm.phonecall')
113 data_obj = self.pool.get('ir.model.data')
116 result = data_obj._get_id(cr, uid, 'crm', 'view_crm_case_meetings_filter')
117 res = data_obj.read(cr, uid, result, ['res_id'])
118 id1 = data_obj._get_id(cr, uid, 'crm', 'crm_case_calendar_view_meet')
119 id2 = data_obj._get_id(cr, uid, 'crm', 'crm_case_form_view_meet')
120 id3 = data_obj._get_id(cr, uid, 'crm', 'crm_case_tree_view_meet')
122 id1 = data_obj.browse(cr, uid, id1, context=context).res_id
124 id2 = data_obj.browse(cr, uid, id2, context=context).res_id
126 id3 = data_obj.browse(cr, uid, id3, context=context).res_id
128 phonecall = phonecall_obj.browse(cr, uid, record_id, context=context)
130 'default_phonecall_id': phonecall.id,
131 'default_partner_id': phonecall.partner_id and phonecall.partner_id.id or False,
132 'default_email': phonecall.email_from ,
133 'default_name': phonecall.name
137 'name': _('Meetings'),
138 'domain' : "[('user_id','=',%s)]" % (uid),
141 'view_mode': 'calendar,form,tree',
142 'res_model': 'crm.meeting',
144 'views': [(id1, 'calendar'), (id2, 'form'), (id3, 'tree')],
145 'type': 'ir.actions.act_window',
146 'search_view_id': res['res_id']
151 crm_phonecall2meeting()
153 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: