【问题标题】:ODOO Element cannot be located in parent viewODOO 元素不能位于父视图中
【发布时间】:2019-03-22 15:22:30
【问题描述】:

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

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>

【问题讨论】:

  • 什么是父视图?你确定这个带有name="sale_condition" 属性的group 在里面吗?您能否添加您尝试继承的父视图。
  • @CZoellner 感谢您的回复。但是这个[组]在父视图中不存在(view_template_property_form 在odoo/addons/stock/views/product_view)所以我应该用这个属性“sale_condition”添加这个组。我想知道我应该什么时候准确地添加它。
  • 如果它不存在,你要么继承另一个视图,要么找到另一个位置来添加你的东西。您能否分享 Odoo 版本,并在可能的情况下用它标记问题?如果不可能,我会去做。
  • @CZoellner 我正在使用 odoo 12。你能帮我找到另一个职位来添加我的群组吗?例如,我可以在哪里添加它?
  • 这很难决定。它取决于已经存在的视图扩展/继承。对我来说,您的扩展必须放置在产品表单视图的销售或帐户选项卡中。两者都带有salesale_stock 和/或account 模块、IIRC 的扩展。所以你必须研究他们的扩展。不要忘记将依赖项添加到您的模块清单中。

标签: odoo odoo-10 odoo-12


【解决方案1】:

我认为您正在尝试在 Odoo 12 中找到 Odoo 10 视图的组 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>

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 感谢您的回复。我在插件中找不到。我应该在哪里使用属性“sale_condition”添加这个组
    • 您使用的是哪个 odoo 版本?检查您的自定义插件,可能创建了 sale_condition 组
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-02
    相关资源
    最近更新 更多