Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How to get .odt file using XSL:RML report?

René Schuster
on 2/25/14, 8:05 AM 2,047 views

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.


<report id="invoice_attachment_report" string="Time Record" model="invoice.invoice" 
   auto="False" menu="False" attachment="(object.name or '').replace('/','')" 
   attachment_use="True" report_type="odt">


class report_custom(report_rml):
  def create_xml(self, cr, uid, ids, data, context):
        ''' % ('Hello.');
    return xml;
report_custom('report.invoice.attachment.report', 'invoice.invoice', '', 'addons/invoice/report/invoice_attachment_report.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 name="stylesheet">
<xsl:template name="story">


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.


René Schuster

--René Schuster--
| 5 5 8
Weinheim, Germany
--René Schuster--

Challenge Everything!

René Schuster
On 2/27/14, 6:42 AM

Apparently, when one uses a LocalService to create the report, the report_type must be passed in the datas-dictionary:

service.create(cr, uid, [ids], {'model': 'invoice.invoice', 'report_type': 'odt'}

But this is still not entirely working for me...

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)


Asked: 2/25/14, 8:05 AM
Seen: 2047 times
Last updated: 3/16/15, 8:10 AM