Add __table_handler__ to ModelSQL

issue7581
review48531002
This commit is contained in:
Cédric Krier committed 2018-07-24 22:01:08 +02:00
1 parent 6c5f4f9d70
commit c9136ab84d
4 files changed
+9 -17

No files matched your search

+2 -3
View File
@@ -11,7 +11,6 @@ from trytond.model import (
ModelView, ModelSQL, MatchMixin, DeactivableMixin, fields,
sequence_ordered)
from trytond.pyson import Eval, If
from trytond import backend
from trytond.pool import Pool
from trytond.transaction import Transaction
from trytond.cache import Cache
@@ -57,13 +56,13 @@ class Address(DeactivableMixin, sequence_ordered(), ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
cursor = Transaction().connection.cursor()
table = TableHandler(cls, module_name)
sql_table = cls.__table__()
super(Address, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 2.4: drop required on sequence
table.not_null_action('sequence', action='remove')
+2 -4
View File
@@ -3,7 +3,6 @@
from sql.conditionals import Coalesce
from sql.operators import Equal
from trytond import backend
from trytond.model import (
ModelView, ModelSQL, DeactivableMixin, fields, Exclude, tree)
from trytond.pyson import Eval
@@ -42,10 +41,9 @@ class Category(DeactivableMixin, tree(separator=' / '), ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
table_h = TableHandler(cls, module_name)
super(Category, cls).__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 4.6: replace unique by exclude
table_h.drop_constraint('name_parent_uniq')
+2 -4
View File
@@ -9,7 +9,6 @@ except ImportError:
from trytond.model import (
ModelView, ModelSQL, DeactivableMixin, fields, sequence_ordered)
from trytond.pyson import Eval
from trytond import backend
__all__ = ['ContactMechanism']
@@ -104,11 +103,10 @@ class ContactMechanism(
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
table = TableHandler(cls, module_name)
super(ContactMechanism, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 2.4: drop required on sequence
table.not_null_action('sequence', action='remove')
+3 -6
View File
@@ -87,11 +87,9 @@ class Party(DeactivableMixin, ModelSQL, ModelView, MultiValueMixin):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
super(Party, cls).__register__(module_name)
table_h = TableHandler(cls, module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 3.8
table_h.not_null_action('name', 'remove')
@@ -275,7 +273,7 @@ class PartyLang(ModelSQL, ValueMixin):
super(PartyLang, cls).__register__(module_name)
if not exist:
party_h = TableHandler(Party, module_name)
party_h = Party.__table_handler__(module_name)
if party_h.column_exist('lang'):
query = table.insert(
[table.party, table.lang],
@@ -330,13 +328,12 @@ class PartyIdentifier(sequence_ordered(), ModelSQL, ModelView):
def __register__(cls, module_name):
pool = Pool()
Party = pool.get('party.party')
TableHandler = backend.get('TableHandler')
cursor = Transaction().connection.cursor()
party = Party.__table__()
super(PartyIdentifier, cls).__register__(module_name)
party_h = TableHandler(Party, module_name)
party_h = Party.__table_handler__(module_name)
if (party_h.column_exist('vat_number')
and party_h.column_exist('vat_country')):
identifiers = []