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
- 会計
- 在庫
- PoS
- プロジェクト
- MRP
この質問にフラグが付けられました
1
返信
6286
ビュー
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!
| 関連投稿 | 返信 | ビュー | 活動 | |
|---|---|---|---|---|
|
|
4
10月 21
|
10076 | ||
|
|
2
2月 21
|
13756 | ||
|
|
1
9月 17
|
5050 | ||
|
|
0
4月 16
|
9 | ||
|
|
2
2月 24
|
2389 |