I created a custom invoice layout that looks like this
It works fine in the preview
But when I try to generate the pdf from it I only get an html file containing an error
It looks like this:
{"code": 200, "message": "Odoo Server Error", "data": {"name": "odoo.addons.base.models.qweb.QWebException", "debug": "Traceback (most recent call last):\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py\", line 219, in render_template\n yield from compiled_fn(self, values, log)\n File \"\", line 20, in template_205\nAttributeError: 'res.company' object has no attribute 'company_id'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py\", line 2021, in report_download\n response = self.report_routes(reportname, docids=docids, converter=converter, context=context)\n File \"/usr/lib/python3/dist-packages/odoo/http.py\", line 535, in response_wrap\n response = f(*args, **kw)\n File \"/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py\", line 1950, in report_routes\n pdf = report.with_context(context)._render_qweb_pdf(docids, data=data)[0]\n File \"/usr/lib/python3/dist-packages/odoo/addons/account/models/ir_actions_report.py\", line 49, in _render_qweb_pdf\n return super()._render_qweb_pdf(res_ids=res_ids, data=data)\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py\", line 838, in _render_qweb_pdf\n html = self_sudo.with_context(context)._render_qweb_html(res_ids, data=data)[0]\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py\", line 882, in _render_qweb_html\n return self._render_template(self.report_name, data), 'html'\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py\", line 619, in _render_template\n return view_obj._render_template(template, values).encode()\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py\", line 1985, in _render_template\n return self.browse(self.get_view_id(template))._render(values, engine)\n File \"/usr/lib/python3/dist-packages/odoo/addons/website/models/ir_ui_view.py\", line 436, in _render\n return super(View, self)._render(values, engine=engine, minimal_qcontext=minimal_qcontext)\n File \"/usr/lib/python3/dist-packages/odoo/addons/web_editor/models/ir_ui_view.py\", line 29, in _render\n return super(IrUiView, self)._render(values=values, engine=engine, minimal_qcontext=minimal_qcontext)\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py\", line 1993, in _render\n return self.env[engine]._render(self.id, qcontext)\n File \"/usr/lib/python3/dist-packages/odoo/tools/profiler.py\", line 292, in _tracked_method_render\n return method_render(self, template, values, **options)\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_qweb.py\", line 76, in _render\n result = super()._render(template, values=values, **compile_options)\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py\", line 134, in _render\n result = ''.join(rendering)\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py\", line 221, in render_template\n raise e\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py\", line 219, in render_template\n yield from compiled_fn(self, values, log)\n File \"\", line 52, in template_778\n File \"\", line 48, in t_call_content\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py\", line 221, in render_template\n raise e\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py\", line 219, in render_template\n yield from compiled_fn(self, values, log)\n File \"\", line 926, in template_777\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py\", line 221, in render_template\n raise e\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py\", line 219, in render_template\n yield from compiled_fn(self, values, log)\n File \"\", line 50, in template_208\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py\", line 223, in render_template\n raise QWebException(\"Error when render the template\", self, options,\nodoo.addons.base.models.qweb.QWebException: 'res.company' object has no attribute 'company_id'\nTraceback (most recent call last):\n File \"/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py\", line 219, in render_template\n yield from compiled_fn(self, values, log)\n File \"\", line 20, in template_205\nAttributeError: 'res.company' object has no attribute 'company_id'\n\nError when render the template\nAttributeError: 'res.company' object has no attribute 'company_id'\nTemplate: web.external_layout_boxed\nPath: /t/div[1]/img\nNode: \n \n", "message": "Error when render the template", "arguments": ["Error when render the template"], "context": {}}}
As we can read from the error file, the pdf generator is not able to access company.company_id.x_layout_header
so I changed it to company.x_layout_header
→ Now the Preview doesn't work and the generated pdf looks like this:
Which is also completely wrong, there are no images, the table is not a table, the wrong font etc. What am I doing wrong?
Have someone resolved this?