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 register a parser for a qweb report

on 9/26/15, 2:02 PM 859 views


I have the following report defined:

string="Custom invoice report"
attachment = "(object.state in ('open','paid')) and ('F_'+(object.number or '').replace('/','')+'.pdf')"

And I am defining a new parser for it:

from openerp.report import report_sxw
from openerp.osv import osv
from openerp import api

class invoice_parser(report_sxw.rml_parse):

def __init__(self, cr, uid, name, context):
super(invoice_parser, self).__init__(cr, uid, name, context=context)
'select_value': self._selection_value,

def _selection_value(self, value):
if value:
tax_pool = self.pool.get('account.tax')
tax_ids = tax_pool.search(self.cr, self.uid, [('name', '=', value)])
if tax_ids:
tax_id = tax_pool.browse(self.cr, self.uid, tax_ids[0])
return self._translate(tax_id.description)
return value

class report_custom_invoice_parser(osv.AbstractModel):
_name = 'report.module.invoice.wrapper'
_inherit = 'report.abstract_report'
_template = 'custom_reports.invoice_custom'
_wrapped_report_class = invoice_parser

If I understood how parsers work, I guess I have to add something similar to the following code to register the parser:

parser= select_value )

Could someone help me to understand how to register the parser?



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 9/26/15, 3:39 PM

In order for the parser to be picked by Odoo and according for your example you need to define it like this:

class report_custom_invoice_parser(osv.AbstractModel):
_name = 'report.custom_reports.invoice_custom'
_inherit = 'report.abstract_report'
_template = 'custom_reports.invoice_custom'
_wrapped_report_class = invoice_parser

So simple, thanks!!

on 9/27/15, 7:30 AM

I write a more extensive explanation of qweb report parsers at:

Axel Mendoza
on 10/15/15, 5:50 AM

Hi Sir @Axel, why I always got an error that the _name attrbiute is invalid wherein that's the name I defines in my report? But when I remove the module name, dont have an error but the function I created is not callable.

Samantha Cruz
on 3/4/16, 12:54 AM

post your error log

Axel Mendoza
on 3/7/16, 4:21 AM

Hi Sir @Axel, it was already solved, the problem is the name of the module. I have a question Sir, please refer to this link https://www.odoo.com/es_ES/forum/ayuda-1/question/batch-report-using-report-parser-98789, Your suggestions will be highly appreciated :)

Samantha Cruz
on 3/7/16, 7:18 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: 9/26/15, 2:02 PM
Seen: 859 times
Last updated: 9/27/15, 7:30 AM