Я пытаюсь создать пользовательский отчет в Odoo 12 , чтобы добавить его в параметр печати в разделе "Просмотр заказов". Пока все хорошо, я включаю XML в манифест и создаю XML в папке sale_management / report. Я обновляю модуль после редактирования, и он правильно скомпилирован. Тем не менее, когда я нажимаю кнопку печати, я получаю эту ошибку:
Error:
Odoo Server Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 347, in _compiled_fn
return compiled(self, append, new, options, log)
File "<template>", line 1, in template_829_149
File "<template>", line 2, in body_call_content_148
AttributeError: 'NoneType' object has no attribute 'with_context'
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 1671, in report_download
response = self.report_routes(reportname, docids=docids, converter=converter)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 519, in response_wrap
response = f(*args, **kw)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1612, 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 712, in render_qweb_pdf
html = self.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 752, in render_qweb_html
return self.render_template(self.report_name, data), 'html'
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 534, 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 1304, 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 27, 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 1313, in render
return self.env[engine].render(self.id, qcontext)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_qweb.py", line 59, 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 275, in render
self.compile(template, options)(self, body.append, values or {})
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 354, 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 'with_context'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 347, in _compiled_fn
return compiled(self, append, new, options, log)
File "<template>", line 1, in template_829_149
File "<template>", line 2, in body_call_content_148
AttributeError: 'NoneType' object has no attribute 'with_context'
Error to render compiling AST
AttributeError: 'NoneType' object has no attribute 'with_context'
Template: 829
Path: /templates/t/t/t[1]
Node: <t t-set="doc" t-value="doc.with_context(lang=doc.partner_id.lang)"/>
Для целей тестирования XML почти дословно уже включенного шаблона в том же каталоге с именем sale_report_templates. xml и весь мой файл:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<report
id="albaran_sin_valorar"
string="Documento sin valorar"
model="sale.order"
report_type="qweb-pdf"
name="sale_management.report_albaran_sin_valorar"
/>
<template id="report_albaran_sin_valorar" inherit_id="sale.report_saleorder_document">
<xpath expr="//div[hasclass('page')]/p[@id='fiscal_position_remark']" position="after">
<div t-if="doc.sale_order_option_ids and doc.state in ['draft', 'sent']">
<t t-set="has_option_discount" t-value="any(doc.sale_order_option_ids.filtered(lambda o: o.discount$
<h4>
<span>Optional Products</span>
</h4>
<table class="table table-sm">
<thead>
<tr>
<th class="text-left">Description</th>
<th t-if="has_option_discount" groups="sale.group_discount_per_so_line" class="text-lef$
<th class="text-right">Unit Price</th>
</tr>
</thead>
<tbody class="sale_tbody">
<tr t-foreach="doc.sale_order_option_ids" t-as="option">
<td>
<span t-field="option.name"/>
</td>
<td t-if="has_option_discount" groups="sale.group_discount_per_so_line">
...
</template>
</odoo>
Мои вопросы: - Конечно, в чем проблема. - Каковы внутренности Odoo, вовлеченные в проблему, поэтому я могу полностью понять ее
Заранее спасибо Jose