From f73652cc5caa396bffca46701babdf2f06a86917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 7 Jul 2009 19:37:19 +0200 Subject: [PATCH] Fix the use of rowcount because it can return -1 or None according to PEP249 --- fiscalyear.py | 2 +- party.py | 2 -- period.py | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/fiscalyear.py b/fiscalyear.py index e0ec0bd29a..db8a4eaf1f 100644 --- a/fiscalyear.py +++ b/fiscalyear.py @@ -91,7 +91,7 @@ class FiscalYear(ModelSQL, ModelView): fiscalyear.end_date, fiscalyear.end_date, fiscalyear.start_date, fiscalyear.end_date, fiscalyear.company.id, fiscalyear.id)) - if cursor.rowcount: + if cursor.fetchone(): return False return True diff --git a/party.py b/party.py index 00d7a96c47..e54f50312c 100644 --- a/party.py +++ b/party.py @@ -165,8 +165,6 @@ class Party(ModelSQL, ModelView): 'AND'.join(['(SUM((COALESCE(l.debit, 0) - COALESCE(l.credit, 0))) ' \ + ' ' + x[1] + ' %s) ' for x in args]), [code] + today_value + [company_id] + [x[2] for x in args]) - if not cursor.rowcount: - return [('id', '=', 0)] return [('id', 'in', [x[0] for x in cursor.fetchall()])] Party() diff --git a/period.py b/period.py index 09a1d43644..677be72feb 100644 --- a/period.py +++ b/period.py @@ -85,7 +85,7 @@ class Period(ModelSQL, ModelView): period.end_date, period.end_date, period.start_date, period.end_date, period.fiscalyear.id, period.id)) - if cursor.rowcount: + if cursor.fetchone(): return False return True