Replace cursor fetchall by iteration over cursor

issue5817
review335831003
This commit is contained in:
Cédric Krier committed 2021-03-21 16:09:13 +01:00
1 parent 8b4a23ca9c
commit f8cc3cf460
1 file changed
+5 -3
+5 -3
View File
@@ -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))