From 3f66a224e45f789b442af4428eadda5907cbb32a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 24 Jul 2018 22:01:07 +0200 Subject: [PATCH] Add __table_handler__ to ModelSQL issue7581 review48531002 --- account.py | 8 +++----- line.py | 7 ++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/account.py b/account.py index a2dccc43ef..c082ccd405 100644 --- a/account.py +++ b/account.py @@ -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__() diff --git a/line.py b/line.py index 16148acb6f..32bd40cdc6 100644 --- a/line.py +++ b/line.py @@ -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__()