From 4e64cedb9edf02b34fa4e40610a6e76f6b1ecb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20=C3=89vrard?= Date: Thu, 3 Mar 2016 21:53:42 +0100 Subject: [PATCH] Follow PEP-0249 for Transaction and backends issue4949 review19781002 --- invoice.py | 18 +++++++++--------- payment_term.py | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/invoice.py b/invoice.py index 7afdd63b2f..e6f079b838 100644 --- a/invoice.py +++ b/invoice.py @@ -279,8 +279,9 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): TableHandler = backend.get('TableHandler') sql_table = cls.__table__() super(Invoice, cls).__register__(module_name) - cursor = Transaction().cursor - table = TableHandler(cursor, cls, module_name) + transaction = Transaction() + cursor = transaction.connection.cursor() + table = TableHandler(cls, module_name) # Migration from 1.2 invoice_date is no more required table.not_null_action('invoice_date', action='remove') @@ -290,7 +291,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): if (table.column_exist('invoice_report') and table.column_exist('invoice_report_cache')): - limit = cursor.IN_MAX + limit = transaction.database.IN_MAX cursor.execute(*sql_table.select(Count(Literal(1)))) invoice_count, = cursor.fetchone() for offset in range(0, invoice_count, limit): @@ -501,7 +502,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): InvoiceTax = pool.get('account.invoice.tax') Move = pool.get('account.move') MoveLine = pool.get('account.move.line') - cursor = Transaction().cursor + cursor = Transaction().connection.cursor() untaxed_amount = dict((i.id, _ZERO) for i in invoices) tax_amount = dict((i.id, _ZERO) for i in invoices) @@ -604,7 +605,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): MoveLine = pool.get('account.move.line') line = MoveLine.__table__() invoice = cls.__table__() - cursor = Transaction().cursor + cursor = Transaction().connection.cursor() lines = defaultdict(list) for sub_ids in grouped_slice(invoices): @@ -1565,8 +1566,8 @@ class InvoiceLine(ModelSQL, ModelView, TaxableMixin): TableHandler = backend.get('TableHandler') sql_table = cls.__table__() super(InvoiceLine, cls).__register__(module_name) - cursor = Transaction().cursor - table = TableHandler(cursor, cls, module_name) + cursor = Transaction().connection.cursor() + table = TableHandler(cls, module_name) # Migration from 1.0 invoice is no more required table.not_null_action('invoice', action='remove') @@ -2062,8 +2063,7 @@ class InvoiceTax(ModelSQL, ModelView): @classmethod def __register__(cls, module_name): TableHandler = backend.get('TableHandler') - cursor = Transaction().cursor - table = TableHandler(cursor, cls, module_name) + table = TableHandler(cls, module_name) super(InvoiceTax, cls).__register__(module_name) diff --git a/payment_term.py b/payment_term.py index 7cadb97b3f..6bde5f4885 100644 --- a/payment_term.py +++ b/payment_term.py @@ -145,8 +145,8 @@ class PaymentTermLine(ModelSQL, ModelView): TableHandler = backend.get('TableHandler') sql_table = cls.__table__() super(PaymentTermLine, cls).__register__(module_name) - cursor = Transaction().cursor - table = TableHandler(cursor, cls, module_name) + cursor = Transaction().connection.cursor() + table = TableHandler(cls, module_name) # Migration from 1.0 percent change into percentage if table.column_exist('percent'): @@ -332,7 +332,7 @@ class PaymentTermLineRelativeDelta(ModelSQL, ModelView): @classmethod def __register__(cls, module_name): TableHandler = backend.get('TableHandler') - cursor = Transaction().cursor + cursor = Transaction().connection.cursor() pool = Pool() Line = pool.get('account.invoice.payment_term.line') sql_table = cls.__table__() @@ -340,7 +340,7 @@ class PaymentTermLineRelativeDelta(ModelSQL, ModelView): super(PaymentTermLineRelativeDelta, cls).__register__(module_name) - line_table = TableHandler(cursor, Line, module_name) + line_table = TableHandler(Line, module_name) # Migration from 3.4 fields = ['day', 'month', 'weekday', 'months', 'weeks', 'days']