Add __table_handler__ to ModelSQL

issue7581
review48531002
This commit is contained in:
Cédric Krier
2018-07-24 22:01:07 +02:00
parent f683b42f3e
commit d9b40ac0d9
3 changed files with 8 additions and 15 deletions
+2 -5
View File
@@ -11,7 +11,6 @@ from trytond.pyson import Eval, If, Bool
from trytond.pool import Pool, PoolMeta
from trytond.tools import grouped_slice
from trytond.transaction import Transaction
from trytond import backend
__all__ = ['FiscalYear',
'Period', 'Move', 'MoveLine', 'Reconciliation', 'InvoiceSequence',
@@ -30,7 +29,6 @@ class FiscalYear(metaclass=PoolMeta):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
pool = Pool()
Sequence = pool.get('account.fiscalyear.invoice_sequence')
sequence = Sequence.__table__()
@@ -38,7 +36,7 @@ class FiscalYear(metaclass=PoolMeta):
super(FiscalYear, cls).__register__(module_name)
cursor = Transaction().connection.cursor()
table = TableHandler(cls, module_name)
table = cls.__table_handler__(module_name)
# Migration from 4.2: Use Match pattern for sequences
if (table.column_exist('in_invoice_sequence')
@@ -76,7 +74,6 @@ class Period(metaclass=PoolMeta):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
pool = Pool()
Sequence = pool.get('account.fiscalyear.invoice_sequence')
FiscalYear = pool.get('account.fiscalyear')
@@ -86,7 +83,7 @@ class Period(metaclass=PoolMeta):
super(Period, cls).__register__(module_name)
cursor = Transaction().connection.cursor()
table = TableHandler(cls, module_name)
table = cls.__table_handler__(module_name)
# Migration from 4.2: Use Match pattern for sequences
if (table.column_exist('in_invoice_sequence')
+4 -7
View File
@@ -323,7 +323,6 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
pool = Pool()
Line = pool.get('account.invoice.line')
Tax = pool.get('account.invoice.tax')
TableHandler = backend.get('TableHandler')
sql_table = cls.__table__()
line = Line.__table__()
tax = Tax.__table__()
@@ -331,7 +330,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
super(Invoice, cls).__register__(module_name)
transaction = Transaction()
cursor = transaction.connection.cursor()
table = TableHandler(cls, module_name)
table = cls.__table_handler__(module_name)
# Migration from 1.2 invoice_date is no more required
table.not_null_action('invoice_date', action='remove')
@@ -1756,11 +1755,10 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin):
pool = Pool()
Invoice = pool.get('account.invoice')
invoice = Invoice.__table__()
TableHandler = backend.get('TableHandler')
sql_table = cls.__table__()
super(InvoiceLine, cls).__register__(module_name)
cursor = Transaction().connection.cursor()
table = TableHandler(cls, module_name)
table = cls.__table_handler__(module_name)
# Migration from 1.0 invoice is no more required
table.not_null_action('invoice', action='remove')
@@ -2243,11 +2241,10 @@ class InvoiceTax(sequence_ordered(), ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
table = TableHandler(cls, module_name)
super(InvoiceTax, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 2.4: drop required on sequence
table.not_null_action('sequence', action='remove')
+2 -3
View File
@@ -140,11 +140,10 @@ class PaymentTermLine(sequence_ordered(), ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
sql_table = cls.__table__()
super(PaymentTermLine, cls).__register__(module_name)
cursor = Transaction().connection.cursor()
table = TableHandler(cls, module_name)
table = cls.__table_handler__(module_name)
# Migration from 1.0 percent change into percentage
if table.column_exist('percent'):
@@ -341,7 +340,7 @@ class PaymentTermLineRelativeDelta(sequence_ordered(), ModelSQL, ModelView):
super(PaymentTermLineRelativeDelta, cls).__register__(module_name)
line_table = TableHandler(Line, module_name)
line_table = Line.__table_handler__(module_name)
# Migration from 3.4
fields = ['day', 'month', 'weekday', 'months', 'weeks', 'days']