From 654e9d2ee7a5569b225f099c8c324f326ee86acc Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Mon, 8 Aug 2022 14:31:42 +0200 Subject: [PATCH] line, book - wf + tests --- __init__.py | 4 +- book.py | 120 +++++++++++- book.xml | 38 +++- line.py | 99 ++++++++-- line.xml | 4 +- locale/de.po | 185 ++++++++++++------- menu.xml | 18 +- message.xml | 18 ++ tests/__init__.py | 9 +- tests/test_book.py | 176 ++++++++++++++++++ tests/test_line.py | 153 +++++++++++++++ tests/{test_accounttype.py => test_type.py} | 20 +- tryton.cfg | 2 +- account_type.py => types.py | 8 +- account_type.xml => types.xml | 24 +-- view/book_form.xml | 9 + view/book_list.xml | 3 + view/cashbook_line_context_form.xml | 4 +- view/line_form.xml | 18 +- view/line_list.xml | 2 +- view/{accounttype_form.xml => type_form.xml} | 0 view/{accounttype_list.xml => type_list.xml} | 0 view/wizard_openline_form.xml | 4 +- wizard_openline.py | 20 +- wizard_openline.xml | 8 +- 25 files changed, 786 insertions(+), 160 deletions(-) create mode 100644 tests/test_book.py create mode 100644 tests/test_line.py rename tests/{test_accounttype.py => test_type.py} (62%) rename account_type.py => types.py (90%) rename account_type.xml => types.xml (77%) rename view/{accounttype_form.xml => type_form.xml} (100%) rename view/{accounttype_list.xml => type_list.xml} (100%) diff --git a/__init__.py b/__init__.py index b5a9987..7d33883 100644 --- a/__init__.py +++ b/__init__.py @@ -5,13 +5,13 @@ from trytond.pool import Pool from .book import Book -from .account_type import AccountType +from .types import Type from .line import Line, LineContext from .wizard_openline import OpenCashBook, OpenCashBookStart def register(): Pool.register( - AccountType, + Type, Book, LineContext, Line, diff --git a/book.py b/book.py index 60a635c..c80e7e8 100644 --- a/book.py +++ b/book.py @@ -3,22 +3,126 @@ # The COPYRIGHT file at the top level of this repository contains the # full copyright notices and license terms. -from trytond.model import ModelView, ModelSQL, fields +from trytond.model import Workflow, ModelView, ModelSQL, fields, Check +from trytond.pyson import Eval +from trytond.exceptions import UserError +from trytond.i18n import gettext -class Book(ModelSQL, ModelView): - 'Account' +STATES = { + 'readonly': Eval('state', '') != 'open', + } +DEPENDS=['state'] + +sel_state_book = [ + ('open', 'Open'), + ('closed', 'Closed'), + ('archive', 'Archive'), + ] + + +class Book(Workflow, ModelSQL, ModelView): + 'Cashbook' __name__ = 'cashbook.book' - name = fields.Char(string='Name', required=True) - btype = fields.Many2One(string='Account Type', required=True, - model_name='cashbook.type', ondelete='RESTRICT') - lines = fields.One2Many(string='Lines', field='account', - model_name='cashbook.line') + name = fields.Char(string='Name', required=True, + states=STATES, depends=DEPENDS) + btype = fields.Many2One(string='Type', required=True, + model_name='cashbook.type', ondelete='RESTRICT', + states=STATES, depends=DEPENDS) + lines = fields.One2Many(string='Lines', field='cashbook', + model_name='cashbook.line', + states=STATES, depends=DEPENDS) + state = fields.Selection(string='State', required=True, + readonly=True, selection=sel_state_book) + state_string = state.translated('state') @classmethod def __setup__(cls): super(Book, cls).__setup__() cls._order.insert(0, ('name', 'ASC')) + t = cls.__table__() + cls._sql_constraints.extend([ + ('state_val', + Check(t, t.state.in_(['open', 'closed', 'archive'])), + 'cashbook.msg_book_wrong_state_value'), + ]) + cls._transitions |= set(( + ('open', 'closed'), + ('closed', 'open'), + ('closed', 'archive'), + )) + cls._buttons.update({ + 'wfopen': { + 'invisible': Eval('state', '') != 'closed', + 'depends': ['state'], + }, + 'wfclosed': { + 'invisible': Eval('state') != 'open', + 'depends': ['state'], + }, + 'wfarchive': { + 'invisible': Eval('state') != 'closed', + 'depends': ['state'], + }, + }) + + @classmethod + def default_state(cls): + return 'open' + + @classmethod + @ModelView.button + @Workflow.transition('open') + def wfopen(cls, books): + """ open cashbook + """ + pass + + @classmethod + @ModelView.button + @Workflow.transition('closed') + def wfclosed(cls, books): + """ cashbook is closed + """ + pass + + @classmethod + @ModelView.button + @Workflow.transition('archive') + def wfarchive(cls, books): + """ cashbook is archived + """ + pass + + @classmethod + def write(cls, *args): + """ deny update if book is not 'open' + """ + actions = iter(args) + for books, values in zip(actions, actions): + for book in books: + if book.state != 'open': + # allow state-update, if its the only action + if not (('state' in values.keys()) and (len(values.keys()) == 1)): + raise UserError(gettext( + 'cashbook.msg_book_deny_write', + bookname = book.rec_name, + state_txt = book.state_string, + )) + super(Book, cls).write(*args) + + @classmethod + def delete(cls, books): + """ deny delete if book has lines + """ + for book in books: + if (len(book.lines) > 0) and (book.state != 'archive'): + raise UserError(gettext( + 'cashbook.msg_book_deny_delete', + bookname = book.rec_name, + booklines = len(book.lines), + )) + return super(Book, cls).delete(books) # end Book diff --git a/book.xml b/book.xml index e77648b..72b73ca 100644 --- a/book.xml +++ b/book.xml @@ -21,7 +21,7 @@ full copyright notices and license terms. --> - Account + Cashbook cashbook.book @@ -63,5 +63,41 @@ full copyright notices and license terms. --> + + + wfopen + Open + + + + + + + + + + wfclosed + Close + + + + + + + + + + wfarchive + Archive + + + + + + + diff --git a/line.py b/line.py index 2a26727..3d5d71d 100644 --- a/line.py +++ b/line.py @@ -3,10 +3,14 @@ # The COPYRIGHT file at the top level of this repository contains the # full copyright notices and license terms. -from trytond.model import ModelView, ModelSQL, Workflow, fields +from trytond.model import ModelView, ModelSQL, Workflow, fields, Check from trytond.pool import Pool -from trytond.pyson import Eval, If +from trytond.pyson import Eval, If, Or from trytond.transaction import Transaction +from trytond.report import Report +from trytond.exceptions import UserError +from trytond.i18n import gettext +from .book import sel_state_book sel_linetype = [ ('edit', 'Edit'), @@ -16,20 +20,23 @@ sel_linetype = [ STATES = { - 'readonly': Eval('state', '') != 'edit', + 'readonly': Or( + Eval('state', '') != 'edit', + Eval('state_cashbook', '') != 'open', + ), } -DEPENDS=['state'] +DEPENDS=['state', 'state_cashbook'] class LineContext(ModelView): 'Line Context' __name__ = 'cashbook.line.context' - account = fields.Many2One(string='Account', required=True, + cashbook = fields.Many2One(string='Cashbook', required=True, model_name='cashbook.book', states={ - 'readonly': Eval('num_account', 0) < 2, - }, depends=['num_account']) + 'readonly': Eval('num_cashbook', 0) < 2, + }, depends=['num_cashbook']) date_from = fields.Date(string='Start Date', depends=['date_to'], domain=[ If(Eval('date_to') & Eval('date_from'), @@ -46,16 +53,16 @@ class LineContext(ModelView): help='Show account lines in Checked-state.') done = fields.Boolean(string='Done', help='Show account lines in Done-state.') - num_account = fields.Function(fields.Integer(string='Number of Accounts', + num_cashbook = fields.Function(fields.Integer(string='Number of Cashbook', readonly=True, states={'invisible': True}), - 'on_change_with_num_account') + 'on_change_with_num_cashbook') @classmethod - def default_account(cls): + def default_cashbook(cls): """ get default from context """ context = Transaction().context - return context.get('account', None) + return context.get('cashbook', None) @classmethod def default_date_from(cls): @@ -85,8 +92,8 @@ class LineContext(ModelView): context = Transaction().context return context.get('done', False) - def on_change_with_num_account(self, name=None): - """ get number of accessible accounts, + def on_change_with_num_cashbook(self, name=None): + """ get number of accessible cashbooks, depends on user-permissions """ CashBook = Pool().get('cashbook.book') @@ -96,10 +103,10 @@ class LineContext(ModelView): class Line(Workflow, ModelSQL, ModelView): - 'Account Line' + 'Cashbook Line' __name__ = 'cashbook.line' - account = fields.Many2One(string='Account', required=True, select=True, + cashbook = fields.Many2One(string='Cashbook', required=True, select=True, model_name='cashbook.book', ondelete='CASCADE', readonly=True) date = fields.Date(string='Date', required=True, select=True, states=STATES, depends=DEPENDS) @@ -107,11 +114,21 @@ class Line(Workflow, ModelSQL, ModelView): states=STATES, depends=DEPENDS) state = fields.Selection(string='State', required=True, readonly=True, select=True, selection=sel_linetype) + state_string = state.translated('state') + state_cashbook = fields.Function(fields.Selection(string='State of Cashbook', + readonly=True, states={'invisible': True}, selection=sel_state_book), + 'on_change_with_state_cashbook', searcher='search_state_cashbook') @classmethod def __setup__(cls): super(Line, cls).__setup__() cls._order.insert(0, ('date', 'ASC')) + t = cls.__table__() + cls._sql_constraints.extend([ + ('state_val', + Check(t, t.state.in_(['edit', 'check', 'done'])), + 'cashbook.msg_line_wrong_state_value'), + ]) cls._transitions |= set(( ('edit', 'check'), ('check', 'done'), @@ -170,10 +187,58 @@ class Line(Workflow, ModelSQL, ModelView): return IrDate.today() @classmethod - def default_account(cls): + def default_cashbook(cls): """ get default from context """ context = Transaction().context - return context.get('account', None) + return context.get('cashbook', None) + + def get_rec_name(self, name): + """ short + name + """ + return '%(date)s %(desc)s' % { + 'date': Report.format_date(self.date), + 'desc': (self.description or '-')[:40], + } + + @classmethod + def search_rec_name(cls, name, clause): + """ search in description +... + """ + return [('description',) + tuple(clause[1:])] + + @fields.depends('cashbook', '_parent_cashbook.state') + def on_change_with_state_cashbook(self, name=None): + """ get state of cashbook + """ + if self.cashbook: + return self.cashbook.state + + @classmethod + def search_state_cashbook(cls, names, clause): + """ search in state of cashbook + """ + return [('cashbook.state',) + tuple(clause[1:])] + + @classmethod + def delete(cls, lines): + """ deny delete if book is not 'open' or wf is not 'edit' + """ + for line in lines: + if line.cashbook.state == 'closed': + raise UserError(gettext( + 'cashbook.msg_line_deny_delete1', + linetxt = line.rec_name, + bookname = line.cashbook.rec_name, + bookstate = line.cashbook.state_string, + )) + if line.state != 'edit': + raise UserError(gettext( + 'cashbook.msg_line_deny_delete2', + linetxt = line.rec_name, + linestate = line.state_string, + )) + + return super(Line, cls).delete(lines) # end Line diff --git a/line.xml b/line.xml index 123d782..b8eed11 100644 --- a/line.xml +++ b/line.xml @@ -27,12 +27,12 @@ full copyright notices and license terms. --> - Account Line + Cashbook Line cashbook.line cashbook.line.context - - + - - + + - - + - - + + - diff --git a/message.xml b/message.xml index 869f933..706283e 100644 --- a/message.xml +++ b/message.xml @@ -11,6 +11,24 @@ full copyright notices and license terms. --> Cashbook + + Invalid value of the field 'Status', allowed: edit, check, done. + + + Invalid value of the field 'Status', allowed: open, closed, archive. + + + The cash book '%(bookname)s' cannot be deleted because it contains %(booklines)s lines and is not in the status 'Archive'. + + + The cash book '%(bookname)s' is '%(state_txt)s' and cannot be changed. + + + The cashbook line '%(linetxt)s' cannot be deleted because the Cashbook '%(bookname)s' is in state '%(bookstate)s'. + + + The cashbook line '%(linetxt)s' cannot be deleted, its in state '%(linestate)s'. + diff --git a/tests/__init__.py b/tests/__init__.py index bc6f09c..e77df97 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -4,14 +4,17 @@ import trytond.tests.test_tryton import unittest -from trytond.modules.cashbook.tests.test_accounttype import AccounttypeTestCase - +from trytond.modules.cashbook.tests.test_type import TypeTestCase +from trytond.modules.cashbook.tests.test_book import BookTestCase +from trytond.modules.cashbook.tests.test_line import LineTestCase __all__ = ['suite'] class CashbookTestCase(\ - AccounttypeTestCase, + LineTestCase, + BookTestCase, + TypeTestCase, ): 'Test cashbook module' module = 'cashbook' diff --git a/tests/test_book.py b/tests/test_book.py new file mode 100644 index 0000000..c5cd54a --- /dev/null +++ b/tests/test_book.py @@ -0,0 +1,176 @@ +# 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 os, requests +from trytond.tests.test_tryton import ModuleTestCase, with_transaction +from trytond.pool import Pool +from trytond.transaction import Transaction +from trytond.exceptions import UserError +from datetime import date + + +class BookTestCase(ModuleTestCase): + 'Test cashbook book module' + module = 'cashbook' + + @with_transaction() + def test_book_create(self): + """ create cashbook + """ + pool = Pool() + Book = pool.get('cashbook.book') + Types = pool.get('cashbook.type') + + types, = Types.search([('short', '=','CAS')]) + + book, = Book.create([{ + 'name': 'Book 1', + 'btype': types.id, + }]) + self.assertEqual(book.name, 'Book 1') + self.assertEqual(book.btype.rec_name, 'CAS - Cash') + self.assertEqual(book.state, 'open') + self.assertEqual(book.state_string, 'Open') + + @with_transaction() + def test_book_deny_delete_open(self): + """ create cashbook, add lines, try to delete in state 'open' + """ + pool = Pool() + Book = pool.get('cashbook.book') + Types = pool.get('cashbook.type') + + types, = Types.search([('short', '=', 'CAS')]) + + book, = Book.create([{ + 'name': 'Book 1', + 'btype': types.id, + 'lines': [('create', [{ + 'date': date(2022, 5, 1), + 'description': 'test 1', + }])], + }]) + self.assertEqual(book.name, 'Book 1') + self.assertEqual(book.state, 'open') + + self.assertRaisesRegex(UserError, + "The cash book 'Book 1' cannot be deleted because it contains 1 lines and is not in the status 'Archive'.", + Book.delete, + [book]) + + @with_transaction() + def test_book_deny_delete_closed(self): + """ create cashbook, add lines, try to delete in state 'closed' + """ + pool = Pool() + Book = pool.get('cashbook.book') + Types = pool.get('cashbook.type') + + types, = Types.search([('short', '=', 'CAS')]) + + book, = Book.create([{ + 'name': 'Book 1', + 'btype': types.id, + 'lines': [('create', [{ + 'date': date(2022, 5, 1), + 'description': 'test 1', + }])], + }]) + self.assertEqual(book.name, 'Book 1') + self.assertEqual(book.state, 'open') + Book.wfclosed([book]) + self.assertEqual(book.state, 'closed') + + self.assertRaisesRegex(UserError, + "The cash book 'Book 1' cannot be deleted because it contains 1 lines and is not in the status 'Archive'.", + Book.delete, + [book]) + + @with_transaction() + def test_book_deny_delete_archive(self): + """ create cashbook, add lines, try to delete in state 'archive' + """ + pool = Pool() + Book = pool.get('cashbook.book') + Types = pool.get('cashbook.type') + + types, = Types.search([('short', '=', 'CAS')]) + + book, = Book.create([{ + 'name': 'Book 1', + 'btype': types.id, + 'lines': [('create', [{ + 'date': date(2022, 5, 1), + 'description': 'test 1', + }])], + }]) + self.assertEqual(book.name, 'Book 1') + self.assertEqual(book.state, 'open') + Book.wfclosed([book]) + Book.wfarchive([book]) + self.assertEqual(book.state, 'archive') + + Book.delete([book]) + + @with_transaction() + def test_book_deny_update_1(self): + """ create cashbook, try to update in states open, closed, archive + """ + pool = Pool() + Book = pool.get('cashbook.book') + Types = pool.get('cashbook.type') + + types, = Types.search([('short', '=', 'CAS')]) + + book, = Book.create([{ + 'name': 'Book 1', + 'btype': types.id, + }]) + self.assertEqual(book.name, 'Book 1') + self.assertEqual(book.state, 'open') + + Book.write(*[ + [book], + { + 'name': 'Book 1a', + }]) + self.assertEqual(book.name, 'Book 1a') + + # wf: open --> closed + Book.wfclosed([book]) + self.assertEqual(book.state, 'closed') + + self.assertRaisesRegex(UserError, + "The cash book 'Book 1a' is 'Closed' and cannot be changed.", + Book.write, + *[ + [book], + { + 'name': 'Book 1b', + }, + ]) + + Book.wfopen([book]) + self.assertEqual(book.state, 'open') + + Book.write(*[ + [book], + { + 'name': 'Book 1c', + }]) + self.assertEqual(book.name, 'Book 1c') + + Book.wfclosed([book]) + Book.wfarchive([book]) + + self.assertRaisesRegex(UserError, + "The cash book 'Book 1c' is 'Archive' and cannot be changed.", + Book.write, + *[ + [book], + { + 'name': 'Book 1d', + }, + ]) + +# end BookTestCase diff --git a/tests/test_line.py b/tests/test_line.py new file mode 100644 index 0000000..46b603b --- /dev/null +++ b/tests/test_line.py @@ -0,0 +1,153 @@ +# 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 os, requests +from trytond.tests.test_tryton import ModuleTestCase, with_transaction +from trytond.pool import Pool +from trytond.transaction import Transaction +from trytond.exceptions import UserError +from datetime import date + + +class LineTestCase(ModuleTestCase): + 'Test cashbook line module' + module = 'cashbook' + + @with_transaction() + def test_line_create_check_names_search(self): + """ create cashbook + line + """ + pool = Pool() + Book = pool.get('cashbook.book') + Types = pool.get('cashbook.type') + Lines = pool.get('cashbook.line') + + types, = Types.search([('short', '=','CAS')]) + + book, = Book.create([{ + 'name': 'Book 1', + 'btype': types.id, + 'lines': [('create', [{ + 'date': date(2022, 5, 1), + 'description': 'Text 1', + }, { + 'date': date(2022, 5, 2), + 'description': 'Text 2', + }])], + }]) + self.assertEqual(book.name, 'Book 1') + self.assertEqual(book.btype.rec_name, 'CAS - Cash') + self.assertEqual(book.state, 'open') + self.assertEqual(len(book.lines), 2) + self.assertEqual(book.lines[0].date, date(2022, 5, 1)) + self.assertEqual(book.lines[0].rec_name, '05/01/2022 Text 1') + self.assertEqual(book.lines[0].state_cashbook, 'open') + self.assertEqual(book.lines[1].date, date(2022, 5, 2)) + self.assertEqual(book.lines[1].rec_name, '05/02/2022 Text 2') + + self.assertEqual(Lines.search_count([('rec_name', '=', 'Text 1')]), 1) + self.assertEqual(Lines.search_count([('rec_name', '=', 'Text 1a')]), 0) + self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'text%')]), 2) + + self.assertEqual(Lines.search_count([('state_cashbook', '=', 'open')]), 2) + self.assertEqual(Lines.search_count([('state_cashbook', '=', 'closed')]), 0) + self.assertEqual(Lines.search_count([('cashbook.state', '=', 'open')]), 2) + self.assertEqual(Lines.search_count([('cashbook.state', '=', 'closed')]), 0) + + @with_transaction() + def test_line_delete_with_book_in_open_state(self): + """ create cashbook + line, book in state=open, delete a line + """ + pool = Pool() + Book = pool.get('cashbook.book') + Types = pool.get('cashbook.type') + Lines = pool.get('cashbook.line') + + types, = Types.search([('short', '=','CAS')]) + + book, = Book.create([{ + 'name': 'Book 1', + 'btype': types.id, + 'lines': [('create', [{ + 'date': date(2022, 5, 1), + 'description': 'Text 1', + }, { + 'date': date(2022, 5, 2), + 'description': 'Text 2', + }])], + }]) + self.assertEqual(book.name, 'Book 1') + self.assertEqual(len(book.lines), 2) + self.assertEqual(book.state, 'open') + + Lines.delete([book.lines[0]]) + + @with_transaction() + def test_line_delete_with_book_in_closed_state(self): + """ create cashbook + line, book in state=closed, delete a line + """ + pool = Pool() + Book = pool.get('cashbook.book') + Types = pool.get('cashbook.type') + Lines = pool.get('cashbook.line') + + types, = Types.search([('short', '=','CAS')]) + + book, = Book.create([{ + 'name': 'Book 1', + 'btype': types.id, + 'lines': [('create', [{ + 'date': date(2022, 5, 1), + 'description': 'Text 1', + }, { + 'date': date(2022, 5, 2), + 'description': 'Text 2', + }])], + }]) + self.assertEqual(book.name, 'Book 1') + self.assertEqual(len(book.lines), 2) + self.assertEqual(book.state, 'open') + Book.wfclosed([book]) + self.assertEqual(book.state, 'closed') + + self.assertRaisesRegex(UserError, + "The cashbook line '05/01/2022 Text 1' cannot be deleted because the Cashbook 'Book 1' is in state 'Closed'.", + Lines.delete, + [book.lines[0]]) + + @with_transaction() + def test_line_delete_with_line_in_check_state(self): + """ create cashbook + line, line in state=check, delete a line + """ + pool = Pool() + Book = pool.get('cashbook.book') + Types = pool.get('cashbook.type') + Lines = pool.get('cashbook.line') + + types, = Types.search([('short', '=','CAS')]) + + book, = Book.create([{ + 'name': 'Book 1', + 'btype': types.id, + 'lines': [('create', [{ + 'date': date(2022, 5, 1), + 'description': 'Text 1', + }, { + 'date': date(2022, 5, 2), + 'description': 'Text 2', + }])], + }]) + self.assertEqual(book.name, 'Book 1') + self.assertEqual(len(book.lines), 2) + self.assertEqual(book.state, 'open') + + self.assertEqual(book.lines[0].state, 'edit') + Lines.wfcheck([book.lines[0]]) + self.assertEqual(book.lines[0].state, 'check') + + self.assertRaisesRegex(UserError, + "The cashbook line '05/01/2022 Text 1' cannot be deleted, its in state 'Checked'.", + Lines.delete, + [book.lines[0]]) + +# end BookTestCase diff --git a/tests/test_accounttype.py b/tests/test_type.py similarity index 62% rename from tests/test_accounttype.py rename to tests/test_type.py index 97afc93..f2edb95 100644 --- a/tests/test_accounttype.py +++ b/tests/test_type.py @@ -8,12 +8,24 @@ from trytond.transaction import Transaction from trytond.exceptions import UserError -class AccounttypeTestCase(ModuleTestCase): - 'Test account type module' +class TypeTestCase(ModuleTestCase): + 'Test cashbook type module' module = 'cashbook' @with_transaction() - def test_accounttype_create(self): + def test_type_read_existing(self): + """ read predefined types + """ + AccType = Pool().get('cashbook.type') + + t_lst = AccType.search([], order=[('name', 'ASC')]) + self.assertEqual(len(t_lst), 3) + self.assertEqual(t_lst[0].rec_name, 'CAS - Cash') + self.assertEqual(t_lst[1].rec_name, 'FTD - Fixed-term deposit') + self.assertEqual(t_lst[2].rec_name, 'GIR - Giro') + + @with_transaction() + def test_type_create(self): """ create account type """ AccType = Pool().get('cashbook.type') @@ -34,4 +46,4 @@ class AccounttypeTestCase(ModuleTestCase): 'short': 'T1', }]) -# end AccounttypeTestCase +# end TypeTestCase diff --git a/tryton.cfg b/tryton.cfg index 12740e0..1788106 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -6,7 +6,7 @@ xml: icon.xml group.xml message.xml - account_type.xml + types.xml book.xml line.xml wizard_openline.xml diff --git a/account_type.py b/types.py similarity index 90% rename from account_type.py rename to types.py index f223290..f6309d0 100644 --- a/account_type.py +++ b/types.py @@ -6,8 +6,8 @@ from trytond.model import ModelView, ModelSQL, fields, Unique -class AccountType(ModelSQL, ModelView): - 'Account Type' +class Type(ModelSQL, ModelView): + 'Cashbook Type' __name__ = 'cashbook.type' name = fields.Char(string='Name', required=True, translate=True) @@ -15,7 +15,7 @@ class AccountType(ModelSQL, ModelView): @classmethod def __setup__(cls): - super(AccountType, cls).__setup__() + super(Type, cls).__setup__() cls._order.insert(0, ('name', 'ASC')) t = cls.__table__() cls._sql_constraints = [ @@ -39,4 +39,4 @@ class AccountType(ModelSQL, ModelView): ('short',) + tuple(clause[1:]), ] -# end AccountType +# end Type diff --git a/account_type.xml b/types.xml similarity index 77% rename from account_type.xml rename to types.xml index f4fd619..21d31ef 100644 --- a/account_type.xml +++ b/types.xml @@ -6,33 +6,33 @@ full copyright notices and license terms. --> - + cashbook.type tree - accounttype_list + type_list - + cashbook.type form - accounttype_form + type_form - - Account Type + + Cashbook Type cashbook.type - + - - + + - + - - + + diff --git a/view/book_form.xml b/view/book_form.xml index 2873acd..f172268 100644 --- a/view/book_form.xml +++ b/view/book_form.xml @@ -7,4 +7,13 @@ full copyright notices and license terms. -->