错误元素'<xpath expr =“//表单/页脚/按钮[@ name ='create_payment']”name =“”>'无法位于父视图中

时间:2018-05-15 14:20:53

标签: python xml odoo-11

为什么我收到此错误:

Element '<xpath expr="//form/footer/button[@name='create_payment']" 
name="">' cannot be located in parent view

Error context:
View `account.register.payments.wizard.from.invoices.inherited`
[view_id: 660, xml_id: 
account_bankgiro_payment_file.view_account_payment_from_invoices_inherit_account_bankgiro, model: account.register.payments, parent_id: 384]
None" while parsing /home/prachh/odoo-new/11/apps/account_bankgiro_payment_file/views/inherited_account_register_payments.xml:11, near

虽然一切似乎都正确吗?这是我的代码:

        <record id="view_bankgiro_transfer_download" model="ir.ui.view">
            <field name="name">account.payment.bankgiro.download</field>
            <field name="model">account.payment.bankgiro</field>
            <field name="arch" type="xml">
                <form string="Download BankGiro Transfer File" version="7.0">
                    <group>
                        <p class="oe_grey" colspan="4">
                           Click on the file to save it somewhere on your computer. Then upload that file on your bank's homebanking website.
                        </p>
                        <field name="file" filename="filename"/>
                        <field name="filename" invisible="True"/>
                    </group>
                    <group>
                    </group>
                    <footer>
                        <button string="Cancel" class="oe_link" special="cancel" invisible="1"/>
                    </footer>
                </form>
            </field>
        </record>

         <record id="inv_bankgiro_pay_tree" model="ir.ui.view">
            <field name="name">account.bankgiro.pay.tree</field>
            <field name="model">account.payment.bankgiro</field>
            <field name="arch" type="xml">
                <form string="Invoices to be paid via BankGiro">
                    <field name="vendor_invoice">
                        <tree editable="bottom" delete="true" create="false" decoration-danger="(recip_bankgiro_acct == False) or (memo == '') or (bool_red == True)">
                            <field name="id" invisible="1"/>
                            <field name="partner_id"/>
                            <field name="recip_bankgiro_acct"/>
                            <field name="number"/>
                            <field name="ocr_number"/>
                            <field name="memo"/>
                            <field name="date_due" invisible="1"/>
                            <field name="pay_date"/>
                            <field name="origin"/>
                            <field name="residual" string="Payment Amount" sum="Total"/>
                            <field name="state"/>
                            <field name="currency_id"/>
                            <field name="bool_red" invisible="1"/>
                        </tree>
                    </field>
                    <footer>
                        <button name="btn_generate_bankgiro" string="Generate BankGiro Payment File"
                            type="object" class="btn btn-primary"/>
                        <button string="Cancel" class="btn-default" special="cancel"/>
                    </footer>
                </form>
            </field>
        </record>

         <record id="inv_tree" model="ir.ui.view">
            <field name="name">account.invoice.pay.tree</field>
            <field name="model">account.invoice</field>
            <field name="arch" type="xml">
                <tree>
                    <field name="id" invisible="1"/>
                    <field name="partner_id"/>
                    <field name="recip_bankgiro_acct"/>
                    <field name="number"/>
                    <field name="ocr_number"/>
                    <field name="memo"/>
                    <field name="date_due" invisible="1"/>
                    <field name="pay_date"/>
                    <field name="origin"/>
                    <field name="pay_amt" string="Payment Amount" sum="Total"/>
                    <field name="state"/>
                    <field name="currency_id"/>
                    <field name="bool_red" invisible="1"/>
                </tree>
            </field>
        </record>

        <record id="view_account_bankgiro_payment_tree" model="ir.ui.view">
            <field name="name">account.payment.bankgiro.tree</field>
            <field name="model">account.payment.bankgiro</field>
            <field name="arch" type="xml">
                <tree create="false">
                    <field name="name"/>
                    <field name="currency_id" invisible="1"/>
                    <field name="date"/>
                    <field name="total_amount" options="{'currency_field': 'currency_id'}"/>
                </tree>
            </field>
        </record>

        <record id="view_account_bankgiro_payment_form" model="ir.ui.view">
            <field name="name">account.payment.bankgiro.form</field>
            <field name="model">account.payment.bankgiro</field>
            <field name="arch" type="xml">
                <form create="false" edit="false">
                    <sheet>
                        <div class="oe_button_box" name="button_box">
                            <button class="oe_stat_button" name="button_invoices"
                                    string="Invoices" type="object"
                                    icon="fa-bars"/>
                            <button class="oe_stat_button" name="button_payments"
                                    string="Payments" type="object"
                                    icon="fa-bars"/>
                        </div>
                        <div class="oe_title">
                            <h1><field name="name"/></h1>
                        </div>
                        <group>
                            <group>
                                <field name="filename" invisible="1"/>
                                <field name="file" filename="filename" readonly="True"/>

                            </group>
                            <group>
                                <field name="currency_id" invisible="1"/>
                                <field name="date" readonly="True"/>
                                <field name="total_amount" options="{'currency_field': 'currency_id'}" readonly="True"/>
                            </group>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>








    <record id="account_payment_method_bankgiro_transfer" model="account.payment.method">
        <field name="name">BankGiro Transfer</field>
        <field name="code">bankgiro_tr</field>
        <field name="payment_type">outbound</field>
    </record>

    <record id="view_account_payment_from_invoices_inherit_account_bankgiro" model="ir.ui.view">
        <field name="name">account.register.payments.wizard.from.invoices.inherited</field>
        <field name="model">account.register.payments</field>
        <field name="inherit_id" ref="account.view_account_payment_from_invoices"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='payment_date']" position="attributes">
                <attribute name="attrs">{'invisible':[('payment_method_code','=','bankgiro_tr')]}</attribute>
            </xpath>
            <xpath expr="//field[@name='communication']" position="attributes">
                <attribute name="attrs">{'invisible':[('payment_method_code','=','bankgiro_tr')]}</attribute>
            </xpath>
            <xpath expr="//field[@name='amount']" position="attributes">
                <attribute name="attrs">{'invisible':[('payment_method_code','=','bankgiro_tr')]}</attribute>
            </xpath>
           <xpath expr="//form/footer/button[@name='create_payment']" position="attributes" name="" >
                <attribute name="attrs">{'invisible':[('payment_method_code','=','bankgiro_tr')]}</attribute>
            </xpath>
            <xpath expr="//form/footer/button[@special='cancel']" position="before">
                <button string='Validate' name="create_bankgiro_payment" type="object" class="btn-primary" attrs="{'invisible': [('payment_method_code','!=','bankgiro_tr')]}"/>
            </xpath>
        </field>
    </record>

1 个答案:

答案 0 :(得分:1)

xpath没有属性name,只需将其从您的视图中删除即可。

你有这个:

<xpath expr="//form/footer/button[@name='create_payment']" position="attributes" name="" >
    <attribute name="attrs">{'invisible':[('payment_method_code','=','bankgiro_tr')]}</attribute>
</xpath>

你需要写下这个:

<xpath expr="//form/footer/button[@name='create_payment']" position="attributes">
    <attribute name="attrs">{'invisible':[('payment_method_code','=','bankgiro_tr')]}</attribute>
</xpath>

修改

注释那些正在修改create_payment按钮的行:

<!-- <xpath expr="//form/footer/button[@name='create_payment']" position="attributes">
    <attribute name="attrs">{'invisible':[('payment_method_code','=','bankgiro_tr')]}</attribute>
</xpath> -->

然后重新启动Odoo并通过接口更新模块 account_bankgiro_payment_file 。在那之后,告诉我错误是否消失或者你有另一个错误。