Odoo Help


print button code doubt

sneha antony
on 3/12/14, 6:31 AM 2,026 views

I had a doubt regarding the .py code to print a report.For purchase order the code in the .py file is being provided below.But I didn't understand the last line report_sxw.report_sxw('report.purchase.order','purchase.order','addons/purchase/report/order.rml',parser=order).

class order(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(order, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({'time': time})


How is purchase.order given in that line.What is its significance and where is it taken from?The class name is order yet the report.sxw is given the name purchase.order.Can anyone please give me a clarification.

Can you please give explanation for the purchase.order given in report_sxw

sneha antony
on 3/12/14, 7:05 AM



| 5 4 7
Bikaner, India

OpenERP Developer at SunARC Technology

On 3/12/14, 7:32 AM

The parser inherit from the report_sxw.rml_parse object and it add to the localcontext, the function time so it will be possible to call it in the report.

After an instance of report_sxw.report_sxw is created with the parameters

  1. the name of the report
  2. the object name on which the report is defined
  3. the path to the rml file
  4. the parser to use for the report (by default rml_parse)
  5. a boolean to add or not the company header on the report (default True)

report_sxw The second parameter is object name 'purchase.order' for Purchase Module

from openerp.report import report_sxw File Location server\server\openerp\report\report_sxw.py


René Schuster

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

Challenge Everything!

René Schuster
On 3/12/14, 7:40 AM

As prakash suggested: See this for clarification.

order is a custom parser that inherits from report_sxw.rml_parse.
The __ini__ function is overridden to give access to the time via the localcontext.

From the given link above:

After, an instance of report_sxw.report_sxw is created with the parameters:
- the name of the report
- the object name on which the report is defined
- the path to the rml file
- the parser to use for the report (by default rml_parse)
- a boolean to add or not the company header on the report (default True)

If you check the code of report_sxw.report_sxw you will find the definition of its __init__ function:

class report_sxw(report_rml, preprocess.report):
def __init__(self, name, table, rml=False, parser=rml_parse, header='external', store=False):
    report_rml.__init__(self, name, table, rml, '')
    self.name = name
    self.parser = parser
    self.header = header
    self.store = store
    if header=='internal' or header=='internal landscape':

There you can see what the documentation already told you: The second argument is the table/model/object on which you create the report.
In your case 'purchase.order'. It has nothing to do with the name of the parser; this is the fourth argument.


I tried the code for printing in the warranty module.But on clicking the print button error occurs that

AttributeError: 'warranty_warranty' object has no attribute '%(collection_docket)d'

sneha antony
on 3/12/14, 8:01 AM

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

0 follower(s)


Asked: 3/12/14, 6:31 AM
Seen: 2026 times
Last updated: 3/16/15, 8:10 AM