diff --git a/book.py b/book.py index da49399..291e81f 100644 --- a/book.py +++ b/book.py @@ -55,9 +55,6 @@ class Book(Workflow, ModelSQL, ModelView): reconciliations = fields.One2Many(string='Reconciliations', field='cashbook', model_name='cashbook.recon', states=STATES, depends=DEPENDS) - account = fields.Many2One(string='Account', select=True, - model_name='account.account', ondelete='RESTRICT', - states=STATES, depends=DEPENDS) start_balance = fields.Numeric(string='Initial Amount', required=True, states={ 'readonly': Or( diff --git a/category.py b/category.py index 661c780..0d23eb8 100644 --- a/category.py +++ b/category.py @@ -34,11 +34,6 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView): readonly=True, states={'invisible': True}), 'on_change_with_parent_cattype') - account = fields.Many2One(string='Account', select=True, - model_name='account.account', ondelete='RESTRICT') - account_code = fields.Function(fields.Char(string='Account', readonly=True), - 'on_change_with_account_code', searcher='search_account_code') - company = fields.Many2One(string='Company', model_name='company.company', required=True, ondelete="RESTRICT") sequence = fields.Integer(string='Sequence', select=True) @@ -57,7 +52,6 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView): t = cls.__table__() cls._sql_constraints.extend([ ('name_uniq', Unique(t, t.name, t.company, t.parent), 'cashbook.msg_category_name_unique'), - ('account_uniq', Unique(t, t.account, t.company), 'cashbook.msg_category_account_unique'), ]) @classmethod @@ -76,37 +70,6 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView): def default_right(): return 0 - def get_long_recname(self, recname): - """ build rec_name with account-no - """ - Configuration = Pool().get('cashbook.configuration') - - l1 = [recname] - - if self.account: - if self.account.code: - cfg1 = Configuration.get_singleton() - if getattr(cfg1, 'cataccno', True) == True: - l1.append('[%s]' % self.account.code) - return ' '.join(l1) - - def get_rec_name(self, name): - """ short + name - """ - return self.get_long_recname( - super(Category, self).get_rec_name(name) - ) - - @classmethod - def search_rec_name(cls, name, clause): - """ search in account + name - """ - return ['OR', - super(Category, cls).search_rec_name(name, clause), - ('account.rec_name',) + tuple(clause[1:]), - ('account.code',) + tuple(clause[1:]), - ] - @fields.depends('parent', '_parent_parent.cattype') def on_change_with_parent_cattype(self, name=None): """ get type of parent category or None @@ -114,19 +77,6 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView): if self.parent: return self.parent.cattype - @fields.depends('account') - def on_change_with_account_code(self, name=None): - """ get code of account - """ - if self.account: - return self.account.code - - @classmethod - def search_account_code(cls, names, clause): - """ search in code - """ - return [('account.code',) + tuple(clause[1:])] - @classmethod def check_category_hierarchy(cls, categories): """ check if current category-type is equal to parent @@ -153,6 +103,8 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView): """ parent.cattape == cattype, update sub-categories """ + Category2 = Pool().get('cashbook.category') + actions = iter(args) to_check = [] to_write = [] @@ -162,8 +114,8 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView): if 'cattype' in values.keys(): # update sub-categories - cats = Category.search([ - ('parent', 'child_of', [x.id for x in categories]) + cats = Category2.search([ + ('parent', 'child_of', [x.id for x in categories]), ]) if len(cats) > 0: to_write.extend([ diff --git a/configuration.py b/configuration.py index a7aa753..e0e460f 100644 --- a/configuration.py +++ b/configuration.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 ModelSingleton, ModelView, ModelSQL, Workflow, fields, Check +from trytond.model import ModelSingleton, ModelView, ModelSQL, fields from .model import UserMultiValueMixin, UserValueMixin from trytond.pyson import Eval, If from trytond.pool import Pool @@ -15,8 +15,6 @@ field_done = fields.Boolean(string='Done', help='Show cashbook lines in Done-state.') field_catnamelong = fields.Boolean(string='Category: Show long name', help='Shows the long name of the category in the Category field of a cash book line.') -field_cataccno = fields.Boolean(string='Category: Show account number', - help='Shows the number of the linked account in the name of a category.') class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin): @@ -38,7 +36,6 @@ class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin): checked = fields.MultiValue(field_checked) done = fields.MultiValue(field_done) catnamelong = fields.MultiValue(field_catnamelong) - cataccno = fields.MultiValue(field_cataccno) @classmethod def multivalue_model(cls, field): @@ -47,7 +44,7 @@ class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin): pool = Pool() if field in ['date_from', 'date_to', 'checked', 'done', - 'catnamelong', 'cataccno']: + 'catnamelong']: return pool.get('cashbook.configuration_user') return super(Configuration, cls).multivalue_model(field) @@ -63,10 +60,6 @@ class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin): def default_catnamelong(cls, **pattern): return cls.multivalue_model('catnamelong').default_catnamelong() - @classmethod - def default_cataccno(cls, **pattern): - return cls.multivalue_model('cataccno').default_cataccno() - # end Configuration @@ -89,7 +82,6 @@ class UserConfiguration(ModelSQL, UserValueMixin): checked = field_checked done = field_done catnamelong = field_catnamelong - cataccno = field_cataccno @classmethod def default_checked(cls): @@ -99,10 +91,6 @@ class UserConfiguration(ModelSQL, UserValueMixin): def default_catnamelong(cls): return True - @classmethod - def default_cataccno(cls): - return True - @classmethod def default_done(cls): return False diff --git a/line.py b/line.py index 31e399f..5cdc934 100644 --- a/line.py +++ b/line.py @@ -230,13 +230,14 @@ class Line(Workflow, ModelSQL, ModelView): """ show optimizef form of category for list-view """ Configuration = Pool().get('cashbook.configuration') + if self.category: cfg1 = Configuration.get_singleton() if getattr(cfg1, 'catnamelong', True) == True: return self.category.rec_name else : - return self.category.get_long_recname(self.category.name) + return self.category.name @classmethod def search_category_view(cls, name, clause): diff --git a/locale/de.po b/locale/de.po index d38bd9c..8c8fb1d 100644 --- a/locale/de.po +++ b/locale/de.po @@ -62,10 +62,6 @@ msgctxt "model:ir.message,text:msg_category_name_unique" msgid "The category name already exists at this level." msgstr "Der Kategoriename existiert auf dieser Ebene bereits." -msgctxt "model:ir.message,text:msg_category_account_unique" -msgid "The account is already in use for a category." -msgstr "Das Konto wird bereits für eine Kategorie verwendet." - msgctxt "model:ir.message,text:msg_category_type_not_like_parent" msgid "The type of the current category '%(catname)s' must be equal to the type of the parent category '%(parentname)s'." msgstr "Der Typ der aktuellen Kategorie '%(catname)s' muß gleich dem Typ der übergeordneten Kategorie '%(parentname)s' sein." @@ -326,10 +322,6 @@ msgctxt "help:cashbook.book,observer:" msgid "Group of users who have read-only access to the cashbook." msgstr "Gruppe von Benutzern, die nur Lesezugriff auf das Kassenbuch haben." -msgctxt "field:cashbook.book,account:" -msgid "Account" -msgstr "Konto" - msgctxt "field:cashbook.book,company:" msgid "Company" msgstr "Unternehmen" @@ -526,14 +518,6 @@ msgctxt "field:cashbook.category,description:" msgid "Description" msgstr "Beschreibung" -msgctxt "field:cashbook.category,account:" -msgid "Account" -msgstr "Konto" - -msgctxt "field:cashbook.category,account_code:" -msgid "Account" -msgstr "Konto" - msgctxt "field:cashbook.category,company:" msgid "Company" msgstr "Unternehmen" @@ -710,14 +694,6 @@ msgctxt "help:cashbook.configuration,catnamelong:" msgid "Shows the long name of the category in the Category field of a cash book line." msgstr "Zeigt im Feld 'Kategorie' einer Kassenbuchzeile den langen Namen der Kategorie." -msgctxt "field:cashbook.configuration,cataccno:" -msgid "Category: Show account number" -msgstr "Kategorie: Kontonummer zeigen" - -msgctxt "help:cashbook.configuration,cataccno:" -msgid "Shows the number of the linked account in the name of a category." -msgstr "Zeigt im Namen einer Kategorie die Nummer des verknüpften Kontos." - ############################### # cashbook.configuration_user # @@ -758,14 +734,6 @@ msgctxt "help:cashbook.configuration_user,catnamelong:" msgid "Shows the long name of the category in the Category field of a cash book line." msgstr "Zeigt im Feld 'Kategorie' einer Kassenbuchzeile den langen Namen der Kategorie." -msgctxt "field:cashbook.configuration_user,cataccno:" -msgid "Category: Show account number" -msgstr "Kategorie: Kontonummer zeigen" - -msgctxt "help:cashbook.configuration_user,cataccno:" -msgid "Shows the number of the linked account in the name of a category." -msgstr "Zeigt im Namen einer Kategorie die Nummer des verknüpften Kontos." - ################## # cashbook.recon # diff --git a/locale/en.po b/locale/en.po index c772074..d8e335b 100644 --- a/locale/en.po +++ b/locale/en.po @@ -34,6 +34,10 @@ msgctxt "model:ir.message,text:msg_line_deny_delete2" msgid "The cashbook line '%(linetxt)s' cannot be deleted, its in state '%(linestate)s'." msgstr "The cashbook line '%(linetxt)s' cannot be deleted, its in state '%(linestate)s'." +msgctxt "model:ir.message,text:msg_line_deny_stateedit_with_recon" +msgid "The status cannot be changed to 'Edit' as long as the line '%(recname)s' is associated with a reconciliation." +msgstr "The status cannot be changed to 'Edit' as long as the line '%(recname)s' is associated with a reconciliation." + msgctxt "model:ir.message,text:msg_line_deny_write" msgid "The cashbook line '%(recname)s' is '%(state_txt)s' and cannot be changed." msgstr "The cashbook line '%(recname)s' is '%(state_txt)s' and cannot be changed." @@ -54,10 +58,6 @@ msgctxt "model:ir.message,text:msg_category_name_unique" msgid "The category name already exists at this level." msgstr "The category name already exists at this level." -msgctxt "model:ir.message,text:msg_category_account_unique" -msgid "The account is already in use for a category." -msgstr "The account is already in use for a category." - msgctxt "model:ir.message,text:msg_category_type_not_like_parent" msgid "The type of the current category '%(catname)s' must be equal to the type of the parent category '%(parentname)s'." msgstr "The type of the current category '%(catname)s' must be equal to the type of the parent category '%(parentname)s'." @@ -78,6 +78,10 @@ msgctxt "model:ir.message,text:msg_line_deny_write_by_reconciliation" msgid "The line '%(recname)s' cannot be changed because the reconciliation '%(reconame)s'is 'Done'." msgstr "The line '%(recname)s' cannot be changed because the reconciliation '%(reconame)s'is 'Done'." +msgctxt "model:ir.message,text:msg_recon_err_overlap" +msgid "The date range overlaps with another reconciliation." +msgstr "The date range overlaps with another reconciliation." + msgctxt "model:res.group,name:group_cashbook" msgid "Cashbook" msgstr "Cashbook" @@ -286,10 +290,6 @@ msgctxt "help:cashbook.book,observer:" msgid "Group of users who have read-only access to the cashbook." msgstr "Group of users who have read-only access to the cashbook." -msgctxt "field:cashbook.book,account:" -msgid "Account" -msgstr "Account" - msgctxt "field:cashbook.book,company:" msgid "Company" msgstr "Company" @@ -474,14 +474,6 @@ msgctxt "field:cashbook.category,description:" msgid "Description" msgstr "Description" -msgctxt "field:cashbook.category,account:" -msgid "Account" -msgstr "Account" - -msgctxt "field:cashbook.category,account_code:" -msgid "Account" -msgstr "Account" - msgctxt "field:cashbook.category,company:" msgid "Company" msgstr "Company" @@ -642,14 +634,6 @@ msgctxt "help:cashbook.configuration,catnamelong:" msgid "Shows the long name of the category in the Category field of a cash book line." msgstr "Shows the long name of the category in the Category field of a cash book line." -msgctxt "field:cashbook.configuration,cataccno:" -msgid "Category: Show account number" -msgstr "Category: Show account number" - -msgctxt "help:cashbook.configuration,cataccno:" -msgid "Shows the number of the linked account in the name of a category." -msgstr "Shows the number of the linked account in the name of a category." - msgctxt "model:cashbook.configuration_user,name:" msgid "User Configuration" msgstr "User Configuration" @@ -686,14 +670,6 @@ msgctxt "help:cashbook.configuration_user,catnamelong:" msgid "Shows the long name of the category in the Category field of a cash book line." msgstr "Shows the long name of the category in the Category field of a cash book line." -msgctxt "field:cashbook.configuration_user,cataccno:" -msgid "Category: Show account number" -msgstr "Category: Show account number" - -msgctxt "help:cashbook.configuration_user,cataccno:" -msgid "Shows the number of the linked account in the name of a category." -msgstr "Shows the number of the linked account in the name of a category." - msgctxt "model:cashbook.recon,name:" msgid "Cashbook Reconciliation" msgstr "Cashbook Reconciliation" @@ -754,3 +730,11 @@ msgctxt "selection:cashbook.recon,state_cashbook:" msgid "Closed" msgstr "Closed" +msgctxt "selection:cashbook.recon,state_cashbook:" +msgid "Archive" +msgstr "Archive" + +msgctxt "field:cashbook.recon,start_amount:" +msgid "Start Amount" +msgstr "Start Amount" + diff --git a/message.xml b/message.xml index f4f8ba1..236efe0 100644 --- a/message.xml +++ b/message.xml @@ -47,9 +47,6 @@ full copyright notices and license terms. --> The category name already exists at this level. - - The account is already in use for a category. - The type of the current category '%(catname)s' must be equal to the type of the parent category '%(parentname)s'. diff --git a/tests/test_category.py b/tests/test_category.py index 39759a1..bfea57e 100644 --- a/tests/test_category.py +++ b/tests/test_category.py @@ -160,39 +160,4 @@ class CategoryTestCase(ModuleTestCase): }])], }]) - @with_transaction() - def test_category_create_with_account(self): - """ create category + account - """ - pool = Pool() - Account = pool.get('account.account') - Category = pool.get('cashbook.category') - - company = self.prep_company() - - with Transaction().set_context({ - 'company': company.id, - }): - account, = Account.create([{ - 'name': 'Account No 1', - 'code': '0123', - }]) - - cat1, = Category.create([{ - 'name': 'Test 1', - 'description': 'Info', - 'account': account.id, - }]) - self.assertEqual(cat1.name, 'Test 1') - self.assertEqual(cat1.rec_name, 'Test 1 [0123]') - self.assertEqual(cat1.description, 'Info') - self.assertEqual(cat1.company.rec_name, 'm-ds') - - self.assertEqual(Category.search_count([ - ('account_code', '=', '0123'), - ]), 1) - self.assertEqual(Category.search_count([ - ('account_code', '=', '123'), - ]), 0) - # end CategoryTestCase diff --git a/tests/test_config.py b/tests/test_config.py index f00d171..4261c84 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -27,9 +27,8 @@ class ConfigTestCase(ModuleTestCase): company = create_company(name='m-ds') return company - @with_transaction() - def test_config_create(self): - """ create config + def prep_config(self): + """ store config """ Configuration = Pool().get('cashbook.configuration') @@ -42,7 +41,13 @@ class ConfigTestCase(ModuleTestCase): self.assertEqual(cfg2.checked, True) self.assertEqual(cfg2.done, False) self.assertEqual(cfg2.catnamelong, True) - self.assertEqual(cfg2.cataccno, True) + return cfg2 + + @with_transaction() + def test_config_create(self): + """ create config + """ + self.prep_config() @with_transaction() def test_config_create_multi_user(self): diff --git a/tests/test_line.py b/tests/test_line.py index 0466dff..2c77865 100644 --- a/tests/test_line.py +++ b/tests/test_line.py @@ -333,7 +333,6 @@ class LineTestCase(ModuleTestCase): Line = pool.get('cashbook.line') Configuration = pool.get('cashbook.configuration') Category = pool.get('cashbook.category') - Account = pool.get('account.account') types = self.prep_type() category = self.prep_category(cattype='in') @@ -342,31 +341,20 @@ class LineTestCase(ModuleTestCase): with Transaction().set_context({ 'company': company.id, }): - accounts = Account.create([{ - 'name': 'Account No 1', - 'code': '0123', - }, { - 'name': 'Account No 2', - 'code': '2345', - }]) - self.assertEqual(accounts[0].rec_name, '0123 - Account No 1') - self.assertEqual(accounts[1].rec_name, '2345 - Account No 2') category2, = Category.create([{ 'company': company.id, 'name': 'Level1', - 'account': accounts[0].id, 'cattype': 'in', 'childs': [('create', [{ 'company': company.id, 'name': 'Level2', - 'account': accounts[1].id, 'cattype': 'in', }])], }]) - self.assertEqual(category2.rec_name, 'Level1 [0123]') + self.assertEqual(category2.rec_name, 'Level1') self.assertEqual(len(category2.childs), 1) - self.assertEqual(category2.childs[0].rec_name, 'Level1/Level2 [2345]') + self.assertEqual(category2.childs[0].rec_name, 'Level1/Level2') cfg1 = Configuration() cfg1.save() @@ -395,15 +383,7 @@ class LineTestCase(ModuleTestCase): self.assertEqual(len(book.lines), 2) self.assertEqual(cfg1.catnamelong, True) - self.assertEqual(cfg1.cataccno, True) - self.assertEqual(book.lines[0].category.rec_name, 'Level1 [0123]') - self.assertEqual(book.lines[1].category.rec_name, 'Level1/Level2 [2345]') - self.assertEqual(book.lines[0].category_view, 'Level1 [0123]') - self.assertEqual(book.lines[1].category_view, 'Level1/Level2 [2345]') - - cfg1.cataccno = False - cfg1.save() self.assertEqual(book.lines[0].category.rec_name, 'Level1') self.assertEqual(book.lines[1].category.rec_name, 'Level1/Level2') self.assertEqual(book.lines[0].category_view, 'Level1') @@ -416,13 +396,6 @@ class LineTestCase(ModuleTestCase): self.assertEqual(book.lines[0].category_view, 'Level1') self.assertEqual(book.lines[1].category_view, 'Level2') - cfg1.cataccno = True - cfg1.save() - self.assertEqual(book.lines[0].category.rec_name, 'Level1 [0123]') - self.assertEqual(book.lines[1].category.rec_name, 'Level1/Level2 [2345]') - self.assertEqual(book.lines[0].category_view, 'Level1 [0123]') - self.assertEqual(book.lines[1].category_view, 'Level2 [2345]') - @with_transaction() def test_line_delete_with_book_in_open_state(self): """ create cashbook + line, book in state=open, delete a line diff --git a/tryton.cfg b/tryton.cfg index 849f0af..4ecb482 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -2,8 +2,8 @@ version=6.0.0 depends: res - account currency + company xml: icon.xml group.xml diff --git a/view/book_form.xml b/view/book_form.xml index eaf242c..65ec132 100644 --- a/view/book_form.xml +++ b/view/book_form.xml @@ -10,8 +10,7 @@ full copyright notices and license terms. -->