1
##############################################################################
3
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
32
campaign_form = '''<?xml version="1.0"?>
33
<form string="Add partners to campaign">
34
<separator string="Default Values" colspan="4"/>
35
<field name="campaign_step_id"/>
36
<field name="priority"/>
37
<field name="user_id"/>
39
<separator string="Partners" colspan="4"/>
40
<field name="partners" nolabel="1" colspan="4"/>
44
'campaign_step_id': {'string':'First Campaign Step', 'type':'many2one', 'relation':'campaign.step', 'required':True},
45
'priority': {'selection':[('0','Very Low'),('1','Low'),('2','Medium'),('3','Good'),('4','Very Good')], 'string':'Priority', 'type':'selection', 'required':True},
46
'user_id': {'string':'User', 'type':'many2one', 'relation':'res.users'},
47
'partners': {'string':'Partners', 'type':'many2many', 'required':True, 'relation':'res.partner'}
50
def _partner_add(self, cr, uid, data, context):
51
partners = pooler.get_pool(cr.dbname).get('res.partner').browse(cr, uid, data['form']['partners'][0][2])
52
campaign_partner_obj = pooler.get_pool(cr.dbname).get('campaign.partner')
53
for partner in partners:
55
campaign_partner_obj.create(cr, uid, {
57
'user_id': data['form']['user_id'],
58
'step': data['form']['campaign_step_id'],
59
'priority': data['form']['priority'],
60
'partner_id': partner.id,
61
'part_adr_id': partner.address and partner.address[0].id or False,
62
'contact': partner.address and partner.address[0].phone or False,
63
'campaign_id': data['id']
67
class part_add(wizard.interface):
71
'result': {'type':'form', 'arch':campaign_form, 'fields':campaign_fields, 'state':[('end','Cancel'), ('add','Add these partners')]}
74
'actions': [_partner_add],
75
'result': {'type':'state', 'state':'end'}
78
part_add('campaign.partner.add')