From e54ba1e905c929bb878438844ef4af5ccdb2e30e Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Tue, 13 Sep 2016 14:04:53 +0200 Subject: [PATCH] Use sequence_ordered issue5105 --- carrier.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/carrier.py b/carrier.py index 25628681d7..3730731d23 100644 --- a/carrier.py +++ b/carrier.py @@ -1,9 +1,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from sql import Null -from sql.conditionals import Case - -from trytond.model import ModelView, ModelSQL, MatchMixin, fields +from trytond.model import ModelView, ModelSQL, MatchMixin, fields, \ + sequence_ordered from trytond.transaction import Transaction from trytond.pool import Pool from trytond.cache import Cache @@ -66,12 +64,11 @@ class Carrier(ModelSQL, ModelView): CarrierSelection._get_carriers_cache.clear() -class CarrierSelection(MatchMixin, ModelSQL, ModelView): +class CarrierSelection(sequence_ordered(), MatchMixin, ModelSQL, ModelView): 'Carrier Selection' __name__ = 'carrier.selection' _get_carriers_cache = Cache('carrier.selection.get_carriers') - sequence = fields.Integer('Sequence') active = fields.Boolean('Active') from_country = fields.Many2One('country.country', 'From Country', ondelete='RESTRICT') @@ -80,16 +77,6 @@ class CarrierSelection(MatchMixin, ModelSQL, ModelView): carrier = fields.Many2One('carrier', 'Carrier', required=True, ondelete='CASCADE') - @classmethod - def __setup__(cls): - super(CarrierSelection, cls).__setup__() - cls._order.insert(0, ('sequence', 'ASC')) - - @staticmethod - def order_sequence(tables): - table, _ = tables[None] - return [Case((table.sequence == Null, 0), else_=1), table.sequence] - @staticmethod def default_active(): return True