~openerp-commiter/openobject-addons/trunk-extra-addons

« back to all changes in this revision

Viewing changes to dm/wizard/campaign_group_project.py

bugfix in overlay creation system

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
# Copyright (c) 2005-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
 
5
#
 
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
 
11
# Service Company
 
12
#
 
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.
 
17
#
 
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.
 
22
#
 
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.
 
26
#
 
27
##############################################################################
 
28
 
 
29
#
 
30
# Order Point Method:
 
31
#    - Order if the virtual stock of today is bellow the min of the defined order point
 
32
#
 
33
 
 
34
import wizard
 
35
import pooler
 
36
 
 
37
parameter_form = '''<?xml version="1.0"?>
 
38
<form string="Campaign Group" colspan="4">
 
39
    <field name="project_id"
 
40
/>
 
41
</form>'''
 
42
 
 
43
parameter_fields = {
 
44
    'project_id': {'string':'Project', 'type':'many2one', 'required':True, 'relation':'project.project', 'domain': [('active','<>',False)]},
 
45
}
 
46
 
 
47
def _create_duplicate(self, cr, uid, data, context):
 
48
    print context,"---------------------------------------------------------------------"
 
49
    campaign_group_obj=pooler.get_pool(cr.dbname).get('dm.campaign.group')
 
50
    project_obj = pooler.get_pool(cr.dbname).get('project.project')
 
51
    duplicate_project_id= project_obj.copy(cr, uid,data['form']['project_id'], {'active': True})
 
52
    campaign = campaign_group_obj.browse(cr, uid, data['id'])
 
53
    project_obj.write(cr, uid, duplicate_project_id, {'name': project_obj.browse(cr, uid, duplicate_project_id, context).name + " for " + campaign.name})
 
54
    campaign_group_obj.write(cr, uid, [data['id']], {'project_id': duplicate_project_id})
 
55
    return {}
 
56
 
 
57
class wizard_campaign_group_project(wizard.interface):
 
58
    states = {
 
59
        'init': {
 
60
            'actions': [],
 
61
            'result': {'type': 'form', 'arch':parameter_form, 'fields': parameter_fields, 'state':[('end','Cancel'),('done', 'Ok')]}
 
62
 
 
63
        },
 
64
        'done':{
 
65
                'actions':[_create_duplicate],
 
66
                'result' : {'type':'state', 'state':'end'}
 
67
                }
 
68
    }
 
69
wizard_campaign_group_project('campaign.group.project')
 
70
 
 
71
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: