This question has been flagged
1 Reply
3507 Views

Hi,

I am creating one of the module for Hotel Management system.

The Class 'type_reservation' stores char values which should be displayed as drop down options.

I have taken a 'Many2one Relationship' and in the drop down but, instead of displaying fields of that module it is literally displaying the Name of corresponding module.

e.g. In many2one field 'type_id' instead of displaying values for types of reservation like Party, Buisness class, Individual, Group reservation etc.

It is displaying values like 'reservation,1','reservation,2','reservation,3', ..... and so on. 'reservation' is the name of the model which I have linked to many2one field.

Can someone plz help me get field names as drop down options.

Here is my code,

hotel_management.py-----------------------------------------------------------------------------------------------

class product_template(osv.Model):

_inherit="product.template"

_columns={

'is_a_room':fields.boolean("Is a Room?"),

}

class hotel_management(osv.Model):

_name="hotel.management"

_columns={

'customer_name':fields.char('Name of Customer',size=64),

'customer_contact':fields.char('Contact',size=50),

'credit_card':fields.char('Credit Card Number',size=64),

'check_in':fields.date("Check In Date"),

'check_out':fields.date("Check Out Date"),

'type_id':fields.many2one('reservation','Reserve many to one'),

}

class type_reservation(osv.Model):

_name="reservation"

_columns={

'type_name':fields.char('Type of Reservation',size=64),

}

Avatar
Discard
Best Answer

Hi Kapil,

Just put

_rec_name='type_name'

in 'reservation' model.

Hope this will help you.

OR

rename field "type_name" to "name".

value of field "name" is displayed in relational fields by default. if you want to use another field instead of default (name), then you've to set _rec_name to that fields name, as explained in the first option above.

Avatar
Discard
Author

Hey Jusab, It works ! Thanks for the solution.