I'm trying to generate a .odt file from a xsl report.
Yes, I have changed the report_type field of the ir.act.report.xml record to odt.
It still generates a pdf.
.xml:
<report id="invoice_attachment_report" string="Time Record" model="invoice.invoice"
name="invoice.attachment.report"
xsl="invoice_gesteb/report/invoice_attachment_report.xsl"
auto="False" menu="False" attachment="(object.name or '').replace('/','')"
attachment_use="True" report_type="odt">
</report>
.py:
class report_custom(report_rml):
def create_xml(self, cr, uid, ids, data, context):
xml='''
<report>
%s
</report>
''' % ('Hello.');
return xml;
report_custom('report.invoice.attachment.report', 'invoice.invoice', '', 'addons/invoice/report/invoice_attachment_report.xsl')
.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:import href="custom_default.xsl"></xsl:import>
<xsl:import href="custom_rml.xsl"></xsl:import>
<xsl:template match="/">
<xsl:call-template name="rml"></xsl:call-template>
</xsl:template>
<xsl:template name="stylesheet">
</xsl:template>
<xsl:template name="story">
</xsl:template>
</xsl:stylesheet>
Report trigger (Button):
def button_invoice(self, cr, uid, ids, context=None):
invoice = self.browse(cr, uid, ids, context=context)[0];
attachment_obj = self.pool.get('ir.attachment');
ctx = context.copy()
ctx['lang'] = invoice.project_id.customer_id.lang;
service = netsvc.LocalService('report.invoice.attachment.report')
(result, format) = service.create(cr, uid, [ids], {'model': 'invoice.invoice'}, ctx)
result = base64.b64encode(result)
report_name = _('Time Attachment') + '_' + invoice.number + "." + format;
data = {
'name': report_name,
'datas_fname': report_name,
'datas': result,
'res_model': 'invoice.invoice',
'res_id': ids and ids[0] or False,
}
context.pop('default_type', None)
time_attachment_id = attachment_obj.create(cr, uid, data, context=context);
Help is appreciated.