[FIX] orm : fixed bug after imporved stuff of hasattr
authorHarry (Open ERP) <hmo@tinyerp.com>
Tue, 12 Jan 2010 11:50:44 +0000 (17:20 +0530)
committerHarry (Open ERP) <hmo@tinyerp.com>
Tue, 12 Jan 2010 11:50:44 +0000 (17:20 +0530)
bzr revid: hmo@tinyerp.com-20100112115044-443q61a9r3jlpkbj

bin/osv/osv.py

index 8fb5afa..f64763a 100644 (file)
@@ -194,10 +194,10 @@ class osv_memory(osv_base, orm.orm_memory):
     # Goal: try to apply inheritancy at the instanciation level and
     #       put objects in the pool var
     #
-    def createInstance(cls, pool, module, cr):
-        name = getattr(cls, '_name', cls._inherit)
+    def createInstance(cls, pool, module, cr):       
         parent_names = getattr(cls, '_inherit', None)
         if parent_names:
+            name = getattr(cls, '_name', cls._inherit)
             for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]):
                 parent_class = pool.get(parent_name).__class__
                 assert pool.get(parent_name), "parent class %s does not exist in module %s !" % (parent_name, module)
@@ -223,7 +223,7 @@ class osv(osv_base, orm.orm):
     #       put objects in the pool var
     #
     def createInstance(cls, pool, module, cr):
-        parent_names = getattr(cls, '_inherit', None)
+        parent_names = getattr(cls, '_inherit', None)        
         if parent_names:
             for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]):
                 parent_class = pool.get(parent_name).__class__
@@ -246,8 +246,8 @@ class osv(osv_base, orm.orm):
                                     new.append(c)
                         else:
                             new.extend(cls.__dict__.get(s, []))
-                    nattr[s] = new
-                name = getattr(cls, '_name', cls._inherit)
+                    nattr[s] = new                
+                name = hasattr(cls, '_name') and cls._name or cls._inherit                
                 cls = type(name, (cls, parent_class), nattr)
         obj = object.__new__(cls)
         obj.__init__(pool, cr)