I have a report I want to customize to add the company logo to the report, the problem is the whole report is generated by code. I want to print the company logo on the report, I can print the company name which indicates its working but with the logo, it seems due to path issues it does not seem to work. Here is my code with a snippet of what I have done so far.
def get_pdf(self, options, minimal_layout=True):
if not config['test_enable']:
self = self.with_context(commit_assetsbundle=True)
base_url = self.env['ir.config_parameter'].sudo().get_param('report.url') or self.env['ir.config_parameter'].sudo().get_param('web.base.url')
rcontext = {
'mode': 'print',
'base_url': base_url,
'company': self.env.company,
}
body = self.env['ir.ui.view'].render_template(
"account_reports.print_template",
values=dict(rcontext),
)
body_html = self.with_context(print_mode=True).get_html(options)
logging.info(self.env.user.company_id.name)
logging.info(self.env.user.company_id.logo)
test = "<header>"\
"<img style='width: 7.0cm; height: 1.8cm;' src='/web/binary/{}' alt='logo'/>"\
"</header>".format(self.env.user.company_id.logo)
ttt = bytes(test, 'utf-8')
Like I said it displays the company's name but not the logo even though the logo is set in the system.