Hello guy,
Trying to override the original point_of_sale.report_saleslines' to include a new docargs paperformat in my qweb report.
The paperformat works in my qweb report.
But impossible to process lines like <t t-esc="total_quantity(o)"/> in my qweb report (because of o).
I'm pretty sure that I have a trouble with wrapped_report_class. But I don't understand how to manage it.
Here is my override :
class report_saleslines_pt(osv.AbstractModel):
_name = 'report.point_of_sale.report_saleslines'
_template = 'point_of_sale.report_saleslines'
_inherit = 'report.abstract_report'
_wrapped_report_class = None
def render_html(self, cr, uid, ids, data=None, context=None):
context = dict(context or {})
paperformat_obj = context.get('chosenPaper') #works well
# If the key 'landscape' is present in data['form'], passing it into the context
if data and data.get('form', {}).get('landscape'):
context['landscape'] = True
if context and context.get('active_ids'):
# Browse the selected objects via their reference in context
model = context.get('active_model') or context.get('model')
objects_model = self.pool[model]
objects = objects_model.browse(cr, uid, context['active_ids'], context=context)
else:
# If no context is set (for instance, during test execution), build one
model = self.pool['report']._get_report_from_name(cr, uid, self._template).model
objects_model = self.pool[model]
objects = objects_model.browse(cr, uid, ids, context=context)
context['active_model'] = model
context['active_ids'] = ids
# Generate the old style report
wrapped_report = self._wrapped_report_class(cr, uid, '', context=context)
_logger.error('LAPAGEPT_CLASSES :: RENDER_HTML() %s %s', 'WRAPPED_REPORT :: ', wrapped_report)
wrapped_report.set_context(objects, data, context['active_ids'])
# Rendering self._template with the wrapped report instance localcontext as
# rendering environment
docargs = wrapped_report.localcontext
docargs['docs'] = docargs.get('objects')
# Used in template translation (see translate_doc method from report model)
docargs['doc_ids'] = context['active_ids']
docargs['doc_model'] = model
docargs['paperformat'] = paperformat_obj
return self.pool['report'].render(cr, uid, [], self._template, docargs, context=context)
report_saleslines_pt()
Here is the error.
Traceback (most recent call last): File "/home/odoo-test/addons/report/controllers/main.py", line 122, in report_download response = self.report_routes(reportname, docids=docids, converter='pdf') File "/home/odoo-test/openerp/http.py", line 395, in response_wrap response = f(*args, **kw) File "/home/odoo-test/addons/report/controllers/main.py", line 65, in report_routes pdf = report_obj.get_pdf(cr, uid, docids, reportname, data=options_data, context=context) File "/home/odoo-test/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/odoo-test/addons/report_lapagept/models/report_lapagept.py", line 134, in get_pdf html = self.get_html(cr, uid, ids, report_name, data=data, context=context) File "/home/odoo-test/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/odoo-test/addons/report_lapagept/models/report_lapagept.py", line 112, in get_html return particularreport_obj.render_html(cr, uid, ids, data=data, context=context) File "/home/odoo-test/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/odoo-test/addons/report_lapagept/lapagept_classes.py", line 80, in render_html wrapped_report = self._wrapped_report_class(cr, uid, '', context=context) TypeError: 'NoneType' object is not callable
should I also create a new parser class?
And if I would want to use the same wrapped_report_class than the original AbstractReport class (i.e. openerp.addons.point_of_sale.report.pos_lines.pos_lines)?