From f8cc3cf46096c8a3545849ebfeb01a11c3211505 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 --- timesheet.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/timesheet.py b/timesheet.py index 99bf71aa55..85f1c2e799 100644 --- a/timesheet.py +++ b/timesheet.py @@ -20,7 +20,9 @@ class Line(metaclass=PoolMeta): pool = Pool() Employee = pool.get('company.employee') - cursor = Transaction().connection.cursor() + transaction = Transaction() + cursor = transaction.connection.cursor() + update = transaction.connection.cursor() table = cls.__table__() table_h = cls.__table_handler__(module_name) @@ -34,10 +36,10 @@ class Line(metaclass=PoolMeta): where=(table.cost_price == 0) & (table.employee != Null) & (table.date != Null))) - for line_id, employee_id, date in cursor.fetchall(): + for line_id, employee_id, date in cursor: employee = Employee(employee_id) cost_price = employee.compute_cost_price(date=date) - cursor.execute(*table.update( + update.execute(*table.update( [table.cost_price], [cost_price], where=table.id == line_id))