Search code examples
odooodoo-10odoo-12

ODOO Element cannot be located in parent view


I m trying to compile a module but it shows me this error

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>

I understand that the error is due to "sale_condition" that is not in the parent view. Can you help me by giving me an alternative, where can I add this group to make it work? Knowing that I can not change in the addons file

This group with the attribute 'sale_condition' is present in 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>

Solution

  • I think that you are trying to locate the group sale_condition of the view of Odoo 10 in Odoo 12, but that view group is not defined in that stock.view_template_property_form view of Odoo 12. Are you porting a module from Odoo 10 to Odoo 12?

    As you need that group just to locate a position in the view where you will include the fields taux_marge and marge_product I would just forget about sale_condition and use developer mode in Odoo 12 to locate a new position relative to the groups/fields/etc that really exists in the view of Odoo 12, for example after pricelist trying something like:

            <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>