Search code examples
pythonpython-3.xodooodoo-13

Odoo13 tree view show only one column


I had a tree view xml which consists of the below code.

<record model="ir.ui.view" id="access_view_tree">
    <field name="name">Access tree</field>
    <field name="model">ka.access.rel</field>
    <field name="arch" type="xml">
        <tree string="Tree view" >
            <field name="id_ra_access"/>
            <field name="id_res_partner"/>
            <field name="partner_type"/>
        </tree>
    </field>
</record>

Has a Model as below.

_name = 'ka.access.rel'
_description = 'KA Partner REL'

id_ra_access = fields.Many2one('ra.access', "Access", required=True, ondelete='cascade', index=True)
id_res_partner = fields.Many2one('res.partner', "Partner", required=True)
partner_type = fields.Selection([('1', 'Primary'), ('2', 'Secondary')], 'Partner Type', required=True, default=2)

_rec_name = 'id'

_defaults = {
    "partner_type": '2'
}

I could see only Form view is having all the three fields. In tree view, I could see only one Column "ID"

Tree View Image


Solution

  • It is the default tree view, your tree view definition was not loaded, If Odoo try to load it, it will raise a ValidationError because field id_ra_Access is not defined:

    odoo.exceptions.ValidationError: ('Error while validating view\n\nField `id_ra_Access` does not exist\n\nError context:\nView `Access tree`.
    

    Check the manifest file and make sure to add the XML file (where you defined the tree view definition) to the data entry and use id_ra_access field name instead of id_ra_Access.