Skip to content
Snippets Groups Projects
Commit d84bce05 authored by Cédric Krier's avatar Cédric Krier :atom:
Browse files

Replace cursor fetchall by iteration over cursor

issue5817
review335831003
parent 29cdd284
No related branches found
No related tags found
No related merge requests found
......@@ -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,9 +304,9 @@
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))
......@@ -308,9 +308,9 @@
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}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment