Odoo 9 Empty Tree View
<p>I have created a new model and added a tree view to edit/view it on the res.partner view.</p>

<p>I can create entries no problem and they appear in the database. I cannot however get the tree view to display any data at all. Even with the filters removed.</p>

<p>Here is the view xml</p>

<pre><code>&lt;page string="Projects/Training"&gt;
    &lt;field name="training_logs" context="{'default_tl_partner_id': active_id}" domain="[('tl_partner_id','=',active_id)]"&gt;
        &lt;tree string="Training Logs" editable="top"&gt;
            &lt;field name="tl_partner_id" invisible="1"/&gt;
            &lt;field name="tl_date"/&gt;
            &lt;field name="tl_trainer"/&gt;
            &lt;field name="tl_present"/&gt;
            &lt;field name="tl_summary"/&gt;
        &lt;/tree&gt;
    &lt;/field&gt;
&lt;/page&gt;
</code></pre>

<p>Model Structure as requested</p>

<pre><code>class training_log(osv.Model):
_name='training.log'
_description='Log of past training events'
_order='tl_date'
_columns = {
    'tl_partner_id': fields.many2one('res.partner', 'Customer'),
    'tl_date': fields.date("Training Date"),
    'tl_trainer': fields.many2one('res.users', 'Trainer'),
    'tl_present': fields.char('People Present'),
    'tl_summary': fields.text('Training Summary')
}
</code></pre>

<p>res.partner - I have left out all my non related fields.</p>

<pre><code>class res_partner(osv.osv):
_inherit = "res.partner"
_columns = {

    'training_logs': fields.one2many('training.log','id','Training Logs'),



}
</code></pre>

<p>When we define <em>one2many</em> field, we need to give proper <em>many2one</em> field name.</p>

<p>In your case, you have given <em>id</em> which means it will take currently record not for as you have created new object <em>training.log</em></p>

<p>Try with following code:</p>

<p>Replace</p>

<pre><code>'training_logs': fields.one2many('training.log','id','Training Logs'),
</code></pre>

<p>with</p>

<pre><code>'training_logs': fields.one2many('training.log','tl_partner_id','Training Logs'),
</code></pre>

<p>Afterwards, restart Odoo server and upgrade module.</p>

python xml openerp odoo-9