From ed364b012992af6263505483ce634a41e416bdcd Mon Sep 17 00:00:00 2001 From: JesusZapata Date: Mon, 30 Jan 2017 16:44:12 +0000 Subject: [PATCH] [FIX] Checking better the field_name OCA/pylint-odoo#109 --- pylint_odoo/checkers/no_modules.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pylint_odoo/checkers/no_modules.py b/pylint_odoo/checkers/no_modules.py index 692a3a81..ff78eeee 100644 --- a/pylint_odoo/checkers/no_modules.py +++ b/pylint_odoo/checkers/no_modules.py @@ -381,8 +381,14 @@ def visit_call(self, node): for argument in args: argument_aux = argument # Check this 'name = fields.Char("name")' - field_name = (argument.parent.parent.targets[0].name - .replace('_', ' ')) + field_name = '' + if (argument.parent and argument.parent.parent and + hasattr(argument.parent.parent, 'targets') and + argument.parent.parent.targets and + hasattr(argument.parent.parent.targets[0], + 'name')): + field_name = (argument.parent.parent.targets[0].name + .replace('_', ' ')) if (isinstance(argument, astroid.Const) and (index == FIELDS_METHOD.get(argument.parent.func.attrname, 0)) and