Odoo Help


Why can relate two fields one2many?

on 1/14/14, 5:05 PM 1,412 views

Hi guys, have a query, i write a OpenERP v7 module to workshop, i have a object class 'vehicle' and another object 'service', actually, each vehicle can have many services, through a one2many relational field in object 'vehicle', but I also need to do the opposite, I mean several vehicles relate to each service


Timo Talvitie, Vizucom Oy

--Timo Talvitie, Vizucom Oy--
| 5 4 7
Tampere, Finland
--Timo Talvitie, Vizucom Oy--

Lead developer at Vizucom.

Timo Talvitie, Vizucom Oy
On 1/14/14, 6:20 PM

Sounds like you should use a many2many relation for this: each of your vehicles can be linked to X services, and each of your services can be linked to Y vehicles. Try using the following fields:

In your vehicle class:


And in your service class the same thing but in reverse:

    'service_rel', # same relation still
    'service_id', # ...but fields of the relation now go in different order

The documentation has some notes on m2m usage here: https://doc.openerp.com/trunk/server/03_module_dev_02/

Thanks u! that is the right way, it works 100%! you are great!

on 1/14/14, 7:35 PM

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

0 follower(s)


Asked: 1/14/14, 5:05 PM
Seen: 1412 times
Last updated: 3/16/15, 8:10 AM