[REF]: base_report_designer: Code improvement + typos

bzr revid: rpa@tinyerp.com-20100714053641-5ezd3ziwzquauq65
This commit is contained in:
rpa (Open ERP) 2010-07-14 11:06:41 +05:30
parent 7f5a7ed089
commit c3bf1349b2
4 changed files with 33 additions and 37 deletions

View File

@ -25,11 +25,11 @@
'version': '0.1',
'category': 'Generic Modules/Base',
'description': """
This module is used along with openerp OpenOffice plugin.
This module is used along with OpenERP OpenOffice plugin.
You have to first install the plugin which is available at
http://www.openerp.com
This module adds wizards to import/export .SXW report that
This module adds wizards to Import/Export .sxw report that
you can modify in OpenOffice.Once you have modified it you can
upload the report using the same wizard.
""",

View File

@ -7,6 +7,7 @@
<field eval="[(6,0,[ref('base.user_root')])]" name="users"/>
<field eval="&quot;&quot;&quot;OpenOfficeReportDesigner&quot;&quot;&quot;" name="name"/>
</record>
<record id="ir_model_access_openofficereportdesigner0" model="ir.model.access">
<field name="model_id" ref="base.model_ir_actions_report_xml"/>
<field eval="1" name="perm_read"/>

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@ -15,11 +15,11 @@
# 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/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields,osv
from osv import osv
from wizard.tiny_sxw2rml import sxw2rml
from StringIO import StringIO
from report import interface
@ -27,49 +27,53 @@ import base64
import pooler
import tools
class report_xml(osv.osv):
_inherit = 'ir.actions.report.xml'
def sxwtorml(self,cr, uid, file_sxw,file_type):
def sxwtorml(self, cr, uid, file_sxw, file_type):
'''
The use of this function is to get rml file from sxw file.
'''
sxwval = StringIO(base64.decodestring(file_sxw))
if file_type=='sxw':
fp = tools.file_open('normalized_oo2rml.xsl',
fp = tools.file_open('normalized_oo2rml.xsl',
subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
if file_type=='odt':
fp = tools.file_open('normalized_odt2rml.xsl',
fp = tools.file_open('normalized_odt2rml.xsl',
subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
return {'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read()))}
def upload_report(self, cr, uid, report_id, file_sxw,file_type, context):
def upload_report(self, cr, uid, report_id, file_sxw, file_type, context):
'''
Untested function
'''
pool = pooler.get_pool(cr.dbname)
sxwval = StringIO(base64.decodestring(file_sxw))
if file_type=='sxw':
fp = tools.file_open('normalized_oo2rml.xsl',
fp = tools.file_open('normalized_oo2rml.xsl',
subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
if file_type=='odt':
fp = tools.file_open('normalized_odt2rml.xsl',
fp = tools.file_open('normalized_odt2rml.xsl',
subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
report = pool.get('ir.actions.report.xml').write(cr, uid, [report_id], {
'report_sxw_content': base64.decodestring(file_sxw),
'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read())),
'report_sxw_content': base64.decodestring(file_sxw),
'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read())),
})
db = pooler.get_db_only(cr.dbname)
interface.register_all(db)
return True
def report_get(self, cr, uid, report_id, context={}):
report = self.browse(cr, uid, report_id, context)
return {
'file_type' : report.report_type,
'report_sxw_content': report.report_sxw_content and base64.encodestring(report.report_sxw_content) or False,
'file_type' : report.report_type,
'report_sxw_content': report.report_sxw_content and base64.encodestring(report.report_sxw_content) or False,
'report_rml_content': report.report_rml_content and base64.encodestring(report.report_rml_content) or False
}
report_xml()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,31 +1,22 @@
<?xml version="1.0"?>
<openerp>
<data>
<data>
<wizard
string="Modify an existing report"
model="ir.actions.report.xml"
name="base_report_designer.modify"
id="wizard_report_designer_modify"/>
<wizard string="Modify an existing report"
model="ir.actions.report.xml" name="base_report_designer.modify"
id="wizard_report_designer_modify" />
<menuitem icon="terp-graph" id="base.reporting_menu" name="Reporting" sequence="30"/>
<menuitem
id="base.next_id_50"
name="Configuration"
parent="base.reporting_menu"
groups="base.group_system"
sequence="3"/>
<menuitem
parent="base.next_id_50"
name="Report Designer"
action="wizard_report_designer_modify"
type="wizard"
id="menu_wizard_report_designer_modify"
sequence="70"/>
<menuitem icon="terp-graph" id="base.reporting_menu"
name="Reporting" sequence="30" />
<menuitem id="base.next_id_50" name="Configuration"
parent="base.reporting_menu" groups="base.group_system" sequence="3" />
<menuitem parent="base.next_id_50" name="Report Designer"
action="wizard_report_designer_modify" type="wizard"
id="menu_wizard_report_designer_modify" sequence="70" />
</data>
</data>
</openerp>