Hi,
I have the following report defined:
<report
id="report_invoice_custom"
model="account.invoice"
string="Custom invoice report"
report_type="qweb-pdf"
name="custom_reports.invoice_custom"
attachment_use="False"
file="custom_reports.invoice_custom"
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)
self.localcontext.update({
'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:
report_sxw.report_sxw(
'custom_reports.invoice_custom',
'account.invoice',
'custom/custom_reports/xml/custom_reports.xml',
parser= select_value )
Could someone help me to understand how to register the parser?
Thanks,