如何解决 Uncaught Promise > Odoo 16 中 owl 生命周期发生错误(请参阅此错误的“原因”属性)?

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

我试图通过继承表单视图来禁用

create,edit
表单视图中的
sale.order
。这是代码。

销售.order_view.xml

<record id="view_order_form_inherit_custom" model="ir.ui.view">
    <field name="name">sale.order.inherit</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
                <form position="attributes">
                        <attribute name="edit">false</attribute>
                        <attribute name="create">false</attribute>
                </form>
           </field>
       </record>

实际上这段代码工作正常,它禁用了销售订单视图中的创建和编辑功能。 但是当我点击“其他信息”选项卡时,我收到了下面提到的错误。我不知道为什么以及如何发生这种奇怪的行为? 当我评论上面的代码时,错误就消失了。

我该如何解决这个问题?

这是错误:

                UncaughtPromiseError > OwlError
            Uncaught Promise > An error occured in the owl lifecycle (see this Error's "cause" property)
            OwlError: An error occured in the owl lifecycle (see this Error's "cause" property)
                OwlError@http://localhost:5014/web/assets/debug/web.assets_common.js:16481:5 (/web/static/lib/owl/owl.js:87)
                handleError@http://localhost:5014/web/assets/debug/web.assets_common.js:16518:35 (/web/static/lib/owl/owl.js:124)
                handleError@http://localhost:5014/web/assets/debug/web.assets_common.js:22093:20 (/web/static/lib/owl/owl.js:5699)
                _render@http://localhost:5014/web/assets/debug/web.assets_common.js:18013:30 (/web/static/lib/owl/owl.js:1619)
                render@http://localhost:5014/web/assets/debug/web.assets_common.js:18002:18 (/web/static/lib/owl/owl.js:1608)
                initiateRender@http://localhost:5014/web/assets/debug/web.assets_common.js:18741:23 (/web/static/lib/owl/owl.js:2347)

            Caused by: TypeError: this.options.find(...) is undefined
                get string@http://localhost:5014/web/assets/debug/web.assets_backend.js:37198:36 (/web/static/src/views/fields/selection/selection_field.js:28)
                template@http://localhost:5014/web/assets/debug/web.assets_common.js line 21874 > Function:15:18 (/web/static/lib/owl/owl.js:5480)
                _render@http://localhost:5014/web/assets/debug/web.assets_common.js:18010:38 (/web/static/lib/owl/owl.js:1616)
                render@http://localhost:5014/web/assets/debug/web.assets_common.js:18002:18 (/web/static/lib/owl/owl.js:1608)
                initiateRender@http://localhost:5014/web/assets/debug/web.assets_common.js:18741:23 (/web/static/lib/owl/owl.js:2347)
odoo odoo-16
1个回答
0
投票

您能否提供错误消息中提供的链接的内容:特别是第28行:http://localhost:5014/web/assets/debug/web.assets_backend.js:37198:36 (/web/static/ src/views/fields/selection/selection_field.js

否则...因为错误告诉我们js脚本没有找到看起来依赖于按钮的东西:

this.options.find(...) is undefined

您可以使用另一种方法,保留按钮,但通过继承视图 sale.view_order_form 使其不可见:

    <record id="sale_order_view_form_btncreate_inv" model="ir.ui.view">
        <field name="name">sale.order.form.btncreateinv</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
           <xpath expr="//button[@id='create_invoice']" position="attributes">
             <attribute name="attrs">{'invisible': True}</attribute> 
           </xpath>
        </field>
    </record>

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