From 650c68a719083574c53dec978795c88029e429bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 24 Jul 2018 22:01:08 +0200 Subject: [PATCH] Add __table_handler__ to ModelSQL issue7581 review48531002 --- product.py | 4 +--- sale.py | 9 ++++----- stock.py | 4 +--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/product.py b/product.py index eae24cdddc..c44a70b39f 100644 --- a/product.py +++ b/product.py @@ -6,7 +6,6 @@ from trytond.model import fields from trytond.pyson import Eval from trytond.pool import Pool, PoolMeta from trytond.transaction import Transaction -from trytond import backend from trytond.modules.product import price_digits __all__ = ['Template', 'Product'] @@ -34,9 +33,8 @@ class Template(metaclass=PoolMeta): @classmethod def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') cursor = Transaction().connection.cursor() - table = TableHandler(cls, module_name) + table = cls.__table_handler__(module_name) sql_table = cls.__table__() super(Template, cls).__register__(module_name) diff --git a/sale.py b/sale.py index cb6bb941a0..a3b570537e 100644 --- a/sale.py +++ b/sale.py @@ -327,7 +327,7 @@ class Sale(Workflow, ModelSQL, ModelView, TaxableMixin): len('packing'))], where=model_field.name.like('%packing%') & (model_field.module == module_name))) - table = TableHandler(cls, module_name) + table = cls.__table_handler__(module_name) table.column_rename('packing_state', 'shipment_state') table.column_rename('packing_method', 'shipment_method') table.column_rename('packing_address', 'shipment_address') @@ -345,7 +345,7 @@ class Sale(Workflow, ModelSQL, ModelView, TaxableMixin): values=['shipment'], where=sql_table.invoice_method == 'packing')) - table = TableHandler(cls, module_name) + table = cls.__table_handler__(module_name) # Migration from 2.2 table.not_null_action('sale_date', 'remove') @@ -378,7 +378,7 @@ class Sale(Workflow, ModelSQL, ModelView, TaxableMixin): where=sql_table.id.in_(sub_query.select(sub_query.id)))) # Add index on create_date - table = TableHandler(cls, module_name) + table = cls.__table_handler__(module_name) table.index_action('create_date', action='add') # Migration from 4.0: Drop not null on payment_term @@ -1135,11 +1135,10 @@ class SaleLine(sequence_ordered(), ModelSQL, ModelView): @classmethod def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') cursor = Transaction().connection.cursor() sql_table = cls.__table__() super(SaleLine, cls).__register__(module_name) - table = TableHandler(cls, module_name) + table = cls.__table_handler__(module_name) # Migration from 1.0 comment change into note if table.column_exist('comment'): diff --git a/stock.py b/stock.py index 79fbc22ec8..2ddae40212 100644 --- a/stock.py +++ b/stock.py @@ -6,7 +6,6 @@ from sql.operators import Concat from trytond.model import Workflow, ModelView, fields from trytond.transaction import Transaction from trytond.pool import Pool, PoolMeta -from trytond import backend __all__ = ['ShipmentOut', 'ShipmentOutReturn', 'Move'] @@ -127,13 +126,12 @@ class Move(metaclass=PoolMeta): @classmethod def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') cursor = Transaction().connection.cursor() sql_table = cls.__table__() super(Move, cls).__register__(module_name) - table = TableHandler(cls, module_name) + table = cls.__table_handler__(module_name) # Migration from 2.6: remove sale_line if table.column_exist('sale_line'):