Inheritance is a mechanism in Object Oriented Programming that allows the utilization and acquisition of all the properties, methods, and views of a class in a newly created class or model.
2. Inheritance is a mechanism in Object Oriented Programming
that allows the utilization and acquisition of all the
properties, methods, and views of a class in a newly created
class or model. This concept enables the creation of new
classes that inherit the characteristics and behaviors of
existing ones, making it possible to build upon existing code
and maintain a more organized and efficient codebase.
3. ● Here we can see a class ‘AccountCommonJournalReport’ with
the name attribute set as ‘account.common.journal.report’.
● This will create a new table in the database for the new model
account.common.journal.report
4. ● Here we can also see the inherit attribute is used for the class
definition. which means this class also inherits an another class that is
account.common.report
● As a result the model account.common.journal.report includes all the
properties from the parent class also.
● That is, all fields and methods from the model account.common.report
can be accessed from this new model.
● It’s also possible to create new fields and methods inside the new
model
5.
6. ● In the image given above, we can see a new field ‘amount_currency’ is created in
the table account.common.journal.report
● As a result traditional prototype inheritance enables to create a new model from a
base model without affecting the parent model.
● In this example, here a new table account.common.journal.report is created
without affecting the parent model account.common.report .
7. Check our company website
for related blogs and Odoo book.
Check our YouTube channel for
functional and technical videos in Odoo.