4
votes

When creating class sometimes use osv.osv, also we use models.Model What is the basic difference between these two? Is there any advantages over another?

2

2 Answers

9
votes

Before version 7,

osv is a class and an OpenERP descriptor class and all the class( model) must inherit it for OpenERP module deployment.

osv class inside in OSV module in OpenERP server , which content all the OpenERP properties like you can see _column, _defaults and other many things there such as nameetc so we must inherit in our openerp model (class)

In version 7,

The ORM, short for Object-Relational Mapping, is a central part of OpenERP.

In OpenERP, the data model is described and manipulated through Python classes and objects. It is the ORM job to bridge the gap -- as transparently as possible for the developer -- between Python and the underlying relational database (PostgreSQL), which will provide the persistence we need for our objects.

osv.osv and orm.Model is deprecated and it still works for backward compatibility. You should use models.Model instead.

In version 8+,

The model transition was

osv.osv ---> orm.Model ---> models.Model

osv.TransientModel ---> orm.TransientModel ---> models.TransientModel

5
votes

The osv.osv was used in the former API. It is deprecated. it still works but should be avoided.

With the new API models.Model should be used.