doc/book/en/development/entityclasses/load-sort.rst
branchstable
changeset 4750 875dc33551a9
parent 4446 a413fac5ff5e
equal deleted inserted replaced
4749:1560d51385f0 4750:875dc33551a9
    22   in the editing view of an entity. The default implementation uses
    22   in the editing view of an entity. The default implementation uses
    23   the modification date. Here's how to adapt it for one entity (sort
    23   the modification date. Here's how to adapt it for one entity (sort
    24   on the name attribute): ::
    24   on the name attribute): ::
    25 
    25 
    26    class MyEntity(AnyEntity):
    26    class MyEntity(AnyEntity):
       
    27        __regid__ = 'MyEntity'
    27        fetch_attrs = ('modification_date', 'name')
    28        fetch_attrs = ('modification_date', 'name')
    28 
    29 
    29        @classmethod
    30        @classmethod
    30        def fetch_unrelated_order(cls, attr, var):
    31        def fetch_unrelated_order(cls, attr, var):
    31            if attr == 'name':
    32            if attr == 'name':
    43 
    44 
    44 For example: ::
    45 For example: ::
    45 
    46 
    46   class Transition(AnyEntity):
    47   class Transition(AnyEntity):
    47     """..."""
    48     """..."""
    48     id = 'Transition'
    49     __regid__ = 'Transition'
    49     fetch_attrs, fetch_order = fetch_config(['name'])
    50     fetch_attrs, fetch_order = fetch_config(['name'])
    50 
    51 
    51 Indicates that for the entity type "Transition", you have to pre-load
    52 Indicates that for the entity type "Transition", you have to pre-load
    52 the attribute `name` and sort by default on this attribute.
    53 the attribute `name` and sort by default on this attribute.