From 7abed3b9961c0bd337fb9c054a1b27cf7ffbebdb Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Thu, 11 Aug 2016 16:35:48 +0200 Subject: [PATCH] [IMP] all: remove unreachable code This commits adds the check W0101 to test_pylint and fixes the errors. The index in sequence.py was added in rev 1381ac139ed33e858ae6af34f61d04becbcc06bf and cancelled a day later in 83fdc271e6c0606dd91d266680a81b9596da27fa so i guess it is safe to remove it. --- addons/mail/models/mail_template.py | 1 - addons/rating/controllers/main.py | 1 - openerp/addons/base/ir/ir_sequence.py | 17 ----------------- openerp/addons/test_pylint/tests/test_pylint.py | 1 + 4 files changed, 1 insertion(+), 19 deletions(-) diff --git a/addons/mail/models/mail_template.py b/addons/mail/models/mail_template.py index eb0abe16a06..8508fa9f250 100644 --- a/addons/mail/models/mail_template.py +++ b/addons/mail/models/mail_template.py @@ -361,7 +361,6 @@ class MailTemplate(models.Model): except Exception: _logger.info("Failed to render template %r using values %r" % (template, variables), exc_info=True) raise UserError(_("Failed to render template %r using values %r")% (template, variables)) - render_result = u"" if render_result == u"False": render_result = u"" results[res_id] = render_result diff --git a/addons/rating/controllers/main.py b/addons/rating/controllers/main.py index cbd28e175aa..1bae7d13874 100644 --- a/addons/rating/controllers/main.py +++ b/addons/rating/controllers/main.py @@ -26,7 +26,6 @@ class Rating(http.Controller): 'rating': rating, 'token': token, 'rate_name': rate_names[rate], 'rate': rate }) - return request.not_found() @http.route(['/rating///submit_feedback'], type="http", auth="public", method=['post']) def submit_rating(self, token, rate, **kwargs): diff --git a/openerp/addons/base/ir/ir_sequence.py b/openerp/addons/base/ir/ir_sequence.py index a6997836c19..28dd8cb1857 100644 --- a/openerp/addons/base/ir/ir_sequence.py +++ b/openerp/addons/base/ir/ir_sequence.py @@ -112,23 +112,6 @@ class IrSequence(models.Model): use_date_range = fields.Boolean(string='Use subsequences per date_range') date_range_ids = fields.One2many('ir.sequence.date_range', 'sequence_id', string='Subsequences') - @api.model_cr - def init(self): - return # Don't do the following index yet. - - # CONSTRAINT/UNIQUE INDEX on (code, company_id) - # /!\ The unique constraint 'unique_name_company_id' is not sufficient, because SQL92 - # only support field names in constraint definitions, and we need a function here: - # we need to special-case company_id to treat all NULL company_id as equal, otherwise - # we would allow duplicate (code, NULL) ir_sequences. - self._cr.execute(""" - SELECT indexname FROM pg_indexes WHERE indexname = - 'ir_sequence_unique_code_company_id_idx'""") - if not self._cr.fetchone(): - self._cr.execute(""" - CREATE UNIQUE INDEX ir_sequence_unique_code_company_id_idx - ON ir_sequence (code, (COALESCE(company_id,-1)))""") - @api.model def create(self, values): """ Create a sequence, in implementation == standard a fast gaps-allowed PostgreSQL sequence is used. diff --git a/openerp/addons/test_pylint/tests/test_pylint.py b/openerp/addons/test_pylint/tests/test_pylint.py index ae4415dca1c..251db1f6eba 100644 --- a/openerp/addons/test_pylint/tests/test_pylint.py +++ b/openerp/addons/test_pylint/tests/test_pylint.py @@ -23,6 +23,7 @@ class TestPyLint(TransactionCase): ENABLED_CODES = [ 'W0123', # eval used + 'W0101', # unreachable code ] def _skip_test(self, reason):