Compare commits
13 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4fb5f625ce | ||
![]() |
282917a617 | ||
![]() |
f4597378c3 | ||
![]() |
2a4fbbabdd | ||
![]() |
7cf82a82ba | ||
![]() |
f7fca80ad7 | ||
![]() |
07df52b6e9 | ||
![]() |
abcb15c20f | ||
![]() |
032160ce76 | ||
![]() |
bda363b1e1 | ||
![]() |
f1ae2932a3 | ||
![]() |
750f5c7594 | ||
![]() |
2da0074d2b |
12 changed files with 83 additions and 36 deletions
16
README.rst
16
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
|
||||
|
|
|
@ -7,6 +7,7 @@ from trytond.pool import Pool
|
|||
from .category import Category
|
||||
from .book import CategoryCashbookRel, Cashbook
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Category,
|
||||
|
|
12
book.py
12
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
|
||||
|
|
34
category.py
34
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
|
||||
|
|
|
@ -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 #
|
||||
|
|
|
@ -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"
|
||||
|
|
2
setup.py
2
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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.0
|
||||
version=6.0.4
|
||||
depends:
|
||||
cashbook
|
||||
xml:
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
cashbook;6.0.19;6.0.999;mds
|
||||
|
||||
cashbook;6.0.28;6.0.999;mds
|
||||
|
|
|
@ -12,6 +12,9 @@ full copyright notices and license terms. -->
|
|||
<field name="parent"/>
|
||||
<field name="childs" colspan="4"/>
|
||||
</page>
|
||||
<page string="Cashbooks" name="cashbooks" col="1">
|
||||
<field name="cashbooks"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<field name="company" invisible="1"/>
|
||||
|
||||
|
|
Loading…
Reference in a new issue