Odoo Help


[SOLVED] Steps to print a report (RML)?

Juan Formoso
on 11/3/14, 10:28 AM 1,936 views

I am trying to understand how to create a report. In fact, I created a new module with a new model, and I am trying to print just an empty report of this new model. After I manage it, I will fill the report in step by step.

But there is something that I am doing wrong, and I would like that you corrected me. By the moment, these are the steps I think I have to do (check the names I am using, because I think the error is there).

I have to generate a folder called report. Inside it, I have to create a __init__.py file (which includes the python file of the report folder).

  • Inside the folder report, I have to create a .py file, for example, print_my_model.py. The code of this file should be the following:

from report import report_sxw
import time

class print_my_model_parser(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(print_my_model_parser, self).__init__(cr, uid, name, context=context)
            'time': time,
report_sxw.report_sxw('report.my_module.my_report_name', 'my.model',

  • Still inside the report folder, I have to create the RML file with the name specified above, inside the .py (in this case, the name of the RML file must be name_of_the_rml_file.rml). I decided to create a test RML file, with no data, so the code inside is:

<?xml version="1.0"?>
<document filename="preview_report.pdf">
  <template title="Preview Report" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20">
    <pageTemplate id="first">
      <frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>

  • Finally, in the main folder of my module, I have to create a XML file to declarate the reports I want to create (this way, the button Print will be generated automatically in the interface). This XML file must be included in the __openerp__.py file, and its content should be:

<?xml version="1.0" encoding="utf-8"?>
        <report auto="True" id="whatever_id"
        model="my.model" name="my_module.my_report_name
        string="Whatever message to show in the Print button of the interface" />


This is not working. I would like you to correct me, specially just above, where I declare the available reports, because I think I am doing some mistakes. In the id I can write anything I did not use earlier. In name, I think I have to write the name of my module followed by a dot and whatever name I want, but in the .py, when I pass parameters to report_sxw.report_sxw(), the first one must be exactly this name, with report. just before. Is this right? Do you see anything I am doing wrong?

I always get this error when I click the button Print and then mines (Whatever message to show in the Print button of the interface):

except_osv: (u"'str' object is not callable", (<type 'exceptions.TypeError'>, TypeError("'str' object is not callable",), <traceback object at 0x7f8c3cb2c1b8>))

hi, in your file "print_my_model.py", replace super(rplc_print_history, self) by super(print_my_model_parser, self) I think

Guillaume Seran
on 11/3/14, 10:43 AM

@Guillaume Seran I am so sorry, you are right but it was a mistake I made, copying and pasting code, and then trying to write easier names to make you understand my question better. I corrected it, but that was not the mistake I was refering to.

Juan Formoso
on 11/3/14, 10:49 AM

you write parser="print_my_model_parser" in my file i don't use quote.

Guillaume Seran
on 11/3/14, 11:04 AM

@Guillaume Seran that was the problem!! Thank you so much!!! I do not have enough karma to convert your comment as an answer, so if you write your comment in a new answer, I will check it as the solution. Thank you again!!

Juan Formoso
on 11/3/14, 11:14 AM
Guillaume Seran
On 11/3/14, 12:25 PM

In your py file  you write parser="print_my_model_parser"
Remove the quotes

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/3/14, 10:28 AM
Seen: 1936 times
Last updated: 3/16/15, 8:10 AM