Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] pylint-odoo: Fix to calculate name of field, referrring to OCA/pylint-odoo#108 #108

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pylint_odoo/checkers/no_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,13 @@ 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('_', ' '))
if (isinstance(argument, astroid.Const) and
(index ==
FIELDS_METHOD.get(argument.parent.func.attrname, 0)) and
(argument.value.lower().replace(' ', '_') ==
argument.parent.parent.targets[0].name)):
(argument.value in
[field_name.capitalize(), field_name.title()])):
self.add_message('attribute-string-redundant', node=node)
if isinstance(argument, astroid.Keyword):
argument_aux = argument.value
Expand Down Expand Up @@ -444,8 +446,8 @@ def visit_call(self, node):
# Check if the param string is equal to the name
# of variable
elif argument.arg == 'string' and \
(argument.parent.parent.targets[0].name ==
argument.value.value.lower().replace(' ', '_')):
(argument.value.value in
[field_name.capitalize(), field_name.title()]):
self.add_message(
'attribute-string-redundant', node=node)
if isinstance(argument_aux, astroid.CallFunc) and \
Expand Down
5 changes: 5 additions & 0 deletions pylint_odoo/test_repo/broken_module/models/broken_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ class TestModel(models.Model):
"Many 2 Many Variable 2",
help="Help")

field_case_sensitive = fields.Char(
'Field Case SENSITIVE',
help="Field case sensitive"
)

name_equal_to_string = fields.Float(
"Name equal to string",
help="Name Equal To String"
Expand Down