ODOO元素无法位于父视图中

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

我正在尝试编译模块,但它向我显示了这个错误

Element '<group name="sale_condition">' cannot be located in parent view

Error context:
View `product.template.only.form.view.marge`
[view_id: 1240, xml_id: n/a, model: product.template, parent_id: 560]
None" while parsing /home/PycharmProjects/account_invoice_margin/views/product_view.xml:4, near
<record id="product_template_only_form_view_marge" model="ir.ui.view">
            <field name="name">product.template.only.form.view.marge</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="stock.view_template_property_form"/>
            <field name="arch" type="xml">
                <group name="sale_condition" position="inside">
                    <label for="taux_marge" groups="account_invoice_margin.group_margin_security"/>
                    <div groups="account_invoice_margin.group_margin_security">
                        <field name="taux_marge" class="oe_inline"/>
                    </div>
                    <label for="marge_product" groups="account_invoice_margin.group_margin_security"/>
                    <div groups="account_invoice_margin.group_margin_security">
                        <field name="marge_product" class="oe_inline"/>
                    </div>
                </group>
            </field>
        </record>

我知道错误是由于“sale_condition”不在父视图中。你能给我一个替代方案来帮助我吗?我可以在哪里添加这个组以使其有效?知道我无法更改插件文件

具有属性'sale_condition'的该组存在于odoo 10 mais pas dans odoo 12中。

<group name="sale_condition" string="Sale Conditions">
                            <label for="warranty" groups="stock.group_production_lot"/>
                            <div groups="stock.group_production_lot">
                                <field name="warranty" class="oe_inline"/> months
                            </div>
                            <label for="sale_delay"/>
                            <div>
                                <field name="sale_delay" attrs="{'readonly':[('sale_ok','=',False)]}" class="oe_inline" style="vertical-align:baseline"/> days
                            </div>
odoo odoo-10 odoo-12
2个回答
0
投票

我认为您正在尝试在Odoo 12中找到Odoo 10视图的group sale_condition,但该视图组未在Odoo 12的stock.view_template_property_form视图中定义。您是否将模块从Odoo 10移植到Odoo 12?

由于您需要该组只是为了在视图中找到您将包含字段taux_marge和marge_product的位置,我将忘记sale_condition并使用Odoo 12中的开发人员模式来找到相对于组/字段/等的新位置存在于Odoo 12的视图中,例如在价格表尝试之后:

        <xpath expr="//group[@name='pricelists']" position="after">
            <group name="marge" string="Marge">
                <group>
                    <label for="taux_marge" groups="account_invoice_margin.group_margin_security"/>
                    <div groups="account_invoice_margin.group_margin_security">
                        <field name="taux_marge" class="oe_inline"/>
                    </div>
                    <label for="marge_product" groups="account_invoice_margin.group_margin_security"/>
                    <div groups="account_invoice_margin.group_margin_security">
                        <field name="marge_product" class="oe_inline"/>
                    </div>
                </group>
            </group>
        </xpath>

0
投票

您可以继承创建group name =“sale_condition”的视图

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