hello all,
How could I test the paperformat of the actual report with « t-if »?
I'm already able to test many thing, but I don't find for the paperformat.
Idea?
Thanks
UPDATED - UPDATED - UPDATED - MANY TIMES :
In try this code in my qweb /home/odoo-test/addons/report_lapagept/views/report_saleslines_lapagept.xml.
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_lapagept.report_saleslines_pt" inherit_id="point_of_sale.report_saleslines">
<xpath expr="//div[@class='page']" position="replace">
<div style="font-family: Ubuntu;" class="page">
<div class="row">
<div class="col-xs-12" style="padding-top: 8px;">
<h1><span t-if="not paperformat">There is no paperformat here</span></h1>
<h1><span t-if="paperformat">There is a paperformat here</span></h1>
<h3><span t-esc="o.user_id.company_id.name" /> - Saleslines</h3>
</div>
</div>
And this code in /home/odoo-test/addons/report_lapagept/report_saleslines_pt.py.
import logging
_logger = logging.getLogger(__name__)
from openerp import api, models
class report_saleslines_pt(models.AbstractModel):
_name = 'report.point_of_sale.report_saleslines'
_template = 'point_of_sale.report_saleslines'
@api.multi
def render_html(self, data=None):
report_obj = self.env['report']
report = report_obj._get_report_from_name('point_of_sale.report_saleslines')
if not report.paperformat_id:
paperformat_obj = self.env.user.company_id.paperformat_id
_logger.error('REPORT_SALES_LINES :: NO PAPER HERE IN THIS REPORT... WEIRD! ' + str(paperformat_obj))
else:
paperformat_obj = report.paperformat_id
_logger.error('REPORT_SALES_LINES :: LE PAPIER POUR CE RAPPORT EST : ' + str(paperformat_obj))
docargs = {
'paperformat': paperformat_obj,
'doc_ids': self._ids,
'doc_model': report.model,
'docs': self,
}
return report_obj.render('point_of_sale.report_saleslines', docargs)
report_saleslines_pt()
I get this error when trying to get the PDF.
raceback (most recent call last): File "/home/odoo-test/addons/report_lapagept/controllers/control_pt.py", line 130, in report_download response = ReportController().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 165, in get_pdf paperformat, specific_paperformat_args, save_in_attachment File "/home/odoo-test/openerp/api.py", line 241, in wrapper return old_api(self, *args, **kwargs) File "/home/odoo-test/addons/report/models/report.py", line 390, in _run_wkhtmltopdf command_args.extend(self._build_wkhtmltopdf_args(paperformat, spec_paperformat_args)) File "/home/odoo-test/addons/report/models/report.py", line 513, in _build_wkhtmltopdf_args if paperformat.format and paperformat.format != 'custom': AttributeError: 'int' object has no attribute 'format'
answer updated, demo and small correction in code
change .... 'paperformat': paperformat_obj, ... to .... 'pformatFOO': paperformat_obj, ... names conflict???
In my system works without problems!
Thanks a lot. I will disable all my modules. Almost sure the problem come for there. I will come back later.