Copying the model definition using inheritance
We saw class inheritance (extension) in the previous recipe. Now, we will see prototype inheritance, which is used to copy the entire definition of the existing model. In this recipe, we will make a copy of the hostel.room model.
Getting ready
We will continue using the my_hostel add-on module from the previous recipe.
How to do it...
Prototype inheritance is executed by using the _name and _inherit class attributes at the same time. Perform the following steps to generate a copy of the hotel.room model:
- Add a new file called 
hostel_room_copy.pyto the/my_hostel/models/directory. - Add the following content to the 
hostel_room_copy.pyfile:from odoo import fields, models, api, _ class HostelRoomCopy(models.Model): Â Â Â _name = "hostel.room.copy" Â Â Â _inherit="hostel.room" Â Â Â _description = "Hostel Room Information Copy"
 - Import a new file reference...