diff --git a/address.py b/address.py index a1b6c0b6c6..d109db75e6 100644 --- a/address.py +++ b/address.py @@ -4,7 +4,7 @@ from trytond.model import ModelView, ModelSQL, fields from trytond.pyson import Eval, If from trytond.transaction import Transaction -from trytond.backend import TableHandler +from trytond import backend __all__ = ['Address'] @@ -33,9 +33,7 @@ class Address(ModelSQL, ModelView): 'Subdivision', domain=[('country', '=', Eval('country'))], states=STATES, depends=['active', 'country']) active = fields.Boolean('Active') - sequence = fields.Integer("Sequence", - order_field='(%(table)s.sequence IS NULL) %(order)s, ' - '%(table)s.sequence %(order)s') + sequence = fields.Integer("Sequence") full_address = fields.Function(fields.Text('Full Address'), 'get_full_address') @@ -50,6 +48,7 @@ class Address(ModelSQL, ModelView): @classmethod def __register__(cls, module_name): + TableHandler = backend.get('TableHandler') cursor = Transaction().cursor table = TableHandler(cursor, cls, module_name) @@ -58,6 +57,11 @@ class Address(ModelSQL, ModelView): # Migration from 2.4: drop required on sequence table.not_null_action('sequence', action='remove') + @staticmethod + def order_sequence(tables): + table, _ = tables[None] + return [table.sequence == None, table.sequence] + @staticmethod def default_active(): return True diff --git a/category.xml b/category.xml index 20c84b3889..d1b88ed03e 100644 --- a/category.xml +++ b/category.xml @@ -23,7 +23,7 @@ this repository contains the full copyright notices and license terms. --> Categories party.category - [('parent', '=', False)] + [('parent', '=', None)] diff --git a/contact_mechanism.py b/contact_mechanism.py index ed2f981c94..9c979abd9e 100644 --- a/contact_mechanism.py +++ b/contact_mechanism.py @@ -3,7 +3,7 @@ from trytond.model import ModelView, ModelSQL, fields from trytond.pyson import Eval from trytond.transaction import Transaction -from trytond.backend import TableHandler +from trytond import backend __all__ = ['ContactMechanism'] @@ -39,9 +39,7 @@ class ContactMechanism(ModelSQL, ModelView): party = fields.Many2One('party.party', 'Party', required=True, ondelete='CASCADE', states=STATES, select=True, depends=DEPENDS) active = fields.Boolean('Active', select=True) - sequence = fields.Integer('Sequence', - order_field='(%(table)s.sequence IS NULL) %(order)s, ' - '%(table)s.sequence %(order)s') + sequence = fields.Integer('Sequence') email = fields.Function(fields.Char('E-Mail', states={ 'invisible': Eval('type') != 'email', 'required': Eval('type') == 'email', @@ -92,6 +90,7 @@ class ContactMechanism(ModelSQL, ModelView): @classmethod def __register__(cls, module_name): + TableHandler = backend.get('TableHandler') cursor = Transaction().cursor table = TableHandler(cursor, cls, module_name) @@ -100,6 +99,11 @@ class ContactMechanism(ModelSQL, ModelView): # Migration from 2.4: drop required on sequence table.not_null_action('sequence', action='remove') + @staticmethod + def order_sequence(tables): + table, _ = tables[None] + return [table.sequence == None, table.sequence] + @staticmethod def default_type(): return 'phone' diff --git a/party.py b/party.py index ca97021571..ce0dd9c007 100644 --- a/party.py +++ b/party.py @@ -34,8 +34,6 @@ class Party(ModelSQL, ModelView): name = fields.Char('Name', required=True, select=True, states=STATES, depends=DEPENDS) code = fields.Char('Code', required=True, select=True, - order_field=("%(table)s.code_length %(order)s, " - "%(table)s.code %(order)s"), states={ 'readonly': Eval('code_readonly', True), }, @@ -85,6 +83,11 @@ class Party(ModelSQL, ModelView): }) cls._order.insert(0, ('name', 'ASC')) + @staticmethod + def order_code(tables): + table, _ = tables[None] + return [table.code_length, table.code] + @staticmethod def default_active(): return True