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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilitat
- Inventari
- PoS
- Projectes
- MRP
This question has been flagged
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:
'service_ids':
fields.many2many(
'mymodule.service',
'service_rel',
'vehicle_id',
'service_id',
'Services'),
And in your service class the same thing but in reverse:
'vehicle_ids':
fields.many2many(
'mymodule.vehicle',
'service_rel', # same relation still
'service_id', # ...but fields of the relation now go in different order
'vehicle_id',
'Vehicles'),
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!
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Registrar-se| Related Posts | Respostes | Vistes | Activitat | |
|---|---|---|---|---|
|
|
4
d’oct. 21
|
10085 | ||
|
|
2
de febr. 21
|
13761 | ||
|
|
1
de set. 17
|
5058 | ||
|
|
0
d’abr. 16
|
9 | ||
|
|
2
de febr. 24
|
2397 |