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.


Is it mandatory to inherit report_sxw.rml_parse for custom report even with odoo 8?

Pascal Tremblay
on 2/12/16, 7:41 AM 799 views

Hello guys,

I want to create a new custom report in my Odoo 8.

Everywhere on the web, custom reports classes are created with two classes : 

  • One class inherits report_sxw.rml_parse

  • One class inherits models.AbstractModel (the parser)

If I well understand, it is mandatory to inherit report_sxw.rml_parse and after create a parser who inherits models.AbstractModel. Is it the case?

But, is report_sxw.rml_parse model not in the old api?

Could we only create a new report ONLY with models.AbstractModel who seems to be in the new api?

Really not clear in my head...

Thanks for your comment.

Neither in your head, nor in mine... even nor in documentation!

Daniel Blanco
on 8/31/16, 9:50 PM

Axel Mendoza

--Axel Mendoza--
| 6 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 2/12/16, 12:11 PM

Hi @Pascal

Very good question, I didn't ask that for myself. 

The real answer is no because we are in python, in other strongly typed programming lang the answer would be yes.

The only thing that we do when we define a parser is inherit from report_sxw.rml_parse to add our methods and values into the localcontext dict value by reimplementing the __init__ method to add our stuffs but Odoo 8 do not anything of that, it's just using report_sxw.rml_parse to build the self.localcontext dict and to call the set_context method. The new report api jus do this with the wrapper_report_class

# Generate the old style report

wrapped_report = self._wrapped_report_class(cr, uid, '', context=context)

wrapped_report.set_context(objects, data, context['active_ids'])

# Rendering self._template with the wrapped report instance localcontext as

# rendering environment

docargs = dict(wrapped_report.localcontext)

So you can do this:

class report_parser(object):
    def __init__(self, cr, uid, name, context):

self.localcontext = {

'next_seq': 'value',

'select_value': self._function,


def set_context(self, objects, data, ids, report_type = None):

self.localcontext['data'] = data

self.localcontext['objects'] = objects

class report_test1_parser(models.AbstractModel):

_name = 'report.parser_test_module.report_test1'

_inherit = 'report.abstract_report'

_template = 'parser_test_module.report_test1'

_wrapped_report_class = report_parser

So no need to inherit form the old api report_sxw.rml_parse

You are really a beast. Thanks.

Pascal Tremblay
on 2/12/16, 12:26 PM

Good questions gets good answers

Axel Mendoza
on 2/12/16, 12:27 PM

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

2 follower(s)


Asked: 2/12/16, 7:41 AM
Seen: 799 times
Last updated: 3/1/16, 2:44 AM