diff --git a/openerp/addons/base/__init__.py b/openerp/addons/base/__init__.py
index fe483c40602..847bef71f8c 100644
--- a/openerp/addons/base/__init__.py
+++ b/openerp/addons/base/__init__.py
@@ -23,6 +23,7 @@ import ir
import module
import res
import publisher_warranty
+import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/openerp/addons/base/base_update.xml b/openerp/addons/base/base_update.xml
index cefc895a977..1820c8df9f3 100644
--- a/openerp/addons/base/base_update.xml
+++ b/openerp/addons/base/base_update.xml
@@ -186,6 +186,10 @@
Company
======================
-->
+
+
+
res.company.formres.company
@@ -219,7 +223,7 @@
-
+
diff --git a/openerp/addons/base/report/__init__.py b/openerp/addons/base/report/__init__.py
new file mode 100644
index 00000000000..254008f0185
--- /dev/null
+++ b/openerp/addons/base/report/__init__.py
@@ -0,0 +1 @@
+import preview_report
diff --git a/openerp/addons/base/report/preview_report.py b/openerp/addons/base/report/preview_report.py
new file mode 100644
index 00000000000..17b489c48a6
--- /dev/null
+++ b/openerp/addons/base/report/preview_report.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import time
+from report import report_sxw
+
+
+class preview_report_company(report_sxw.rml_parse):
+ def __init__(self, cr, uid, name, context):
+ super(preview_report_company, self).__init__(cr, uid, name, context)
+ self.localcontext.update({
+ 'time': time,
+ })
+
+report_sxw.report_sxw('report.preview.report', 'res.company',
+ 'addons/base/report/preview_report.rml', parser=preview_report_company, header='external')
+
diff --git a/openerp/addons/base/report/preview_report.rml b/openerp/addons/base/report/preview_report.rml
new file mode 100644
index 00000000000..b2236438291
--- /dev/null
+++ b/openerp/addons/base/report/preview_report.rml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py
index a16161c0e4a..d506b401079 100644
--- a/openerp/addons/base/res/res_company.py
+++ b/openerp/addons/base/res/res_company.py
@@ -306,47 +306,6 @@ class res_company(osv.osv):
(osv.osv._check_recursion, 'Error! You can not create recursive companies.', ['parent_id'])
]
- def preview_report(self, cr, uid, ids, context=None):
- #TODO: we should be able to create a report dynamically without using the filesystem (without using the trick with tempfilename)
- if not ids:
- return False
- # we need to pass the company_id in order to make a new browse record for the rml parser, because the cursor was previously closed and because of this partner data was not printed
- company_id = ids[0]
- company = self.browse(cr, uid, company_id, context=context)
-
- class company_parser(report_sxw.rml_parse):
- def __init__(self, cr, uid, name, context):
- super(company_parser, self).__init__(cr, uid, name, context=context)
- import openerp
- company = openerp.pooler.get_pool(cr.dbname).get('res.company').browse(cr, uid, company_id, context=context)
- self.setCompany(company)
-
- rml = etree.XML(company.rml_header)
- rml = rml.getchildren()[0]
- header_xml = """
- """
- footer_xml = """
-
-
- """
- tempfileid, tempfilename= tempfile.mkstemp('.rml', 'openerp_')
- fp = open(tempfilename, 'wb+')
- fp.write(header_xml)
- fp.write(etree.tostring(rml))
- fp.write(footer_xml)
- fp.close()
-
- #we need to remove the eventual instances of this report, as we can't have 2 services with the same name
- netsvc.Service._services.pop('report.company.report', False)
- #the report service is created on the fly because there is no rml given
- report_sxw.report_sxw('report.company.report', 'res.company', tempfilename, parser=company_parser)
- return {
- 'type': 'ir.actions.report.xml',
- 'report_name': 'company.report',
- 'datas': {'ids': ids, 'model': 'res.company'},
- 'nodestroy': True,
- 'context': context #pass the context in order to use it in the browse of the company_parser
- }
res_company()