Browse Source

[IMP] Safe way to get instanciated models (fixes test)

pull/68/head
Stefan Rijnhart 9 years ago
parent
commit
b9bb1c71dd
  1. 13
      base_phone/base_phone.py

13
base_phone/base_phone.py

@ -198,18 +198,13 @@ class PhoneCommon(models.AbstractModel):
def _get_phone_fields(self): def _get_phone_fields(self):
'''Returns a dict with key = object name '''Returns a dict with key = object name
and value = list of phone fields''' and value = list of phone fields'''
models = self.env['ir.model'].search([('osv_memory', '=', False)])
res = [] res = []
for model in models:
senv = False
try:
senv = self.env[model.model]
except:
continue
for model_name in self.env.registry:
senv = self.env[model_name]
if ( if (
'_phone_fields' in dir(senv) and
getattr(senv, '_phone_fields', None) and
isinstance(senv._phone_fields, list)): isinstance(senv._phone_fields, list)):
res.append(model.model)
res.append(model_name)
return res return res
def click2dial(self, cr, uid, erp_number, context=None): def click2dial(self, cr, uid, erp_number, context=None):

Loading…
Cancel
Save