[FIX] purchase: Change the default padding of the sequence for the Order Reference
[odoo/odoo.git] / addons / crm / crm_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 fields, osv
23 import crm
24 from datetime import datetime, timedelta
25 from datetime import datetime, timedelta
26
27 class crm_opportunity(osv.osv):
28     _name = 'crm.opportunity'
29 crm_opportunity()    
30 class crm_phonecall(osv.osv):
31     _name = 'crm.phonecall'
32 crm_phonecall()    
33 class crm_meeting(osv.osv):
34     _name = 'crm.meeting'
35     _description = "Meeting Cases"
36     _order = "id desc"
37     _inherit = ["crm.case", "calendar.event"]   
38
39     _columns = { 
40         'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'), 
41         'categ_id': fields.many2one('crm.case.categ', 'Meeting Type', \
42                             domain="[('object_id.model', '=', 'crm.meeting')]", \
43             ),            
44         'phonecall_id':fields.many2one ('crm.phonecall', 'Phonecall'),        
45         'opportunity_id':fields.many2one ('crm.opportunity', 'Opportunity'),       
46         'attendee_ids': fields.many2many('calendar.attendee', 'event_attendee_rel', 'event_id', 'attendee_id', 'Attendees'),
47     }
48
49 crm_meeting()
50
51 class calendar_attendee(osv.osv):
52     _inherit = 'calendar.attendee'
53
54     def _compute_data(self, cr, uid, ids, name, arg, context):        
55         name = name[0]
56         result = super(calendar_attendee, self)._compute_data(cr, uid, ids, name, arg, context)
57
58         for attdata in self.browse(cr, uid, ids, context=context):
59             id = attdata.id
60             result[id] = {}
61             if name == 'categ_id':
62                 if attdata.ref:
63                     model, res_id = tuple(attdata.ref.split(','))
64                     model_obj = self.pool.get(model)
65                     obj = model_obj.read(cr, uid, res_id, ['categ_id'])[0]
66                     result[id][name] = obj.get('categ_id')
67                 else:
68                     result[id][name] = False
69         return result
70     _columns = {
71         'categ_id': fields.function(_compute_data, method=True, string='Event Type', type="many2one", relation="crm.case.categ", multi='categ_id'), 
72     }
73 calendar_attendee()
74
75 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: