← Back to team overview

openerp-india team mailing list archive

[Bug 927817] [NEW] _is_osv_memory (6.1 Trunk)

 

Public bug reported:

In ir_model.py
classe ir_model

    def _is_osv_memory(self, cr, uid, ids, field_name, arg, context=None):
        models = self.browse(cr, uid, ids, context=context)
        res = dict.fromkeys(ids)
        for model in models:
            res[model.id] = self.pool.get(model.model).is_transient()
        return res

If you create a new model, test it, and finaly you remove it, model now
removed from ir_model table, so when we try to configure group this
function is called and browse all id result of this error :
AttributeError: 'NoneType' object has no attribute 'is_transient'

Because the model in ir_model table NOT IN self.pool because we remove
it from code, and not remove from database.

maybe add something like that to validate

for model in models:
    res[model.id] = self.pool.get(model.model) and self.pool.get(model.model).is_transient() or False

or
for model in models:
    obj =  self.pool.get(model.model)
    res[model.id] = obj and obj.is_transient() or False

** Affects: openobject-addons
     Importance: Undecided
         Status: New

** Description changed:

  In ir_model.py
  classe ir_model
  
-     def _is_osv_memory(self, cr, uid, ids, field_name, arg, context=None):
-         models = self.browse(cr, uid, ids, context=context)
-         res = dict.fromkeys(ids)
-         for model in models:
-             res[model.id] = self.pool.get(model.model).is_transient()
-         return res
+     def _is_osv_memory(self, cr, uid, ids, field_name, arg, context=None):
+         models = self.browse(cr, uid, ids, context=context)
+         res = dict.fromkeys(ids)
+         for model in models:
+             res[model.id] = self.pool.get(model.model).is_transient()
+         return res
  
- 
- If you create a new model, test it, and finaly you remove it, model now removed from ir_model table, so when we try to configure group this function is called and browse all id result of this error : AttributeError: 'NoneType' object has no attribute 'is_transient'
+ If you create a new model, test it, and finaly you remove it, model now
+ removed from ir_model table, so when we try to configure group this
+ function is called and browse all id result of this error :
+ AttributeError: 'NoneType' object has no attribute 'is_transient'
  
  Because the model in ir_model table NOT IN self.pool because we remove
  it from code, and not remove from database.
  
  maybe add something like that to validate
  
  for model in models:
-     res[model.id] = self.pool.get(model.model) and self.pool.get(model.model).is_transient() or False
+     res[model.id] = self.pool.get(model.model) and self.pool.get(model.model).is_transient() or False
  
  or
  for model in models:
-     obj =  self.pool.get(model.model)
-     res[model.id] = obj and obj.is_transient() or False
+     obj =  self.pool.get(model.model)
+     res[model.id] = obj and obj.is_transient() or False

** Summary changed:

- _is_osv_memory
+ _is_osv_memory (6.1 Trunk)

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/927817

Title:
  _is_osv_memory (6.1 Trunk)

Status in OpenERP Addons (modules):
  New

Bug description:
  In ir_model.py
  classe ir_model

      def _is_osv_memory(self, cr, uid, ids, field_name, arg, context=None):
          models = self.browse(cr, uid, ids, context=context)
          res = dict.fromkeys(ids)
          for model in models:
              res[model.id] = self.pool.get(model.model).is_transient()
          return res

  If you create a new model, test it, and finaly you remove it, model
  now removed from ir_model table, so when we try to configure group
  this function is called and browse all id result of this error :
  AttributeError: 'NoneType' object has no attribute 'is_transient'

  Because the model in ir_model table NOT IN self.pool because we remove
  it from code, and not remove from database.

  maybe add something like that to validate

  for model in models:
      res[model.id] = self.pool.get(model.model) and self.pool.get(model.model).is_transient() or False

  or
  for model in models:
      obj =  self.pool.get(model.model)
      res[model.id] = obj and obj.is_transient() or False

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/927817/+subscriptions


Follow ups

References