What’s new?

Active Record

Model register

class instead of instance in Pool using metaclass MetaPool

trytond calls: module.register()

def register():
    Pool.register(
        Party,
        module='party', type_='model')

Model attributes

RPC

RPC(readonly=True, instantiate=None, result=None)

Model fields

__setup__ deepcopy all fields

More objects

No more dictionary values

Before

def on_change_product(self, values):
    product_obj = pool.get('product.product')
    product = product_obj.browse(values['product'])
    return {
        'description': product.rec_name,
        }

After

def on_change_product(self):
    return {
        'description': self.product.rec_name,
        }

default values

@classmethod
def default_active(cls):
    return True

Function getter

instance method

def get_rec_name(self, name):
    return '%s: %s' % (
        self.rec_name, self.party.rec_name)

but also class method

def get_amount(cls, records, name):
    cursor.execute('SELECT id, SUM(...)',
        map(int, records))
    return dict(cursor.fetchall())

Bonus

merge on_change_with with getter

currency_digits = fields.Function(fields.Integer('Digits',
        on_change_with=['currency']),
    'on_change_with_currency_digits')

def on_change_with_currency_digits(self, name=None):
    if self.currency:
        return self.currency.digits
    return 2

Unified API

Cache

Explicit LRU Cache management

class Cache(object):

    def get(self, key, default=None):
        ...

    def set(self, key, value):
        ...

    def clear(self):
        ...

Wizard

The instance is the session

Report

TODO

Sequence

Problem: sequence field increase every time

Solution

order_field='(%(table)s.sequence IS NULL) %(order)s, ' \
    '%(table)s.sequence %(order)s'

Time Format

time = fields.Time(string='Time', format='%H:%M')

Reference field for xxx2Many

size attribute

create/delete field access

Merge all kinds of button

View in XML file

Pre-validation