changeset 089a4aeb7c89 in modules/timesheet_cost:default
details: 
https://hg.tryton.org/modules/timesheet_cost?cmd=changeset&node=089a4aeb7c89
description:
        Replace cursor fetchall by iteration over cursor

        issue5817
        review335831003
diffstat:

 timesheet.py |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 8354e0811e35 -r 089a4aeb7c89 timesheet.py
--- a/timesheet.py      Fri Mar 05 15:49:20 2021 +0100
+++ b/timesheet.py      Sun Mar 21 16:09:13 2021 +0100
@@ -20,7 +20,9 @@
         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 @@
                     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))

Reply via email to