Tryton 6.8: tests, indexes, info

This commit is contained in:
Frederik Jaeckel 2023-06-07 21:52:09 +02:00
parent 765738d9ee
commit 1c5b31d2f1
6 changed files with 37 additions and 28 deletions

16
rate.py
View file

@ -4,7 +4,7 @@
# full copyright notices and license terms.
from trytond.model import (
ModelView, ModelSQL, fields, Unique, Check, SymbolMixin)
ModelView, ModelSQL, fields, Unique, Check, SymbolMixin, Index)
from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.pyson import Eval
@ -15,11 +15,11 @@ class Rate(SymbolMixin, ModelSQL, ModelView):
__name__ = 'investment.rate'
asset = fields.Many2One(
string='Asset', required=True, select=True, ondelete='CASCADE',
string='Asset', required=True, ondelete='CASCADE',
model_name='investment.asset')
date = fields.Date(string='Date', required=True, select=True)
date = fields.Date(string='Date', required=True)
rate = fields.Numeric(
string='Rate', required=True, select=True,
string='Rate', required=True,
digits=(16, Eval('asset_digits', 4)), depends=['asset_digits'])
asset_digits = fields.Function(fields.Integer(
@ -46,6 +46,14 @@ class Rate(SymbolMixin, ModelSQL, ModelView):
'currency.msg_rate_positive'),
]
cls._order.insert(0, ('date', 'DESC'))
cls._sql_indexes.update({
Index(
t,
(t.date, Index.Range(order='DESC'))),
Index(
t,
(t.rate, Index.Range())),
})
@classmethod
def default_date(cls):