0

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>
omas
  • 69
  • 1
  • 12
  • What is the parent view? Are you sure this `group` with attribute `name="sale_condition"` is in it? Could you please add the parent view you are trying to inherit. – CZoellner Mar 22 '19 at 16:14
  • @CZoellner thanks for your response. But this [group] doesn't exist in the parent view (view_template_property_form wich is in odoo/addons/stock/views/product_view) So I should add this group with this attribute "sale_condition". I want to know when should I add it exactly. – omas Mar 25 '19 at 08:50
  • If it isn't there you either inherit another view or find another position to add your stuff. Could you please share the Odoo version, and if possible tag the question with it? If not possible, i will do it. – CZoellner Mar 25 '19 at 08:52
  • @CZoellner I m using odoo 12. Can you please help me to find the other position to add my group. Where can I add it for example? – omas Mar 25 '19 at 09:05
  • That's difficult to decide. It depends on the already present view extensions/inherits. For me your extensions has to be placed either in the sales or the account tab of the product form view. Both come with extensions by `sale`, `sale_stock` and/or `account` module, IIRC. So you have to look into their extensions. Don't forget to add the dependencies to your module manifest. – CZoellner Mar 25 '19 at 09:35
  • Thank you for your suggestions. I just noticed that this group is in odoo 10 but not in odoo12. Perhaps it is replaced by another name. – omas Mar 25 '19 at 14:38
  • Or the view has changed much more. – CZoellner Mar 25 '19 at 14:40

2 Answers2

1

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>
Victor G.
  • 121
  • 5
0

You can inherit view where group name="sale_condition" is created

Jack Sparrow
  • 628
  • 8
  • 20
  • Thanks for your response. I can't found it in the addons. Where should I add this group with attribute "sale_condition" – omas Mar 25 '19 at 09:01
  • Which odoo version you are using ? Check in your custom addons maybe there is sale_condition group is created – Jack Sparrow Mar 25 '19 at 15:55