~jgrandguillaume-c2c/openobject-addons/multi-company-cost-price

« back to all changes in this revision

Viewing changes to base_module_record/wizard/base_module_record_data.py

  • Committer: Joël Grand-Guillaume
  • Date: 2010-04-08 09:00:10 UTC
  • mfrom: (2533.3.664)
  • Revision ID: joel.grandguillaume@camptocamp.com-20100408090010-c0pqjan341s18bxs
[MRG] Merge from last trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    <field name="filter_cond"/>
38
38
    <separator string="Choose objects to record" colspan="4"/>
39
39
    <field name="objects" colspan="4" nolabel="1"/>
40
 
 
 
40
    <group><field name="info_yaml"/></group>
41
41
</form>'''
42
42
 
43
43
intro_start_fields = {
44
44
    'check_date':  {'string':"Record from Date",'type':'datetime','required':True, 'default': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S')},
45
45
    'objects':{'string': 'Objects', 'type': 'many2many', 'relation': 'ir.model', 'help': 'List of objects to be recorded'},
46
46
    'filter_cond':{'string':'Records only', 'type':'selection','selection':[('created','Created'),('modified','Modified'),('created_modified','Created & Modified')], 'required':True, 'default': lambda *args:'created'},
47
 
 
 
47
    'info_yaml': {'string':'YAML','type':'boolean'}
48
48
}
49
49
 
50
50
exp_form = '''<?xml version="1.0"?>
98
98
                      continue
99
99
        search_ids=obj_pool.search(cr,uid,search_condition)
100
100
        for s_id in search_ids:
101
 
             args=(cr.dbname,uid,user,obj_name,'copy',s_id,{},context)
 
101
             args=(cr.dbname,uid,obj_name,'copy',s_id,{},context)
102
102
             mod.recording_data.append(('query',args, {}, s_id))
103
103
    return {}
104
104
 
 
105
def _check(self, cr, uid, data, context):
 
106
     pool = pooler.get_pool(cr.dbname)
 
107
     mod = pool.get('ir.module.record')
 
108
     if len(mod.recording_data):
 
109
         if data['form']['info_yaml']:
 
110
             return 'save_yaml'
 
111
         else:
 
112
             return 'info'
 
113
     else:
 
114
         return 'end'
 
115
         
105
116
def _create_xml(self, cr, uid, data, context):
106
117
    pool = pooler.get_pool(cr.dbname)
107
118
    mod = pool.get('ir.module.record')
108
119
    res_xml = mod.generate_xml(cr, uid)
109
120
    return { 'res_text': res_xml }
110
121
 
 
122
def _create_yaml(self,cr,uid,data,context):
 
123
    pool = pooler.get_pool(cr.dbname)
 
124
    mod = pool.get('ir.module.record')
 
125
    res_xml = mod.generate_yaml(cr, uid)
 
126
    return { 'res_text': res_xml }
 
127
 
111
128
class base_module_record_objects(wizard.interface):
112
129
    states = {
113
130
         'init': {
122
139
                ]
123
140
            }
124
141
        },
125
 
         'record': {
 
142
        'record': {
126
143
            'actions': [],
127
 
            'result': {'type':'action','action':_record_objects,'state':'intro'}
 
144
            'result': {'type':'action','action':_record_objects,'state':'check'}
128
145
                },
129
 
         'intro': {
 
146
        'check': {
 
147
            'actions': [],
 
148
            'result': {'type':'choice','next_state':_check}
 
149
        },
 
150
         'info': {
130
151
            'actions': [ _create_xml ],
131
152
            'result': {
132
153
                'type':'form',
136
157
                    ('end', 'End', 'gtk-cancel'),
137
158
                ]
138
159
            },
 
160
        },
 
161
        'save_yaml': {
 
162
            'actions': [ _create_yaml ],
 
163
            'result': {
 
164
                'type':'form',
 
165
                'arch': exp_form,
 
166
                'fields':exp_fields,
 
167
                'state':[
 
168
                    ('end', 'End', 'gtk-cancel'),
 
169
                ]
139
170
            },
 
171
        },
140
172
         'end': {
141
173
            'actions': [],
142
174
            'result': {'type':'form', 'arch':info, 'fields':{}, 'state':[('end','OK')]}