diff --git a/product.py b/product.py index 4482b5092c..d2d104d563 100644 --- a/product.py +++ b/product.py @@ -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_)) diff --git a/sale.py b/sale.py index cd84884440..ff467943ad 100644 --- a/sale.py +++ b/sale.py @@ -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')) diff --git a/sale_reporting.py b/sale_reporting.py index 154757f78e..aa99ad6218 100644 --- a/sale_reporting.py +++ b/sale_reporting.py @@ -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)