Skip to Content
Menu
This question has been flagged
2 Replies
7545 Views

Hi guys!

I've created a many2many field in the sale.order model that it's related with fleet.vehicle model (id).

How it's showed in the follow image:


IMAGE 1: http://es.zimagez.com/zimage/defm2m.php


Well, the 'x_vehiculo' field is a multi-selection fieldHow it's showed in the follow image:


IMAGE 2: http://es.zimagez.com/zimage/m2mmulti.php


The idea is that for each sale order i can to store more that 1 vehicle.

The trouble is that i can't see the value for of x_vehiculo' field for each sale order when i make a query in the SGB Postgresql (PgAdmin III).


IMAGE 3: http://es.zimagez.com/zimage/salida2.php


There is any way to can retrieve values of 'x_vehicle' multi-selection field for each sale.order?


Please if somebody could help me. I'd be very gratefull.

Thanks you so much


Avatar
Discard
Best Answer

Hi,

In your case the values of the records will be stored in the : x_fleet_vehicle_sale_order_rel. so you can query this table to get the result or make a JOIN to this table to get the data you want.

Also if you have a recordset [browse record] you can access these records directly as:

sale_object.x_vehiculo; this will return a recordset of the vehicles in the relation ...

Hope this could helps

Avatar
Discard
Best Answer

James, many2many records are stored in a seperate table..

While creating many2many field, if u remember the structure,

x_vehiculo = fields.many2many('fleet.vehicle', '<NEW_TABLE>', 'sale_id', 'vehicle_id', '<STRING>')

your structure must be something like this.....

here, <New Table> is the table on which u can query to get records and sale_id is id for sale.order and vehicle_id is for fleet.vehicle, like:
"select vehicle_id from <NEW_TABLE> where sale_id = <ID>";

hope it help!!!

Avatar
Discard