Rucha (Open ERP) has proposed merging
lp:~openerp-dev/openobject-server/trunk-configuration-rework-preview-report-rpa
into lp:~openerp-dev/openobject-server/trunk-configuration-rework.
Requested reviews:
qdp (OpenERP) (qdp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-configuration-rework-preview-report-rpa/+merge/67037
Removed preview_report function from res.company and Added new blank report to
print company header/footer
--
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-configuration-rework-preview-report-rpa/+merge/67037
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/trunk-configuration-rework.
=== modified file 'openerp/addons/base/__init__.py'
--- openerp/addons/base/__init__.py 2010-11-22 12:00:39 +0000
+++ openerp/addons/base/__init__.py 2011-07-06 13:01:06 +0000
@@ -23,6 +23,7 @@
import module
import res
import publisher_warranty
+import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'openerp/addons/base/base_update.xml'
--- openerp/addons/base/base_update.xml 2011-07-04 14:32:25 +0000
+++ openerp/addons/base/base_update.xml 2011-07-06 13:01:06 +0000
@@ -186,6 +186,10 @@
Company
======================
-->
+
+ <report id="preview_report" model="res.company" name="preview.report" multi="True"
+ rml="base/report/preview_report.rml" string="Preview Report"/>
+
<record id="view_company_form" model="ir.ui.view">
<field name="name">res.company.form</field>
<field name="model">res.company</field>
@@ -219,7 +223,7 @@
<field name="rml_footer2" colspan="4"/>
<group colspan="4" col="8">
<label string="" colspan="7"/>
- <button name="preview_report" string="Preview Report" type="object" icon="gtk-print"/>
+ <button name="%(preview_report)d" string="Preview Report" type="action" icon="gtk-print"/>
</group>
</page>
<page string="Header/Footer" groups="base.group_extended">
=== added file 'openerp/addons/base/report/__init__.py'
--- openerp/addons/base/report/__init__.py 1970-01-01 00:00:00 +0000
+++ openerp/addons/base/report/__init__.py 2011-07-06 13:01:06 +0000
@@ -0,0 +1,1 @@
+import preview_report
=== added file 'openerp/addons/base/report/preview_report.py'
--- openerp/addons/base/report/preview_report.py 1970-01-01 00:00:00 +0000
+++ openerp/addons/base/report/preview_report.py 2011-07-06 13:01:06 +0000
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+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')
+
=== added file 'openerp/addons/base/report/preview_report.rml'
--- openerp/addons/base/report/preview_report.rml 1970-01-01 00:00:00 +0000
+++ openerp/addons/base/report/preview_report.rml 2011-07-06 13:01:06 +0000
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<document filename="test.pdf">
+ <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
+ <pageTemplate id="first">
+ <frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
+ </pageTemplate>
+ </template>
+ <stylesheet>
+ <blockTableStyle id="Standard_Outline">
+ <blockAlignment value="LEFT"/>
+ <blockValign value="TOP"/>
+ </blockTableStyle>
+ <initialize>
+ <paraStyle name="all" alignment="justify"/>
+ </initialize>
+ <paraStyle name="Standard" fontName="Helvetica"/>
+ <images/>
+ </stylesheet>
+ <story>
+ <para style="Standard">
+ <font color="white"> </font>
+ </para>
+ </story>
+</document>
=== modified file 'openerp/addons/base/res/res_company.py'
--- openerp/addons/base/res/res_company.py 2011-07-05 10:30:01 +0000
+++ openerp/addons/base/res/res_company.py 2011-07-06 13:01:06 +0000
@@ -306,47 +306,6 @@
(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 = """<document filename="Preview Report.pdf">
- <template pageSize="(595.0,842.0)" title="Preview Report" author="OpenERP S.A.([email protected])" allowSplitting="20">"""
- footer_xml = """
- </template>
- </document>
- """
- 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()
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp