[IMP] Added the missing cancel in install wozard
[odoo/odoo.git] / openerp / addons / base / module / report / ir_module_reference_print.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #    
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
19 #
20 ##############################################################################
21
22 import time
23 from report import report_sxw
24
25 class ir_module_reference_print(report_sxw.rml_parse):
26     def __init__(self, cr, uid, name, context):
27         super(ir_module_reference_print, self).__init__(cr, uid, name, context=context)
28         self.localcontext.update({
29             'time': time,
30             'findobj': self._object_find,
31             'objdoc': self._object_doc,
32             'objdoc2': self._object_doc2,
33             'findflds': self._fields_find,
34         })
35     def _object_doc(self, obj):
36         modobj = self.pool.get(obj)
37         strdocs= modobj.__doc__
38         if not strdocs:
39             return None
40         else:
41             strdocs=strdocs.strip().splitlines(True)
42         res = ''
43         for stre in strdocs:
44             if not stre or stre.isspace():
45                 break
46             res += stre
47         return res
48
49     def _object_doc2(self, obj):
50         modobj = self.pool.get(obj)
51         strdocs= modobj.__doc__
52         if not strdocs:
53             return None
54         else:
55             strdocs=strdocs.strip().splitlines(True)
56         res = []
57         fou = False
58         for stre in strdocs:
59             if fou:
60                 res.append(stre.strip())
61             elif not stre or stre.isspace():
62                 fou = True
63         return res
64
65     def _object_find(self, module):
66         ids2 = self.pool.get('ir.model.data').search(self.cr, self.uid, [('module','=',module), ('model','=','ir.model')])
67         ids = []
68         for mod in self.pool.get('ir.model.data').browse(self.cr, self.uid, ids2):
69             ids.append(mod.res_id)
70         modobj = self.pool.get('ir.model')
71         return modobj.browse(self.cr, self.uid, ids)
72
73     def _fields_find(self, obj):
74         modobj = self.pool.get(obj)
75         res = modobj.fields_get(self.cr, self.uid).items()
76         res.sort()
77         return res
78
79 report_sxw.report_sxw('report.ir.module.reference', 'ir.module.module',
80         'addons/base/module/report/ir_module_reference.rml',
81         parser=ir_module_reference_print, header=False)
82
83
84 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
85