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

« back to all changes in this revision

Viewing changes to dm/wizard/proposition_copy.py

merging new development from indian accounting

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
import wizard
 
3
import pooler
 
4
from osv import fields
 
5
from osv import osv
 
6
 
 
7
segment_form = """<?xml version="1.0" ?>
 
8
<form string="Duplication Of Proposition">
 
9
    <field name="keep_segments"/>
 
10
</form>"""
 
11
 
 
12
segment_fields = {
 
13
    'keep_segments':{'string':'Keep Segments At Duplication', 'type':'boolean','default': lambda *a:True},
 
14
}
 
15
 
 
16
def _copy_prp(self, cr, uid, data, context):
 
17
    prop_id = data['id']
 
18
    pool = pooler.get_pool(cr.dbname)
 
19
    prp_id = pool.get('dm.campaign.proposition').copy(cr, uid, prop_id, context=context)
 
20
    datas = pool.get('dm.campaign.proposition').browse(cr, uid, prp_id, context)
 
21
    seg = data['form']['keep_segments']
 
22
    if datas.segment_ids:
 
23
        if not seg:
 
24
            l = []
 
25
            for i in datas.segment_ids:
 
26
                l.append(i.id)
 
27
                pool.get('dm.campaign.proposition.segment').unlink(cr,uid,l)
 
28
            return {'PRP_ID':prp_id}
 
29
    return {'PRP_ID':prp_id}
 
30
 
 
31
class wizard_prop_copy(wizard.interface):
 
32
    states = {
 
33
        'init':{
 
34
            'actions': [],
 
35
            'result': {'type':'form', 'arch':segment_form, 'fields':segment_fields, 'state': [('end', 'Cancel'), ('copy', 'Duplicate')]},
 
36
        },
 
37
        'copy': {
 
38
            'actions': [],
 
39
            'result': {'type': 'action', 'action':_copy_prp, 'state':'end'}
 
40
        }
 
41
    }
 
42
wizard_prop_copy("wizard_prop_copy")
 
43
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
 
b'\\ No newline at end of file'