Add __table_handler__ to ModelSQL
issue7581 review48531002
This commit is contained in:
1 parent
160758d3c1
commit
ff0a58d446
3 files changed
+7
-13
No files matched your search
+2
-5
@@ -10,7 +10,6 @@ from trytond.model import ModelView, ModelSQL, MatchMixin, fields, \
|
||||
from trytond.pyson import Eval, If
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
from trytond import backend
|
||||
|
||||
from trytond.modules.product import price_digits
|
||||
|
||||
@@ -186,10 +185,9 @@ class ProductSupplier(sequence_ordered(), ModelSQL, ModelView, MatchMixin):
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
transaction = Transaction()
|
||||
cursor = transaction.connection.cursor()
|
||||
table = TableHandler(cls, module_name)
|
||||
table = cls.__table_handler__(module_name)
|
||||
sql_table = cls.__table__()
|
||||
|
||||
# Migration from 2.2 new field currency
|
||||
@@ -332,9 +330,8 @@ class ProductSupplierPrice(
|
||||
|
||||
@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__()
|
||||
|
||||
fill_sequence = not table.column_exist('sequence')
|
||||
|
||||
+4
-5
@@ -301,7 +301,7 @@ class Purchase(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')
|
||||
|
||||
# Migration from 3.8:
|
||||
@@ -318,7 +318,7 @@ class Purchase(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: warehouse is no more required
|
||||
table.not_null_action('warehouse', 'remove')
|
||||
|
||||
@@ -354,7 +354,7 @@ class Purchase(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')
|
||||
|
||||
@classmethod
|
||||
@@ -1110,11 +1110,10 @@ class PurchaseLine(sequence_ordered(), ModelSQL, ModelView):
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
cursor = Transaction().connection.cursor()
|
||||
sql_table = cls.__table__()
|
||||
super(PurchaseLine, 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'):
|
||||
|
||||
@@ -8,7 +8,6 @@ from trytond.model import Workflow, ModelView, 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
|
||||
|
||||
@@ -205,13 +204,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 purchase_line
|
||||
if table.column_exist('purchase_line'):
|
||||
|
||||
Reference in new issue
Block a user