diff --git a/README.rst b/README.rst index 7b12126..207238b 100644 --- a/README.rst +++ b/README.rst @@ -14,6 +14,22 @@ Requires Changes ======= +*6.0.4 - 05.06.2023* + +- code optimized + +*6.0.3 - 05.02.2023* + +- updt: remove left/right fields + +*6.0.2 - 08.11.2022* + +- add: show linked cashbook on category-form + +*6.0.1 - 08.11.2022* + +- works + *6.0.0 - 07.11.2022* - init diff --git a/__init__.py b/__init__.py index 11bfdee..e8af3da 100644 --- a/__init__.py +++ b/__init__.py @@ -7,6 +7,7 @@ from trytond.pool import Pool from .category import Category from .book import CategoryCashbookRel, Cashbook + def register(): Pool.register( Category, diff --git a/book.py b/book.py index 65f0839..00a2d5e 100644 --- a/book.py +++ b/book.py @@ -3,14 +3,14 @@ # this repository contains the full copyright notices and license terms. from trytond.model import ModelSQL, fields -from trytond.transaction import Transaction -from trytond.pool import Pool, PoolMeta +from trytond.pool import PoolMeta class Cashbook(metaclass=PoolMeta): __name__ = 'cashbook.book' - categories = fields.Many2Many(string='Categories', + categories = fields.Many2Many( + string='Categories', relation_name='cashbook.bookcategory-rel', origin='cashbook', target='category') @@ -21,9 +21,11 @@ class CategoryCashbookRel(ModelSQL): 'Category Cashbook Relation' __name__ = 'cashbook.bookcategory-rel' - category = fields.Many2One(string='Category', required=True, select=True, + category = fields.Many2One( + string='Category', required=True, select=True, model_name='cashbook.bookcategory', ondelete='CASCADE') - cashbook = fields.Many2One(string='Cashbook', required=True, select=True, + cashbook = fields.Many2One( + string='Cashbook', required=True, select=True, model_name='cashbook.book', ondelete='CASCADE') # end CategoryCashbookRel diff --git a/category.py b/category.py index 06160cc..b428e51 100644 --- a/category.py +++ b/category.py @@ -11,31 +11,35 @@ class Category(tree(separator=' / '), ModelSQL, ModelView): "Cashbook Category" __name__ = "cashbook.bookcategory" - company = fields.Many2One(string='Company', model_name='company.company', + company = fields.Many2One( + string='Company', model_name='company.company', required=True, ondelete="RESTRICT") name = fields.Char(string='Name', required=True, translate=True) - parent = fields.Many2One(string='Parent', select=True, - model_name='cashbook.bookcategory', ondelete='CASCADE', - left='left', right='right') - childs = fields.One2Many(string='Children', field='parent', + parent = fields.Many2One( + string='Parent', select=True, + model_name='cashbook.bookcategory', ondelete='CASCADE') + childs = fields.One2Many( + string='Children', field='parent', model_name='cashbook.bookcategory') - left = fields.Integer(string='Left', required=True, select=True) - right = fields.Integer(string='Right', required=True, select=True) + + cashbooks = fields.Many2Many( + string='Cashbooks', + relation_name='cashbook.bookcategory-rel', + origin='category', target='cashbook') + + @classmethod + def __register__(cls, module_name): + super(Category, cls).__register__(module_name) + table = cls.__table_handler__(module_name) + table.drop_column('left') + table.drop_column('right') @classmethod def __setup__(cls): super(Category, cls).__setup__() cls._order.insert(0, ('rec_name', 'ASC')) - @staticmethod - def default_left(): - return 0 - - @staticmethod - def default_right(): - return 0 - @staticmethod def default_company(): return Transaction().context.get('company') or None diff --git a/locale/de.po b/locale/de.po index 2372d4e..94fce9d 100644 --- a/locale/de.po +++ b/locale/de.po @@ -54,6 +54,10 @@ msgctxt "view:cashbook.bookcategory:" msgid "General Information" msgstr "Allgemein" +msgctxt "view:cashbook.bookcategory:" +msgid "Cashbooks" +msgstr "Kassenbücher" + msgctxt "field:cashbook.bookcategory,name:" msgid "Name" msgstr "Name" @@ -78,6 +82,10 @@ msgctxt "field:cashbook.bookcategory,right:" msgid "Right" msgstr "Rechts" +msgctxt "field:cashbook.bookcategory,cashbooks:" +msgid "Cashbooks" +msgstr "Kassenbücher" + ################# # cashbook.book # diff --git a/locale/en.po b/locale/en.po index 97cfcf1..7374def 100644 --- a/locale/en.po +++ b/locale/en.po @@ -38,6 +38,10 @@ msgctxt "view:cashbook.bookcategory:" msgid "General Information" msgstr "General Information" +msgctxt "view:cashbook.bookcategory:" +msgid "Cashbooks" +msgstr "Cashbooks" + msgctxt "field:cashbook.bookcategory,name:" msgid "Name" msgstr "Name" @@ -62,6 +66,10 @@ msgctxt "field:cashbook.bookcategory,right:" msgid "Right" msgstr "Right" +msgctxt "field:cashbook.bookcategory,cashbooks:" +msgid "Cashbooks" +msgstr "Cashbooks" + msgctxt "view:cashbook.book:" msgid "Categories" msgstr "Categories" diff --git a/setup.py b/setup.py index 235b3ab..728ff37 100644 --- a/setup.py +++ b/setup.py @@ -67,7 +67,9 @@ setup(name='%s_%s' % (PREFIX, MODULE), version=info.get('version', '0.0.1'), description='Tryton module to add categories for cashbooks.', long_description=long_description, + long_description_content_type='text/x-rst', url='https://www.m-ds.de/', + download_url='https://scmdev.m-ds.de/Tryton/Extra/cashbook_bookcategory', author='martin-data services', author_email='service@m-ds.de', license='GPL-3', diff --git a/tests/__init__.py b/tests/__init__.py index ead6f2c..a6930ba 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,24 +1,26 @@ -# This file is part of Tryton. The COPYRIGHT file at the top level of -# this repository contains the full copyright notices and license terms. +# -*- coding: utf-8 -*- +# This file is part of the cashbook-module from m-ds for 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 trytond.modules.cashbook_bookcategory.tests.test_category import CategoryTestCase +from .test_category import CategoryTestCase __all__ = ['suite'] -class CashbookCategoryTestCase(\ - CategoryTestCase,\ - ): +class CashbookCategoryTestCase(CategoryTestCase): 'Test cashbook module' module = 'cashbook_bookcategory' # end CashbookCategoryTestCase + def suite(): suite = trytond.tests.test_tryton.suite() - suite.addTests(unittest.TestLoader().loadTestsFromTestCase(CashbookCategoryTestCase)) + suite.addTests(unittest.TestLoader().loadTestsFromTestCase( + CashbookCategoryTestCase)) return suite diff --git a/tests/test_category.py b/tests/test_category.py index 9677d39..4bf63d5 100644 --- a/tests/test_category.py +++ b/tests/test_category.py @@ -3,10 +3,9 @@ # The COPYRIGHT file at the top level of this repository contains the # full copyright notices and license terms. -from trytond.tests.test_tryton import ModuleTestCase, with_transaction +from trytond.tests.test_tryton import with_transaction from trytond.pool import Pool from trytond.transaction import Transaction -from trytond.exceptions import UserError from trytond.modules.cashbook.tests import CashbookTestCase @@ -22,8 +21,7 @@ class CategoryTestCase(CashbookTestCase): company = self.prep_company() with Transaction().set_context({ - 'company': company.id, - }): + 'company': company.id}): categories, = BookCategory.create([{ 'name': 'Cat 0', 'childs': [('create', [{ @@ -56,8 +54,7 @@ class CategoryTestCase(CashbookTestCase): types = self.prep_type() company = self.prep_company() with Transaction().set_context({ - 'company': company.id, - }): + 'company': company.id}): category, = BookCategory.create([{ 'name': 'Cat 0', 'childs': [('create', [{ @@ -78,6 +75,11 @@ class CategoryTestCase(CashbookTestCase): self.assertEqual(len(book.categories), 1) self.assertEqual(book.categories[0].rec_name, 'Cat 0') + self.assertEqual(len(category.cashbooks), 1) + self.assertEqual( + category.cashbooks[0].rec_name, + 'Book 1 | 0.00 usd | Open') + # replace category Book.write(*[ [book], diff --git a/tryton.cfg b/tryton.cfg index ba1dc2c..706d511 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=6.0.0 +version=6.0.4 depends: cashbook xml: diff --git a/versiondep.txt b/versiondep.txt index e56514a..834317e 100644 --- a/versiondep.txt +++ b/versiondep.txt @@ -1,2 +1 @@ -cashbook;6.0.19;6.0.999;mds - +cashbook;6.0.28;6.0.999;mds diff --git a/view/category_form.xml b/view/category_form.xml index 5366dfc..2d6d58d 100644 --- a/view/category_form.xml +++ b/view/category_form.xml @@ -12,6 +12,9 @@ full copyright notices and license terms. --> + + +