1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # Copyright (c) 2010 Camptocamp SA (http://www.camptocamp.com)
7 # Author : Nicolas Bessi (Camptocamp)
9 # WARNING: This program as such is intended to be used by professional
10 # programmers who take the whole responsability of assessing all potential
11 # consequences resulting from its eventual inadequacies and bugs
12 # End users who are looking for a ready-to-use solution with commercial
13 # garantees and support are strongly adviced to contract a Free Software
16 # This program is Free Software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License
18 # as published by the Free Software Foundation; either version 2
19 # of the License, or (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 ##############################################################################
33 from openerp.osv import fields, orm
35 from webkit_report import WebKitParser
37 class ir_actions_report_xml(orm.Model):
38 _inherit = 'ir.actions.report.xml'
40 'webkit_header': fields.property(
41 type='many2one', relation='ir.header_webkit',
42 string='Webkit Header', help="The header linked to the report",
44 'webkit_debug': fields.boolean('Webkit debug',
45 help="Enable the webkit engine debugger"),
46 'report_webkit_data': fields.text('Webkit Template',
47 help="This template will be used if the main report file is not found"),
48 'precise_mode': fields.boolean('Precise Mode',
49 help="This mode allow more precise element position as each object"
50 " is printed on a separate HTML but memory and disk usage are wider.")
53 def _lookup_report(self, cr, name):
55 Look up a report definition.
61 # First lookup in the deprecated place, because if the report definition
62 # has not been updated, it is more likely the correct definition is there.
63 # Only reports with custom parser specified in Python are still there.
64 if 'report.' + name in openerp.report.interface.report_int._reports:
65 new_report = openerp.report.interface.report_int._reports['report.' + name]
66 if not isinstance(new_report, WebKitParser):
69 cr.execute("SELECT * FROM ir_act_report_xml WHERE report_name=%s and report_type=%s", (name, 'webkit'))
73 parser = operator.attrgetter(r['parser'])(openerp.addons)
74 kwargs = { 'parser': parser }
78 new_report = WebKitParser('report.'+r['report_name'],
79 r['model'], opj('addons',r['report_rml'] or '/'),
80 header=r['header'], register=False, **kwargs)
87 return super(ir_actions_report_xml, self)._lookup_report(cr, name)
89 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: