I've inherited purchase.order and added the field:
shipping_to = fields.Many2one('res.partner', string="Delivery place", default=lambda self: self.env['res.company']._company_default_get('partners.ext'))
I want to display it in the qweb report:< template id="external_layout_background_ext" inherit_id="web.external_layout_background">
< xpath expr="//div[1]" position="replace">
< div t-attf-class="header o_company_#{company.id}_layout" t-att-style="report_header_style">
< t t-if="doc_model == 'purchase.order'">
< span t-field="doc.shipping_to.display_name" style="font-weight:bold;" />
< /t>
< /div>
< /xpath>
< /template>
But I get this error:
Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 331, in _compiled_fn return compiled(self, append, new, options, log) File "", line 1, in template_web_external_layout_background_870 AttributeError: 'NoneType' object has no attribute 'shipping_to' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 2121, in report_download response = self.report_routes(reportname, docids=docids, converter=converter, context=context) File "/usr/lib/python3/dist-packages/odoo/http.py", line 531, in response_wrap response = f(*args, **kw) File "/mnt/extra-addons/report_xml/controllers/main.py", line 41, in report_routes return super().report_routes(reportname, docids, converter, **data) File "/usr/lib/python3/dist-packages/odoo/http.py", line 531, in response_wrap response = f(*args, **kw) File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 2056, in report_routes pdf = report.with_context(context)._render_qweb_pdf(docids, data=data)[0] File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 804, in _render_qweb_pdf html = self_sudo.with_context(context)._render_qweb_html(res_ids, data=data)[0] File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 845, in _render_qweb_html return self._render_template(self.sudo().report_name, data), 'html' File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 583, in _render_template return view_obj._render_template(template, values) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 1709, in _render_template return self.browse(self.get_view_id(template))._render(values, engine) File "/usr/lib/python3/dist-packages/odoo/addons/web_editor/models/ir_ui_view.py", line 28, in _render return super(IrUiView, self)._render(values=values, engine=engine, minimal_qcontext=minimal_qcontext) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 1717, in _render return self.env[engine]._render(self.id, qcontext) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_qweb.py", line 55, in _render result = super(IrQWeb, self)._render(id_or_xml_id, values=values, **context) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 258, in _render self.compile(template, options)(self, body.append, values or {}) File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 333, in _compiled_fn raise e File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 331, in _compiled_fn return compiled(self, append, new, options, log) File "", line 1, in template_purchase_report_purchaseorder_772 File "", line 2, in body_call_content_770 File "", line 3, in foreach_769 File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 333, in _compiled_fn raise e File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 331, in _compiled_fn return compiled(self, append, new, options, log) File "", line 1, in template_purchase_report_purchaseorder_document_810 File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 333, in _compiled_fn raise e File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 331, in _compiled_fn return compiled(self, append, new, options, log) File "", line 1, in template_web_external_layout_843 File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 338, in _compiled_fn raise QWebException("Error to render compiling AST", e, path, node and etree.tostring(node[0], encoding='unicode'), name) odoo.addons.base.models.qweb.QWebException: 'NoneType' object has no attribute 'shipping_to' Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 331, in _compiled_fn return compiled(self, append, new, options, log) File "", line 1, in template_web_external_layout_background_870 AttributeError: 'NoneType' object has no attribute 'shipping_to' Error to render compiling AST AttributeError: 'NoneType' object has no attribute 'shipping_to' Template: web.external_layout_background Path: /t/div[1]/t[3]/span Node:
I don't understand why 'doc' is none, because I'm using a similar structure for the sale.order and that works.
Thank you for any suggestions