无法在Odoo 11中加载模板account.report_invoice_document_with_payments

时间:2018-01-18 15:32:37

标签: odoo qweb odoo-11

我正在尝试自定义Odoo 11的发票报告。我还要自定义页眉,页脚和正文。这是我的示例代码

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

    <template id="external_layout__standard_abc">
        <div class="header">
             <t t-set="company" t-value="res_company"/>
                <t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})" />
            <div class="row">
                <div class="col-xs-6 mb4">
                    <img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % to_text(company.logo)" style="max-height: 45px;"/>
                </div>
                <div class="col-xs-6" name="company_address" style="text-align:right;">
                    <h3 style="text-transform: uppercase;">INVOICE</h3>
                    <strong t-field="company.partner_id"></strong>
                       <span  t-field="company.partner_id" t-field-options='{"widget": "contact", "fields": ["address"], "no_marker": true}'/><br/>
                        Phone: <span t-field="company.phone"/><br/>
                        Email: <span t-field="company.email"/><br/>
                        Fax: <span t-field="company.fax"/><br/>
                        Mobile: <span t-field="company.mobile"/>
                </div>
            </div>
        </div>
        <div class="article o_report_layout_standard">
            <t t-raw="0" />
        </div>
        <div class="footer">
        <div class="text-center" style="border-top: 1px solid black;">
            <ul class="list-inline mb4">
                <li t-if="company.phone">Phone: <span t-field="company.phone"/></li>
                <li t-if="company.email">Email: <span t-field="company.email"/></li>
                <li t-if="company.website">Web: <span t-field="company.website"/></li>
                <li t-if="company.vat"><t t-esc="company.country_id.vat_label or 'TIN'"/>: <span t-field="company.vat"/></li>
            </ul>

            <div name="financial_infos">
                <span t-field="company.report_footer"/>
            </div>
        </div>
    </div>
    </template>
    <template id="report_invoice_document_abc_body">
            <xpath expr="//table[@class='table table-condensed']//thead//tr" position="replace">
                <tr style="background-color:lightgray;">
                <th>Description</th>
                <th class="text-right">Price</th>
                 </tr>
            </xpath>
    </template>
    <template id="report_header" inherit_id="account.report_invoice_document">
         <xpath expr="t[@t-call='web.external_layout']" position="replace">
             <t t-call="abc.external_layout__standard_abc">
                 <t t-call="abc.report_invoice_document_abc_body"/>
            </t>
         </xpath>
    </template>
</data>
</openerp>

但我的问题是它的工作正常“没有付款的发票”,但是当我试图提取“发票”的pdf报告时,它显示以下错误。是否有任何特殊原因?

    Error:
Odoo Server Error

Traceback (most recent call last):
  File "/Users/paramitamitra/odoo11/core/odoo/tools/cache.py", line 84, in lookup
    r = d[key]
  File "/Users/paramitamitra/odoo11/core/odoo/tools/func.py", line 68, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/paramitamitra/odoo11/core/odoo/tools/lru.py", line 44, in __getitem__
    a = self.d[obj].me
KeyError: ('ir.qweb', <function IrQWeb.compile at 0x10b35e730>, 'account.report_invoice_document_with_payments', ('en_US', True, None, None, None, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/paramitamitra/odoo11/core/odoo/tools/cache.py", line 84, in lookup
    r = d[key]
  File "/Users/paramitamitra/odoo11/core/odoo/tools/func.py", line 68, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/paramitamitra/odoo11/core/odoo/tools/lru.py", line 44, in __getitem__
    a = self.d[obj].me
KeyError: ('ir.ui.view', <function View._read_template at 0x10aeda7b8>, frozenset({1, 3, 4, 7, 8, 18, 19, 20, 23, 24, 25, 28}), 493, ('en_US', True, None, None, None, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/qweb.py", line 367, in get_template
    document = options.get('load', self.load)(template, options)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 85, in load
    template = env['ir.ui.view'].read_template(name)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 1053, in read_template
    return self._read_template(self.get_view_id(xml_id))
  File "<decorator-gen-25>", line 2, in _read_template
  File "/Users/paramitamitra/odoo11/core/odoo/tools/cache.py", line 89, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 1044, in _read_template
    arch = self.browse(view_id).read_combined(['arch'])['arch']
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 707, in read_combined
    arch_tree = self.apply_inheritance_specs(arch_tree, view_arch, parent_view['id'])
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 644, in apply_inheritance_specs
    self.raise_view_error(_("Element '%s' cannot be located in parent view") % tag, inherit_id)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 506, in raise_view_error
    raise ValueError(message)
ValueError: Element '<xpath expr="//div[@id='total']/div/table">' cannot be located in parent view

Error context:
View `report_invoice_document`
[view_id: 492, xml_id: account.report_invoice_document, model: n/a, parent_id: n/a]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/paramitamitra/odoo11/core/addons/web/controllers/main.py", line 1658, in report_download
    response = self.report_routes(reportname, docids=docids, converter='pdf')
  File "/Users/paramitamitra/odoo11/core/odoo/http.py", line 512, in response_wrap
    response = f(*args, **kw)
  File "/Users/paramitamitra/odoo11/core/addons/web/controllers/main.py", line 1607, in report_routes
    pdf = report.with_context(context).render_qweb_pdf(docids, data=data)[0]
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_actions_report.py", line 624, in render_qweb_pdf
    html = self.with_context(context).render_qweb_html(res_ids, data=data)[0]
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_actions_report.py", line 662, in render_qweb_html
    return self.render_template(self.report_name, data), 'html'
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_actions_report.py", line 470, in render_template
    return view_obj.render_template(template, values)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 1158, in render_template
    return self.browse(self.get_view_id(template)).render(values, engine)
  File "/Users/paramitamitra/odoo11/core/addons/web_editor/models/ir_ui_view.py", line 27, in render
    return super(IrUiView, self).render(values=values, engine=engine)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 1167, in render
    return self.env[engine].render(self.id, qcontext)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 57, in render
    return super(IrQWeb, self).render(id_or_xml_id, values=values, **context)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/qweb.py", line 271, in render
    self.compile(template, options)(self, body.append, values or {})
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/qweb.py", line 343, in _compiled_fn
    raise e
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/qweb.py", line 341, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "<template>", line 1, in template_495_12684
  File "<template>", line 2, in body_call_content_12683
  File "<template>", line 3, in foreach_12682
  File "<decorator-gen-35>", line 2, in compile
  File "/Users/paramitamitra/odoo11/core/odoo/tools/cache.py", line 89, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 77, in compile
    return super(IrQWeb, self).compile(id_or_xml_id, options=options)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/qweb.py", line 288, in compile
    element, document = self.get_template(template, options)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/qweb.py", line 371, in get_template
    raise QWebException("load could not load template", name=template)
odoo.addons.base.ir.ir_qweb.qweb.QWebException: None
Traceback (most recent call last):
  File "/Users/paramitamitra/odoo11/core/odoo/tools/cache.py", line 84, in lookup
    r = d[key]
  File "/Users/paramitamitra/odoo11/core/odoo/tools/func.py", line 68, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/paramitamitra/odoo11/core/odoo/tools/lru.py", line 44, in __getitem__
    a = self.d[obj].me
KeyError: ('ir.qweb', <function IrQWeb.compile at 0x10b35e730>, 'account.report_invoice_document_with_payments', ('en_US', True, None, None, None, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/paramitamitra/odoo11/core/odoo/tools/cache.py", line 84, in lookup
    r = d[key]
  File "/Users/paramitamitra/odoo11/core/odoo/tools/func.py", line 68, in wrapper
    return func(self, *args, **kwargs)
  File "/Users/paramitamitra/odoo11/core/odoo/tools/lru.py", line 44, in __getitem__
    a = self.d[obj].me
KeyError: ('ir.ui.view', <function View._read_template at 0x10aeda7b8>, frozenset({1, 3, 4, 7, 8, 18, 19, 20, 23, 24, 25, 28}), 493, ('en_US', True, None, None, None, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/qweb.py", line 367, in get_template
    document = options.get('load', self.load)(template, options)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 85, in load
    template = env['ir.ui.view'].read_template(name)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 1053, in read_template
    return self._read_template(self.get_view_id(xml_id))
  File "<decorator-gen-25>", line 2, in _read_template
  File "/Users/paramitamitra/odoo11/core/odoo/tools/cache.py", line 89, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 1044, in _read_template
    arch = self.browse(view_id).read_combined(['arch'])['arch']
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 707, in read_combined
    arch_tree = self.apply_inheritance_specs(arch_tree, view_arch, parent_view['id'])
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 644, in apply_inheritance_specs
    self.raise_view_error(_("Element '%s' cannot be located in parent view") % tag, inherit_id)
  File "/Users/paramitamitra/odoo11/core/odoo/addons/base/ir/ir_ui_view.py", line 506, in raise_view_error
    raise ValueError(message)
ValueError: Element '<xpath expr="//div[@id='total']/div/table">' cannot be located in parent view

Error context:
View `report_invoice_document`
[view_id: 492, xml_id: account.report_invoice_document, model: n/a, parent_id: n/a]

load could not load template
Template: account.report_invoice_document_with_paymentsenter code here

提前感谢。

1 个答案:

答案 0 :(得分:1)

这是一个模板,而不是一个视图。你不能通过这种方式继承它,你需要以这种方式扩展它:

<template id="report_header">
    <t t-extend="account.report_invoice_document">
         <xpath expr="t[@t-call='web.external_layout']" position="replace">
             <t t-call="abc.external_layout__standard_abc">
                 <t t-call="abc.report_invoice_document_abc_body"/>
            </t>
          </xpath>
    </t>
</template>