跳至內容
選單
此問題已被標幟
1 回覆
4022 瀏覽次數

V7


class hotel_room_amenities_type(osv.osv):

_name = 'hotel.room_amenities_type'

_description = 'amenities Type'

_inherits = {'product.category':'cat_id'}

_columns = {

'cat_id':fields.many2one('product.category', 'category', required=True, ondelete='cascade'),

}

_defaults = {

'isamenitype': lambda * a: 1,

}


class product_category(osv.osv):

_inherit = "product.category"

_columns = {

'isroomtype':fields.boolean('Is Room Type'),

'isamenitype':fields.boolean('Is amenities Type'),

'isservicetype':fields.boolean('Is Service Type'),

}

product_category()


V8


class HotelRoomAmenitiesType(models.Model):  
 _name = 'hotel.room.amenities.type' _description = 'amenities Type'
 cat_id = fields.Many2one('product.category', 'category', required=True, delegate=True, ondelete='cascade')

頭像
捨棄
最佳答案

Hello Dep,


_inherits means you can access all the fields from existing class but in database, there is create a new table for it.

For Ex:-

In your custom class hotel_room_amenities_type, you can access all the fields from the product.category but in database there is create new table for your class.

In your custom class, you may give the many2one fields for existing models is compulsory.


_inherit means you extend the existing model.


Thanks,

頭像
捨棄
作者

Thanks.....

相關帖文 回覆 瀏覽次數 活動
1
2月 21
2135
1
11月 24
874
0
3月 22
2391
1
8月 21
9447
1
4月 17
5496