1
votes

I have created a new model and added a tree view to edit/view it on the res.partner view.

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.

Here is the view xml

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

Model Structure as requested

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')
}

res.partner - I have left out all my non related fields.

class res_partner(osv.osv):
_inherit = "res.partner"
_columns = {

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



}
1
Please update your question with model structure.Bhavesh Odedra
where is model structure for res.partner object ?Bhavesh Odedra
As I mentioned above I already tried it with the filters off. I tried taking domain and context out again but the tree is still blank.Karl Hunt

1 Answers

1
votes

When we define one2many field, we need to give proper many2one field name.

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

Try with following code:

Replace

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

with

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

Afterwards, restart Odoo server and upgrade module.