Skip to Content
Menu
This question has been flagged
4 Replies
1664 Views

I am trying to extend the res.partner model so I can see a list of the 10 most recent tasks that have been 'Done' for a customer on their 'Contact' form.  I only want to see the following fields in the list of tasks:

  • name

  • date_start

  • date_end

I believe I need to create a One2many field that links 'res.partner' to 'project.task'.

I have tried the following:

collection_history_1 = fields.One2many(comodel_name='project.task', inverse_name='partner_id')

but when I load and update the module I get the following error:

  File "/home/odoo/odoo-server/odoo/fields.py", line 2234, in _setup_regular_full
    invf = comodel._fields[self.inverse_name]
KeyError: 'partner_id'


I obviously have little idea what I'm doing, but I'm hoping someone can point me in the right direction.

Thanks.

Avatar
Discard

Inheritance in model and views: https://goo.gl/fGNfBY

Author

@Sehrish - well, that's actually not very helpful for someone at my level as it doesn't say much at all about one2many field types, which is obviously what I'm struggling with here. This kind of answer is what makes this forum a very frustrating place sometimes. How about writing something that assists me in achieving the goal I described at the top of my question?

Best Answer

Hi,

Did you add the field partner_id in the project.task model ? If not inherit and add the partner_id field in project.task model.

For creating one2many field and to add it in the views, you can check this: https://www.youtube.com/watch?v=_O_tNBdg3HQ


Thanks

Avatar
Discard
Author

Thanks Niyas Raphy. The 'partner_id' field is an already existing many2one field in project.task model. Do I need to create a new field that references the existing field?