Python 从10到12的迁移模块

Python 从10到12的迁移模块,python,xml,odoo,odoo-10,odoo-12,Python,Xml,Odoo,Odoo 10,Odoo 12,我正在尝试将模块从Odoo 10迁移到12,但它显示了此错误,我不明白原因: 属性中使用的字段“状态”必须出现在视图中,但缺少 你能帮我解决这个问题吗 Field 'state' used in attributes must be present in view but is missing: - 'state' in attrs="{'invisible': ['|','|',('journal_entry_ids', '!=', []), ('state', '=', 'confirm'

我正在尝试将模块从Odoo 10迁移到12,但它显示了此错误,我不明白原因:

属性中使用的字段“状态”必须出现在视图中,但缺少

你能帮我解决这个问题吗

Field 'state' used in attributes must be present in view but is missing:
 - 'state' in attrs="{'invisible': ['|','|',('journal_entry_ids', '!=', []), ('state', '=', 'confirm'),('type', '!=', 'bank')]}"
 - 'state' in attrs="{'invisible': ['|','|',('journal_entry_ids', '=', []), ('state', '=', 'confirm'),('type', '!=', 'bank')]}"

Error context:
View `account.bank.statement.form.reconciliation`
[view_id: 1684, xml_id: n/a, model: account.bank.statement, parent_id: 462]
None while parsing /home/PycharmProjects/Odoo12/bank_reconciliation/views/account_view.xml:4, near
<record id="view_bank_statement_form_reconciliation" model="ir.ui.view">
    <field name="name">account.bank.statement.form.reconciliation</field>
    <field name="model">account.bank.statement</field>
    <field name="inherit_id" ref="account.view_bank_statement_form"/>
    <field name="arch" type="xml">
        <data>
            <field name="date" position="after">
                <field name="type" invisible="1"/>
            </field>
            <xpath expr="//button[1]" position="attributes">
                <attribute name="attrs">{'invisible': [('type', '!=', 'cash')]}</attribute>
            </xpath>
            <xpath expr="//field[@name='line_ids']/tree/field[@name='bank_account_id']" position="after">
                <field name="type" invisible="1"/>
                <button name="select_account_move_line" type="object" icon="fa-registered" attrs="{'invisible': ['|','|',('journal_entry_ids', '!=', []), ('state', '=', 'confirm'),('type', '!=', 'bank')]}"/>
            </xpath>
            <xpath expr="//field[@name='line_ids']/tree/field[@name='bank_account_id']" position="after">
                <button name="cancel_reconciliation" type="object" icon="fa-chain-broken" attrs="{'invisible': ['|','|',('journal_entry_ids', '=', []), ('state', '=', 'confirm'),('type', '!=', 'bank')]}"/>
            </xpath>
            <xpath expr="//field[@name='line_ids']" position="inside">
                <form string="Statement Line" create="false">
                    <group col="4">
                        <field name="statement_id"/>
                        <field name="date"/>
                        <field name="name"/>
                        <field name="ref"/>
                        <field name="partner_id"/>
                        <field name="amount"/>
                        <field name="journal_currency_id" invisible="1"/>
                        <field name="sequence"/>
                        <field name="note"/>
                </group>
                    <notebook colspan="4">
                        <page string="Ecritures liées">
                            <field name="move_line_ids">
                                <tree readonly="1">
                                    <field name="name"/>
                                    <field name="account_id"/>
                                    <field name="move_id"/>
                                    <field name="date"/>
                                    <field name="debit" sum="Débit"/>
                                    <field name="credit" sum="Crédit"/>
                                </tree>
                            </field>
                        </page>
                    </notebook>
                </form>
            </xpath>
        </data>
    </field>
</record>
属性中使用的字段“状态”必须出现在视图中,但缺少: -属性中的“状态”(“{'invisible':['|','|',('journal_entry_ids','!=',[]),('state','=','confirm'),('type',','!=','bank')]} -属性中的“状态”(“{'invisible':['|','|',('journal_entry_ids','=',[]),('state','=','confirm'),('type','!=','bank')]} 错误上下文: 查看“account.bank.statement.form.对账”` [视图id:1684,xml id:n/a,型号:account.bank.statement,父项id:462] 解析/home/PycharmProjects/Odoo12/bank_-condition/views/account_-view.xml时无:4,近 账户、银行、对账单、表格、对账 账户、银行对账单 {'invisible':[('type','!=','cash')]] 错误表示属性“state”在父视图中不存在,但它存在。

以下是父视图:

<record id="view_bank_statement_form" model="ir.ui.view">
    <field name="name">account.bank.statement.form</field>
    <field name="model">account.bank.statement</field>
    <field name="priority">1</field>
    <field name="arch" type="xml">
        <form string="Bank Statement">
        <header>
            <field name="all_lines_reconciled" invisible="1" />
            <button name="%(action_bank_reconcile_bank_statements)d" string="Reconcile" type="action" class="oe_highlight" attrs="{'invisible':['|','|',('all_lines_reconciled','=',True),('line_ids','=',[]),('state', '!=', 'open')]}"/>
            <button name="check_confirm_bank" string="Validate" type="object" class="oe_highlight" attrs="{'invisible':['|','|',('all_lines_reconciled','=',False),('line_ids','=',[]),('state', '!=', 'open')]}"/>
            <field name="state" widget="statusbar" statusbar_visible="open,confirm"/>
        </header>
        ...
    </field>
</record>

账户、银行、对账单、表格
账户、银行对账单
1.
...

当您编写以下内容时:

<xpath expr="//field[@name='line_ids']/tree/field[@name='bank_account_id']" position="after">
    ...
</xpath>

顺便说一下,您重复了两次相同的
xpath
,这对Odoo来说既费解又慢,因此我将其分组为一个更有意义的方法。

感谢您的澄清,我现在明白了。
<xpath expr="//field[@name='line_ids']/tree/field[@name='bank_account_id']" position="after">
    <field name="type" invisible="1"/>
    <field name="state" invisible="1"/>
    <button name="select_account_move_line" type="object" icon="fa-registered" attrs="{'invisible': ['|','|',('journal_entry_ids', '!=', []), ('state', '=', 'confirm'),('type', '!=', 'bank')]}"/>
    <button name="cancel_reconciliation" type="object" icon="fa-chain-broken" attrs="{'invisible': ['|','|',('journal_entry_ids', '=', []), ('state', '=', 'confirm'),('type', '!=', 'bank')]}"/>
</xpath>