Odoo Help


How to add field to res_partner in Odoo version 9

Trevor Nemanic
on 1/15/16, 6:16 PM 1,490 views

I want to add a field, job_ids, to res_partner in Odoo version 9. I added the field, restarted the Odoo service, and updated the app. However, the column does not appear in the database for res_partner, but it does for Jobs. If I add another column, like "test = fields.Char()" in res_partner it works. What is the issue with creating job_ids?

class res_partner(models.Model):

    _inherit = 'res.partner'

    job_ids = fields.One2many('fix_tribe.jobs', 'res_partner_id', string="Jobs")

class Jobs(models.Model):

    _name = 'fix_tribe.jobs'

    name = fields.Char()

    customer_id = fields.Many2one('fix_tribe.customers', string="Customer")

    res_partner_id = fields.Many2one('res.partner', string="ResPartner")

    isCompleted = fields.Boolean(string="Completed?")

    datetime_start = fields.Datetime(string="Start Date/Time")

    datetime_stop = fields.Datetime(string="Stop Date/Time")

    cost = fields.Float()

    jobitem_ids = fields.One2many('fix_tribe.job_items', 'name')

O Sluys
On 1/16/16, 3:16 AM

A one2many field doesn't create a new column in the table of the object. It's purpose is to easily browse the inverse relationship of a many2one field. In fact, no extra information needs to be encoded in the database for a one2many relationship because it can be inferred by querying the many2one relationship, and that's why an extra column is not needed for the res_partner table. The reason you are seeing the res_partner_id column in the jobs table is because of the many2one field you defined in the Jobs class.

In case you are wondering about many2many fields, you will also not see an extra column in the table for that relationship because it is represented by a separate table.

Do a search for relational database tutorials if you want to find out more about what happens on the database side.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/15/16, 6:16 PM
Seen: 1490 times
Last updated: 1/16/16, 3:16 AM