Add __table_handler__ to ModelSQL

issue7581
review48531002
This commit is contained in:
Cédric Krier committed 2018-07-24 22:01:07 +02:00
1 parent d87124694c
commit 3f66a224e4
2 files changed
+5 -10

No files matched your search

+3 -5
View File
@@ -117,9 +117,8 @@ class Account(
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
super(Account, cls).__register__(module_name)
table = TableHandler(cls, module_name)
table = cls.__table_handler__(module_name)
# Migration from 4.0: remove currency
table.not_null_action('currency', action='remove')
@@ -424,7 +423,7 @@ class AnalyticAccountEntry(ModelView, ModelSQL):
migration_3_4 = True
# Don't create table before renaming
table = TableHandler(cls, module_name)
table = cls.__table_handler__(module_name)
super(AnalyticAccountEntry, cls).__register__(module_name)
@@ -515,12 +514,11 @@ class AnalyticMixin(object):
def __register__(cls, module_name):
pool = Pool()
AccountEntry = pool.get('analytic.account.entry')
TableHandler = backend.get('TableHandler')
cursor = Transaction().connection.cursor()
super(AnalyticMixin, cls).__register__(module_name)
handler = TableHandler(cls, module_name)
handler = cls.__table_handler__(module_name)
# Migration from 3.4: analytic accounting changed to reference field
if handler.column_exist('analytic_accounts'):
entry = AccountEntry.__table__()
+2 -5
View File
@@ -7,7 +7,6 @@ from sql import Literal
from trytond.model import ModelView, ModelSQL, fields, Check
from trytond.wizard import Wizard, StateAction
from trytond import backend
from trytond.pyson import Eval, PYSONEncoder
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
@@ -60,9 +59,8 @@ class Line(ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
super(Line, cls).__register__(module_name)
table = TableHandler(cls, module_name)
table = cls.__table_handler__(module_name)
# Migration from 1.2 currency has been changed in function field
table.not_null_action('currency', action='remove')
@@ -209,8 +207,7 @@ class MoveLine(ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
table = TableHandler(cls, module_name)
table = cls.__table_handler__(module_name)
cursor = Transaction().connection.cursor()
sql_table = cls.__table__()