added from extra-addons
[odoo/odoo.git] / addons / event / wizard / event_registrations_partner.py
1 # -*- encoding: utf-8 -*-
2 ##############################################################################
3 #
4 # Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
5 #
6 # $Id: make_invoice.py 1070 2005-07-29 12:41:24Z nicoe $
7 #
8 # WARNING: This program as such is intended to be used by professional
9 # programmers who take the whole responsability of assessing all potential
10 # consequences resulting from its eventual inadequacies and bugs
11 # End users who are looking for a ready-to-use solution with commercial
12 # garantees and support are strongly adviced to contract a Free Software
13 # Service Company
14 #
15 # This program is Free Software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License
17 # as published by the Free Software Foundation; either version 2
18 # of the License, or (at your option) any later version.
19 #
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
28 #
29 ##############################################################################
30
31 import wizard
32 import pooler
33
34 from osv import fields, osv
35
36 def _list_partners(self, cr, uid, data, context):
37         list_partner = []
38         pool_obj=pooler.get_pool(cr.dbname)
39         obj_reg=pool_obj.get('event.registration')
40         reg_ids = obj_reg.search(cr, uid, [('event_id','in',data['ids'])])
41         data_reg = obj_reg.browse(cr, uid, reg_ids)
42         for reg in data_reg:
43             if not reg.partner_id.id in list_partner:
44                 list_partner.append(reg.partner_id.id)
45         data['partner_ids'] = list_partner
46         return {}
47
48 class event_partners(wizard.interface):
49     def _reg_partners(self, cr, uid, data, context):
50         pool_obj = pooler.get_pool(cr.dbname)
51         model_data_ids = pool_obj.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_partner_form')])
52         resource_id = pool_obj.get('ir.model.data').read(cr,uid,model_data_ids,fields=['res_id'])[0]['res_id']
53         return {
54             'domain': "[('id','in', ["+','.join(map(str,data['partner_ids']))+"])]",
55             'name': 'Partners',
56             'view_type': 'form',
57             'view_mode': 'tree,form',
58             'res_model': 'res.partner',
59             'views': [(False,'tree'),(resource_id,'form')],
60             'type': 'ir.actions.act_window'
61         }
62         return {}
63
64     states = {
65         'init' : {
66                'actions' : [_list_partners],
67                'result': {'type': 'action' , 'action':_reg_partners, 'state':'end'}
68             },
69
70     }
71
72 event_partners("event.event_reg_partners")
73
74
75 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
76