[FIX] crm: do not overwrite the value of no_force_assignation if already set in the...
[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 openerp.osv import osv
23 from openerp.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         """ This opens Meeting's calendar view to schedule meeting on current Phonecall
45             @return : Dictionary value for created Meeting view
46         """
47         res = {}
48         phonecall_id = context and context.get('active_id', False) or False
49         if phonecall_id:
50             phonecall = self.pool.get('crm.phonecall').browse(cr, uid, phonecall_id, context)
51             res = self.pool.get('ir.actions.act_window').for_xml_id(cr, uid, 'calendar', 'action_calendar_event', context)
52             res['context'] = {
53                 'default_phonecall_id': phonecall.id,
54                 'default_partner_id': phonecall.partner_id and phonecall.partner_id.id or False,
55                 'default_user_id': uid,
56                 'default_email_from': phonecall.email_from,
57                 'default_state': 'open',
58                 'default_name': phonecall.name,
59             }
60         return res
61
62
63 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: