Skip to Content
Menu
This question has been flagged
2 Replies
2070 Views

Hello, 

I am creating a custom view in Odoo13,  extending sale.view_order_tree, but get the following error message when installing the extension module i am working with.


odoo.exceptions.ValidationError: ('Error while validating view\n\nField `opportunity_id` does not exist\n\nError context:\nView `lco.sale.order.tree`\n[view_id: 1036, xml_id: n/a, model: sale.order, parent_id: 932]', None)


I had doubled check model sale.order to verify that field opportunity_id exisits, this is a field contained in sale.order standard table, even I created a new custom view using studio and it works as expected, shows opportuniy_id field.

Also I try with another field for the same table 'partner.id', and my custom view works perfectly, it only happens with opportunity_id field.


Here is the XML of my view.

<?xml version="1.0"?>
<odoo>
    <record id="lco_view_order_tree" model="ir.ui.view">
        <field name="name">lco.sale.order.tree</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_tree" />
        <field name="arch" type="xml">
            <field name="invoice_status" position="after">
                <field name="opportunity_id"/>
            </field>
        </field>
    </record>
</odoo>

Also I understood this field comes from crm.lead table in a many2one relationship, am i missing any specific detail for importing this kind of field?


Appreciate your help.

Avatar
Discard
Best Answer

I had the same problem recently with following the error message:

Field "opportunity_id" does not exist in model sale.order

The fix is simple: Add a dependency on sale_crm​ in your __manifest__.py​, as that module defines opportunity_id​ on the sale.order​ model, e.g.

{
'depends': [
'crm',
'sale',
'sale_crm',
],
}
Avatar
Discard
Best Answer
Try this:

<xpath expr="//field[@name='invoice_status']" position="after">
    <field name="opportunity_id"/> </xpath>
Avatar
Discard
Author

Thanks Gleb,

Unfortunately i get the same result. Are you able to view this field with above code?