From b9bb1c71dd916ca6e0ca7760eb648d9608cd4ee6 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Mon, 26 Oct 2015 16:07:15 +0100 Subject: [PATCH] [IMP] Safe way to get instanciated models (fixes test) --- base_phone/base_phone.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/base_phone/base_phone.py b/base_phone/base_phone.py index b63ad7c..cd32731 100644 --- a/base_phone/base_phone.py +++ b/base_phone/base_phone.py @@ -198,18 +198,13 @@ class PhoneCommon(models.AbstractModel): def _get_phone_fields(self): '''Returns a dict with key = object name and value = list of phone fields''' - models = self.env['ir.model'].search([('osv_memory', '=', False)]) 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 ( - '_phone_fields' in dir(senv) and + getattr(senv, '_phone_fields', None) and isinstance(senv._phone_fields, list)): - res.append(model.model) + res.append(model_name) return res def click2dial(self, cr, uid, erp_number, context=None):