Replace cursor fetchall by iteration over cursor
issue5817 review335831003
This commit is contained in:
1 parent
dca61f06a3
commit
2257021def
3 files changed
+8
-6
No files matched your search
+5
-3
@@ -56,7 +56,9 @@ class Template(metaclass=PoolMeta):
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
cursor = Transaction().connection.cursor()
|
||||
transaction = Transaction()
|
||||
cursor = transaction.connection.cursor()
|
||||
update = transaction.connection.cursor()
|
||||
table = cls.__table_handler__(module_name)
|
||||
sql_table = cls.__table__()
|
||||
|
||||
@@ -66,11 +68,11 @@ class Template(metaclass=PoolMeta):
|
||||
if table.column_exist('delivery_time'):
|
||||
cursor.execute(*sql_table.select(
|
||||
sql_table.id, sql_table.delivery_time))
|
||||
for id_, delivery_time in cursor.fetchall():
|
||||
for id_, delivery_time in cursor:
|
||||
if delivery_time is None:
|
||||
continue
|
||||
lead_time = datetime.timedelta(days=delivery_time)
|
||||
cursor.execute(*sql_table.update(
|
||||
update.execute(*sql_table.update(
|
||||
[sql_table.lead_time],
|
||||
[lead_time],
|
||||
where=sql_table.id == id_))
|
||||
|
||||
@@ -1790,7 +1790,7 @@ class OpenCustomer(Wizard):
|
||||
sale = Sale.__table__()
|
||||
|
||||
cursor.execute(*sale.select(sale.party, group_by=sale.party))
|
||||
customer_ids = [line[0] for line in cursor.fetchall()]
|
||||
customer_ids = [line[0] for line in cursor]
|
||||
action['pyson_domain'] = PYSONEncoder().encode(
|
||||
[('id', 'in', customer_ids)])
|
||||
wizard = Wizard(ModelData.get_id('sale', 'act_open_customer'))
|
||||
|
||||
+2
-2
@@ -532,12 +532,12 @@ class CategoryTree(ModelSQL, ModelView):
|
||||
sub_ids = list(sub_ids)
|
||||
where = reduce_ids(table.id, sub_ids)
|
||||
cursor.execute(*table.select(table.id, table.parent, where=where))
|
||||
parents.update(cursor.fetchall())
|
||||
parents.update(cursor)
|
||||
|
||||
where = reduce_ids(reporting_category.id, sub_ids)
|
||||
cursor.execute(
|
||||
*reporting_category.select(reporting_category.id, where=where))
|
||||
reporting_categories.extend(r for r, in cursor.fetchall())
|
||||
reporting_categories.extend(r for r, in cursor)
|
||||
|
||||
result = {}
|
||||
reporting_categories = ReportingCategory.browse(reporting_categories)
|
||||
|
||||
Reference in new issue
Block a user