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

        issue5817
        review335831003
diffstat:

 project.py |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (55 lines):

diff -r 29cdd2840ef1 -r d84bce053fd2 project.py
--- a/project.py        Thu Mar 18 23:04:17 2021 +0100
+++ b/project.py        Sun Mar 21 16:09:13 2021 +0100
@@ -119,7 +119,7 @@
                     ).select(table.id, Sum(progress.progress),
                     where=where,
                     group_by=table.id))
-            invoiced_progress.update(dict(cursor.fetchall()))
+            invoiced_progress.update(dict(cursor))
 
             for work in sub_works:
                 delta = (
@@ -169,7 +169,7 @@
                     Sum(progress.progress * invoice_line.unit_price),
                     where=where,
                     group_by=table.id))
-            for work_id, amount in cursor.fetchall():
+            for work_id, amount in cursor:
                 if not isinstance(amount, Decimal):
                     amount = Decimal(str(amount))
                 work = ids2work[work_id]
@@ -181,7 +181,7 @@
                     condition=table.company == company.id
                     ).select(table.id, company.currency,
                     where=where))
-            work2currency.update(cursor.fetchall())
+            work2currency.update(cursor)
 
         currencies = Currency.browse(set(work2currency.values()))
         id2currency = {c.id: c for c in currencies}
@@ -254,7 +254,7 @@
             cursor.execute(*line.select(line.work, Sum(line.duration),
                     where=red_sql & (line.invoice_line == Null),
                     group_by=line.work))
-            for twork_id, duration in cursor.fetchall():
+            for twork_id, duration in cursor:
                 if duration:
                     # SQLite uses float for SUM
                     if not isinstance(duration, datetime.timedelta):
@@ -304,13 +304,13 @@
                     Sum(timesheet_line.duration * invoice_line.unit_price),
                     where=where,
                     group_by=table.id))
-            amounts.update(cursor.fetchall())
+            amounts.update(cursor)
 
             cursor.execute(*table.join(company,
                     condition=table.company == company.id
                     ).select(table.id, company.currency,
                     where=where))
-            work2currency.update(cursor.fetchall())
+            work2currency.update(cursor)
 
         currencies = Currency.browse(set(work2currency.values()))
         id2currency = {c.id: c for c in currencies}

Reply via email to