From be4befb0e5b50f9d2cd8856948a1fe7a99c32533 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Thu, 17 Jul 2014 07:20:58 -0400 Subject: [PATCH] Tighten type check in domain Fixes #15 Check that `domain[2]` is `str` because in some cases it's an `int` and `list` operations don't work on `int`s. --- mass_editing/models/ir_model_fields.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mass_editing/models/ir_model_fields.py b/mass_editing/models/ir_model_fields.py index 7257910..d75e7f6 100644 --- a/mass_editing/models/ir_model_fields.py +++ b/mass_editing/models/ir_model_fields.py @@ -31,12 +31,14 @@ class IrModelFields(orm.Model): count=False): model_domain = [] for domain in args: - if domain[0] == 'model_id' and domain[2]\ - and type(domain[2]) != list: - model_domain += [( - 'model_id', 'in', map(int, domain[2][1:-1].split(',')))] + if (len(domain) > 2 and domain[0] == 'model_id' + and isinstance(domain[2], basestring)): + model_domain += [ + ('model_id', 'in', map(int, domain[2][1:-1].split(','))) + ] else: model_domain.append(domain) return super(IrModelFields, self).search( cr, uid, model_domain, offset=offset, limit=limit, order=order, - context=context, count=count) + context=context, count=count + )