Compare commits
11 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1bfa987746 | ||
![]() |
f7fee173d7 | ||
![]() |
a98b4387c4 | ||
![]() |
176c8d93a7 | ||
![]() |
126daacf0a | ||
![]() |
e0e1fd07a7 | ||
![]() |
4ae07b962f | ||
![]() |
91674d81e3 | ||
![]() |
6457a8a4ac | ||
![]() |
68961c4675 | ||
![]() |
a9c627a63b |
15 changed files with 129 additions and 93 deletions
2
.hgignore → .gitignore
vendored
2
.hgignore → .gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
syntax: glob
|
||||
*.pyc
|
||||
build/*
|
||||
mds_cashbook_bookcategory.egg-info/*
|
||||
dist/*
|
|
@ -9,11 +9,11 @@ pip install mds-cashbook-bookcategory
|
|||
|
||||
Requires
|
||||
========
|
||||
- Tryton 6.0
|
||||
- Tryton 7.0
|
||||
|
||||
Changes
|
||||
=======
|
||||
|
||||
*6.0.0 - 07.11.2022*
|
||||
*7.0.0 - 01.12.2023*
|
||||
|
||||
- init
|
||||
- compatibilty to Tryton 7.0
|
||||
|
|
|
@ -6,10 +6,13 @@
|
|||
from trytond.pool import Pool
|
||||
from .category import Category
|
||||
from .book import CategoryCashbookRel, Cashbook
|
||||
from .ir import Rule
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Category,
|
||||
Cashbook,
|
||||
CategoryCashbookRel,
|
||||
Rule,
|
||||
module='cashbook_bookcategory', type_='model')
|
||||
|
|
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,
|
||||
model_name='cashbook.bookcategory', ondelete='CASCADE')
|
||||
cashbook = fields.Many2One(string='Cashbook', required=True, select=True,
|
||||
cashbook = fields.Many2One(
|
||||
string='Cashbook', required=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',
|
||||
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
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
</record>
|
||||
<record model="ir.rule" id="rg_category_rw_owner-1">
|
||||
<field name="domain" eval="[
|
||||
('create_uid.id', '=', Eval('user', {}).get('id', -1)),
|
||||
('create_uid.id', '=', Eval('user_id', -1)),
|
||||
]" pyson="1"/>
|
||||
<field name="rule_group" ref="rg_category_rw_owner"/>
|
||||
</record>
|
||||
|
|
21
ir.py
Normal file
21
ir.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This file is part of the cashbook-module from m-ds.de for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
|
||||
class Rule(metaclass=PoolMeta):
|
||||
__name__ = 'ir.rule'
|
||||
|
||||
@classmethod
|
||||
def _context_modelnames(cls):
|
||||
""" list of models to add 'user_id' to context
|
||||
"""
|
||||
result = super(Rule, cls)._context_modelnames()
|
||||
return result | {
|
||||
'cashbook.bookcategory',
|
||||
}
|
||||
|
||||
# end Rule
|
|
@ -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"
|
||||
|
|
72
setup.py
72
setup.py
|
@ -2,7 +2,7 @@
|
|||
"""
|
||||
|
||||
# Always prefer setuptools over distutils
|
||||
from setuptools import setup, find_packages
|
||||
from setuptools import setup
|
||||
# To use a consistent encoding
|
||||
from codecs import open
|
||||
from os import path
|
||||
|
@ -36,10 +36,10 @@ with open(path.join(here, 'versiondep.txt'), encoding='utf-8') as f:
|
|||
l2 = i.strip().split(';')
|
||||
if len(l2) < 4:
|
||||
continue
|
||||
modversion[l2[0]] = {'min':l2[1], 'max':l2[2], 'prefix':l2[3]}
|
||||
modversion[l2[0]] = {'min': l2[1], 'max': l2[2], 'prefix': l2[3]}
|
||||
|
||||
# tryton-version
|
||||
major_version = 6
|
||||
major_version = 7
|
||||
minor_version = 0
|
||||
|
||||
requires = []
|
||||
|
@ -51,56 +51,58 @@ for dep in info.get('depends', []):
|
|||
prefix = modversion[dep]['prefix']
|
||||
|
||||
if len(modversion[dep]['max']) > 0:
|
||||
requires.append('%s_%s >= %s, <= %s' %
|
||||
(prefix, dep, modversion[dep]['min'], modversion[dep]['max']))
|
||||
else :
|
||||
requires.append('%s_%s >= %s' %
|
||||
(prefix, dep, modversion[dep]['min']))
|
||||
else :
|
||||
requires.append('%s_%s >= %s.%s, < %s.%s' %
|
||||
('trytond', dep, major_version, minor_version,
|
||||
requires.append('%s_%s >= %s, <= %s' % (
|
||||
prefix, dep, modversion[dep]['min'],
|
||||
modversion[dep]['max']))
|
||||
else:
|
||||
requires.append('%s_%s >= %s' % (
|
||||
prefix, dep, modversion[dep]['min']))
|
||||
else:
|
||||
requires.append('%s_%s >= %s.%s, < %s.%s' % (
|
||||
'trytond', dep, major_version, minor_version,
|
||||
major_version, minor_version + 1))
|
||||
requires.append('trytond >= %s.%s, < %s.%s' %
|
||||
(major_version, minor_version, major_version, minor_version + 1))
|
||||
requires.append('trytond >= %s.%s, < %s.%s' % (
|
||||
major_version, minor_version, major_version, minor_version + 1))
|
||||
|
||||
setup(name='%s_%s' % (PREFIX, MODULE),
|
||||
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',
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Plugins',
|
||||
'Framework :: Tryton',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Customer Service',
|
||||
'Intended Audience :: Information Technology',
|
||||
'Intended Audience :: Financial and Insurance Industry',
|
||||
'Topic :: Office/Business',
|
||||
'Topic :: Office/Business :: Financial :: Accounting',
|
||||
'Natural Language :: German',
|
||||
'Natural Language :: English',
|
||||
'Operating System :: OS Independent',
|
||||
'License :: OSI Approved :: GNU General Public License (GPL)',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Plugins',
|
||||
'Framework :: Tryton',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Customer Service',
|
||||
'Intended Audience :: Information Technology',
|
||||
'Intended Audience :: Financial and Insurance Industry',
|
||||
'Topic :: Office/Business',
|
||||
'Topic :: Office/Business :: Financial :: Accounting',
|
||||
'Natural Language :: German',
|
||||
'Natural Language :: English',
|
||||
'Operating System :: OS Independent',
|
||||
'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 category',
|
||||
package_dir={'trytond.modules.%s' % MODULE: '.'},
|
||||
packages=[
|
||||
'trytond.modules.%s' % MODULE,
|
||||
],
|
||||
package_data={
|
||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
||||
+ ['tryton.cfg', 'locale/*.po', 'tests/*.py',
|
||||
'view/*.xml',
|
||||
'versiondep.txt', 'README.rst']),
|
||||
'trytond.modules.%s' % MODULE: (info.get('xml', []) + [
|
||||
'tryton.cfg', 'locale/*.po', 'tests/*.py',
|
||||
'view/*.xml', 'versiondep.txt', 'README.rst']),
|
||||
},
|
||||
|
||||
install_requires=requires,
|
||||
zip_safe=False,
|
||||
entry_points="""
|
||||
|
|
|
@ -1,24 +1,4 @@
|
|||
# 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 trytond.modules.cashbook_bookcategory.tests.test_category import CategoryTestCase
|
||||
|
||||
|
||||
__all__ = ['suite']
|
||||
|
||||
|
||||
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))
|
||||
return suite
|
||||
# -*- 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.
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
# 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
|
||||
from trytond.modules.cashbook.tests.test_module import CashbookTestCase
|
||||
|
||||
|
||||
class CategoryTestCase(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],
|
||||
|
@ -96,3 +98,6 @@ class CategoryTestCase(CashbookTestCase):
|
|||
self.assertEqual(len(book.categories), 0)
|
||||
|
||||
# end CategoryTestCase
|
||||
|
||||
|
||||
del CashbookTestCase
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.0
|
||||
version=7.0.0
|
||||
depends:
|
||||
cashbook
|
||||
xml:
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cashbook;6.0.19;6.0.999;mds
|
||||
cashbook;7.0.31;7.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