Skip to Content
Menu
This question has been flagged
1 Reply
2600 Views

I have made the new module followed by the tutorial in odoo documentation. But when I made view inheritance, i have an error like this

ParseError: "Error while validating constraint

Field `session_ids` does not exist

Error context:
View `partner.instructor`
[view_id: 228, xml_id: n/a, model: res.partner, parent_id: 124]
None" while parsing file:///d:/addons/openacademy/views/partner.xml:5, near
<record model="ir.ui.view" id="partner_instructor_form_view">
            <field name="name">partner.instructor</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <notebook position="inside">
                    <page string="Sessions">
                        <group>
                            <field name="instructor"/>
                            <field name="session_ids"/>
                        </group>
                    </page>
                </notebook>
            </field>
        </record>

I have to import partner in __init__.py and add views/partner.xml in __manifest__.py
Please check the script i have made and tell the error.

partner.py

from odoo import modelds, fields, api class Partner(models.Model): _inherit = 'res.partner' # Add a new column to the res.partner model, by default partners are not # instructors instructor = fields.Boolean("Instructor", default=False) session_ids = fields.Many2many('openacademy.session', string="Attended Sessions", readonly=True)

partner.xml

<odoo> <data> <!-- Add instructor field to existing view --> <record model="ir.ui.view" id="partner_instructor_form_view"> <field name="name">partner.instructor</field> <field name="model">res.partner</field> <field name="inherit_id" ref="base.view_partner_form"/> <field name="arch" type="xml"> <notebook position="inside"> <page string="Sessions"> <group> <field name="instructor"/> <field name="session_ids"/> </group> </page> </notebook> </field> </record> <record model="ir.actions.act_window" id="contact_list_action"> <field name="name">Contacts</field> <field name="res_model">res.partner</field> <field name="view_mode">tree,form</field> </record> <menuitem id="configuration_menu" name="Configuration" parent="main_openacademy_menu"/> <menuitem id="contact_menu" name="Contacts" parent="configuration_menu" action="contact_list_action"/> </data> </odoo>

Thank you in advance
Avatar
Discard

did you restart your service?

May be you forgot to make an update /restart to your module

Best Answer

did you manage to solve your issue? Im facing the same problem...

Avatar
Discard