~aminpy/+junk/data_management

« back to all changes in this revision

Viewing changes to data_exporter.py

  • Committer: Amin Oruji
  • Date: 2012-05-03 20:19:32 UTC
  • Revision ID: aminpy@gmail.com-20120503201932-zecnff8uixadz5pz
some pep8 corrections

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
        # Check for based on module
23
23
        if export_type_input == 'b':
24
 
            json_exported_file_name = "%s_data.json" % ir_module_module_input.name
 
24
            json_exported_file_name = "%s_data.json" % \
 
25
                ir_module_module_input.name
25
26
            ir_model_obj = self.pool.get('ir.model')
26
 
            ir_model_id_list = ir_model_obj.search(cr, uid, [], context=context)
 
27
            ir_model_id_list = ir_model_obj.search(cr, uid, [],
 
28
                                                   context=context)
27
29
            ir_model_list2 = ir_model_obj.browse(cr, uid, ir_model_id_list,
28
30
                                                context=context)
29
31
 
30
 
            cr.execute("select table_name from information_schema.tables where table_type != 'VIEW'")
 
32
            cr.execute("""select table_name from information_schema.tables \
 
33
where table_type != 'VIEW'""")
31
34
            table_list = []
32
35
            table_list2 = cr.fetchall()
33
36
 
36
39
 
37
40
            # Separate choosed module models with loop because of function field
38
41
            for ir_model in ir_model_list2:
39
 
                if ir_model.modules == ir_module_module_input.name and ir_model.model.replace('.', '_') in table_list:
 
42
                if ir_model.modules == ir_module_module_input.name and \
 
43
                    ir_model.model.replace('.', '_') in table_list:
40
44
                    ir_model_list.append(ir_model)
41
45
 
42
46
 
43
47
        # Check for based on model
44
48
        elif export_type_input == 'a':
45
 
            json_exported_file_name = "%s_data.json" % ir_model_id_input.model.replace('.', '_')
 
49
            json_exported_file_name = "%s_data.json" % \
 
50
                ir_model_id_input.model.replace('.', '_')
46
51
            ir_model_list.append(ir_model_id_input)
47
52
 
48
53
        for ir_model in ir_model_list:
67
72
 
68
73
            # Select * from ...
69
74
            try:
70
 
                input_model_list = input_model_obj.read(cr, uid, input_model_id_list,
 
75
                input_model_list = input_model_obj.read(cr, uid,
 
76
                                                        input_model_id_list,
71
77
                                                        [], context=context)
72
78
            except AttributeError, e:
73
79
                print e.message