From 96a66a8ead0e7d5ced69858bb133fffdeca54148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 21 Mar 2021 16:09:13 +0100 Subject: [PATCH] Replace cursor fetchall by iteration over cursor issue5817 review335831003 --- payment.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/payment.py b/payment.py index ca6a3ab996..1c2c3ea522 100644 --- a/payment.py +++ b/payment.py @@ -656,7 +656,7 @@ class Mandate(Workflow, ModelSQL, ModelView): cursor.execute(*payment.select(payment.sepa_mandate, Literal(True), where=red_sql, group_by=payment.sepa_mandate)) - has_payments.update(cursor.fetchall()) + has_payments.update(cursor) return {'has_payments': has_payments} @@ -768,7 +768,9 @@ class Message(Workflow, ModelSQL, ModelView): def __register__(cls, module_name): pool = Pool() Group = pool.get('account.payment.group') - cursor = Transaction().connection.cursor() + transaction = Transaction() + cursor = transaction.connection.cursor() + update = transaction.connection.cursor() table = cls.__table__() super(Message, cls).__register__(module_name) @@ -780,8 +782,8 @@ class Message(Workflow, ModelSQL, ModelView): group = Group.__table__() cursor.execute(*group.select( group.id, group.sepa_message, group.company)) - for group_id, message, company_id in cursor.fetchall(): - cursor.execute(*table.insert( + for group_id, message, company_id in cursor: + update.execute(*table.insert( [table.message, table.type, table.company, table.origin, table.state], [[