From 21b014183a470e18a9d88043a6004c94f5e2c143 Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Thu, 8 Jun 2023 17:13:40 +0200 Subject: [PATCH] Tryton 6.8: index, info, tests --- README.rst | 6 +++--- book.py | 19 ++++++++++++++++--- setup.py | 3 ++- tests/__init__.py | 15 --------------- tests/book.py | 3 ++- tryton.cfg | 2 +- versiondep.txt | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.rst b/README.rst index 165d75d..75c2884 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ pip install mds-cashbook-investment Requires ======== -- Tryton 6.0 +- Tryton 6.8 How to ====== @@ -23,6 +23,6 @@ You can monitor trading fees, dividends and sales profits. Changes ======= -*6.0.0 - 20.12.2022* +*6.8.10 - 08.06.2023* -- init +- compatibility to Tryton 6.8 diff --git a/book.py b/book.py index 99461cf..04f2ceb 100644 --- a/book.py +++ b/book.py @@ -3,7 +3,7 @@ # The COPYRIGHT file at the top level of this repository contains the # full copyright notices and license terms. -from trytond.model import fields, SymbolMixin +from trytond.model import fields, SymbolMixin, Index from trytond.pool import PoolMeta, Pool from trytond.pyson import Eval, Or, Len, Bool, If from trytond.modules.cashbook.book import STATES2, DEPENDS2 @@ -42,7 +42,7 @@ class Book(SymbolMixin, metaclass=PoolMeta): __name__ = 'cashbook.book' asset = fields.Many2One( - string='Asset', select=True, + string='Asset', model_name='investment.asset', ondelete='RESTRICT', states={ 'required': Eval('feature', '') == 'asset', @@ -71,7 +71,7 @@ class Book(SymbolMixin, metaclass=PoolMeta): model_name='product.uom.category', states={'invisible': True}), 'on_change_with_asset_uomcat') quantity_uom = fields.Many2One( - string='UOM', select=True, + string='UOM', model_name='product.uom', ondelete='RESTRICT', domain=[ ('category.id', '=', Eval('asset_uomcat', -1)), @@ -211,6 +211,19 @@ class Book(SymbolMixin, metaclass=PoolMeta): }, depends=['currency_digits', 'feature']), 'on_change_with_yield_balance') + @classmethod + def __setup__(cls): + super(Book, cls).__setup__() + t = cls.__table__() + cls._sql_indexes.update({ + Index( + t, + (t.asset, Index.Equality())), + Index( + t, + (t.quantity_uom, Index.Equality())), + }) + @classmethod def view_attributes(cls): return super(Book, cls).view_attributes() + [ diff --git a/setup.py b/setup.py index de14b11..e1ae976 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ with open(path.join(here, 'versiondep.txt'), encoding='utf-8') as f: # tryton-version major_version = 6 -minor_version = 0 +minor_version = 8 requires = [] for dep in info.get('depends', []): @@ -92,6 +92,7 @@ setup( 'License :: OSI Approved :: GNU General Public License (GPL)', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', ], keywords='tryton cashbook investment', diff --git a/tests/__init__.py b/tests/__init__.py index 6b028e5..4effdfa 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,17 +1,2 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. - -import trytond.tests.test_tryton -import unittest - -from .test_module import CashbookInvestmentTestCase - - -__all__ = ['suite'] - - -def suite(): - suite = trytond.tests.test_tryton.suite() - suite.addTests(unittest.TestLoader().loadTestsFromTestCase( - CashbookInvestmentTestCase)) - return suite diff --git a/tests/book.py b/tests/book.py index 30cda5e..facab82 100644 --- a/tests/book.py +++ b/tests/book.py @@ -745,7 +745,8 @@ class CbInvTestCase(object): self.assertRaisesRegex( UserError, - 'A value is required for field "Asset" in "Cashbook".', + 'A value is required for field "Asset" in ' + + '"Book 1 | 0.00 usd | Open | 0.0000 u" of "Cashbook".', Book.write, *[ [book], diff --git a/tryton.cfg b/tryton.cfg index 3bf61da..c967ff6 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=6.0.0 +version=6.8.10 depends: cashbook investment diff --git a/versiondep.txt b/versiondep.txt index ed656a2..56d4ce7 100644 --- a/versiondep.txt +++ b/versiondep.txt @@ -1 +1 @@ -cashbook;6.0.21;6.0.999;mds +cashbook;6.8.28;6.8.999;mds