如何确定“ValueError:元素不能位于父视图中”的原因? - Odoo 10.0e企业

问题描述 投票:0回答:1

我最近在尝试通过自定义模块继承来自定义报告时犯了升级Base模块的错误。我正在处理在UI中以开发人员模式执行的自定义。我能够纠正存储在ir_ui_view中的先前自定义。但是,我在尝试将发票打印到PDF时遇到错误,但我无法找到原因。我还没有找到一些连接,我正在用它来理解报告继承。

错误是:

ValueError: Element '<xpath expr="//div/[@name='invoice_address']">' cannot be located in parent view

Error context:
View `report_invoice_document_inherit_sale`
[view_id: 1119, xml_id: sale.report_invoice_document_inherit_sale, model: n/a, parent_id: 735]

load could not load template
Template: account.report_invoice_document

这是ir_ui_view的继承:

<?xml version="1.0"?>
<data inherit_id="account.report_invoice_document">
        <xpath expr="//div[@name='invoice_address']" position="attributes">
            <attribute name="groups">!sale.group_delivery_invoice_address</attribute>
        </xpath>
        <xpath expr="//div[@name='invoice_address']" position="before">
            <div class="col-xs-5 col-xs-offset-7" groups="sale.group_delivery_invoice_address">
                <strong t-if="o.partner_shipping_id == o.partner_id">Invoicing and shipping address:</strong>
                <strong t-if="o.partner_shipping_id != o.partner_id">Invoicing address:</strong>
                <div t-field="o.partner_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"/>
                 <span t-if="o.partner_id.vat">TIN: <span t-field="o.partner_id.vat"/></span>
                <div t-if="o.partner_shipping_id != o.partner_id" class="mt8">
                    <strong>Shipping address:</strong>
                    <div t-field="o.partner_shipping_id" t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: True}"/>
                    <span t-if="o.partner_id.vat">TIN: <span t-field="o.partner_id.vat"/></span>
                </div>
            </div>
        </xpath>
   </data>

这里是父文件account\reports\report_invoice.xml,其中包含模板'report_invoice_document'

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="report_invoice_document">
    <t t-call="report.external_layout">
        <t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})" />
        <div class="page">
            <div class="row">
                <div name="invoice_address" class="col-xs-5 col-xs-offset-7">
                    <address t-field="o.partner_id"
                    t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
                    <span t-if="o.partner_id.vat">TIN: <span t-field="o.partner_id.vat"/></span>
                </div>
            </div>

            <h2>
                <span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Invoice</span>
                <span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA</span>
                <span t-if="o.type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span>
                <span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span>
                <span t-if="o.type == 'out_refund'">Refund</span>
                <span t-if="o.type == 'in_refund'">Vendor Refund</span>
                <span t-if="o.type == 'in_invoice'">Vendor Bill</span>
                <span t-field="o.number"/>
            </h2>

            <div class="row mt32 mb32">
                <div class="col-xs-2" t-if="o.name">
                    <strong>Description:</strong>
                    <p t-field="o.name"/>
                </div>
                <div class="col-xs-2" t-if="o.date_invoice">
                    <strong>Invoice Date:</strong>
                    <p t-field="o.date_invoice"/>
                </div>
                <div class="col-xs-2" t-if="o.date_due and o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">
                    <strong>Due Date:</strong>
                    <p t-field="o.date_due"/>
                </div>
                <div class="col-xs-2" t-if="o.origin">
                    <strong>Source:</strong>
                    <p t-field="o.origin"/>
                </div>
                <div class="col-xs-2" t-if="o.partner_id.ref">
                    <strong>Customer Code:</strong>
                    <p t-field="o.partner_id.ref"/>
                </div>
                <div name="reference" class="col-xs-2" t-if="o.reference and o.type == 'in_invoice'">
                    <strong>Reference:</strong>
                    <p t-field="o.reference"/>
                </div>
            </div>

            <!-- Is there a discount on at least one line? -->
            <t t-set="display_discount" t-value="any([l.discount for l in o.invoice_line_ids])"/>

            <table class="table table-condensed">
                <thead>
                    <tr>
                        <th>Description</th>
                        <th class="hidden">Source Document</th>
                        <th class="text-right">Quantity</th>
                        <th class="text-right">Unit Price</th>
                        <th t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">Disc.(%)</th>
                        <th class="text-right">Taxes</th>
                        <th class="text-right">Tax Excluded Price</th>
                    </tr>
                </thead>
                <tbody class="invoice_tbody">
                    <tr t-foreach="o.invoice_line_ids" t-as="l">
                        <td><span t-field="l.name"/></td>
                        <td class="hidden"><span t-field="l.origin"/></td>
                        <td class="text-right">
                            <span t-field="l.quantity"/>
                            <span t-field="l.uom_id"  groups="product.group_uom"/>
                        </td>
                        <td class="text-right">
                            <span t-field="l.price_unit"/>
                        </td>
                        <td t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">
                            <span t-field="l.discount"/>
                        </td>
                        <td class="text-right">
                            <span t-esc="', '.join(map(lambda x: (x.description or x.name), l.invoice_line_tax_ids))"/>
                        </td>
                        <td class="text-right">
                            <span t-field="l.price_subtotal" 
                             t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
                        </td>
                    </tr>
                </tbody>
            </table>



            <div class="row">
                <div class="col-xs-4 pull-right">
                    <table class="table table-condensed">
                        <tr class="border-black">
                            <td><strong>Subtotal</strong></td>
                            <td class="text-right">
                                <span t-field="o.amount_untaxed" options='{"widget": "monetary", "display_currency": o.currency_id}'/>
                            </td>
                        </tr>
                        <t t-foreach="o._get_tax_amount_by_group()" t-as="amount_by_group">
                            <tr>
                                <td><span t-esc="amount_by_group[0]"/></td>
                                <td class="text-right">
                                    <span t-esc="amount_by_group[1]"/>
                                </td>
                            </tr>
                        </t>
                        <tr class="border-black">
                            <td><strong>Total</strong></td>
                            <td class="text-right">
                                 <span t-field="o.amount_total" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>

            <p t-if="o.comment">
                <strong>Comment:</strong>
                <span t-field="o.comment"/>
            </p>
            <p t-if="o.payment_term_id">
                <span t-field="o.payment_term_id.note"/>
            </p>
            <p t-if="o.fiscal_position_id.note">
                <strong>Fiscal Position Remark:</strong>
                <span t-field="o.fiscal_position_id.note"/>
            </p>
         </div>
    </t>
</template>

<template id="report_invoice">
    <t t-call="report.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="account.report_invoice_document" t-lang="o.partner_id.lang"/>
       </t>
    </t>
</template>

<template id="account_invoice_report_duplicate" inherit_id="account.report_invoice_document" primary="True">
    <xpath expr="//h2" position="replace">
        <h2>
            <span>Duplicate</span>
            <span t-field="o.number"/>
        </h2>
    </xpath>
</template>

<template id="account_invoice_report_duplicate_main">
    <t t-call="report.html_container">
        <t t-foreach="docs" t-as="o">
            <t t-call="account.account_invoice_report_duplicate" t-lang="o.partner_id.lang"/>
        </t>
    </t>
</template>
</data>
</odoo>
inheritance odoo-10 valueerror
1个回答
0
投票

谢谢Litty的帮助。我发现我使用错误的值更新了id 735(account.report_invoice_document)的ir_ui_view的arch_db字段,因此依赖文档试图继承完全不相关的XML。

我应该删除这个问题吗?

© www.soinside.com 2019 - 2024. All rights reserved.