Add __table_handler__ to ModelSQL

issue7581
review48531002
This commit is contained in:
Cédric Krier
2018-07-24 22:01:08 +02:00
parent 13b24da4f0
commit 650c68a719
3 changed files with 6 additions and 11 deletions
+1 -3
View File
@@ -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)
+4 -5
View File
@@ -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'):
+1 -3
View File
@@ -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'):