From 126daacf0aa22a76453c353e73d59af48e83de04 Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Fri, 1 Dec 2023 12:13:39 +0100 Subject: [PATCH 1/5] formatting --- setup.py | 69 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/setup.py b/setup.py index 23a7db4..b9b4bd6 100644 --- a/setup.py +++ b/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,7 +36,7 @@ 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 @@ -51,19 +51,21 @@ 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, @@ -74,36 +76,33 @@ setup(name='%s_%s' % (PREFIX, MODULE), 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', - 'Programming Language :: Python :: 3.9', + '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=""" From 176c8d93a7b37aa33f4c6fcaf08d4275f63a36e7 Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Fri, 1 Dec 2023 12:15:17 +0100 Subject: [PATCH 2/5] Tryton 7.0 --- README.rst | 6 +++--- setup.py | 4 ++-- tryton.cfg | 2 +- versiondep.txt | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 49aa477..8ef20d6 100644 --- a/README.rst +++ b/README.rst @@ -9,11 +9,11 @@ pip install mds-cashbook-bookcategory Requires ======== -- Tryton 6.8 +- Tryton 7.0 Changes ======= -*6.8.4 - 05.06.2023* +*7.0.0 - 01.12.2023* -- code optimized, porting to Tryton 6.8 +- compatibilty to Tryton 7.0 diff --git a/setup.py b/setup.py index b9b4bd6..043ba3f 100644 --- a/setup.py +++ b/setup.py @@ -39,8 +39,8 @@ with open(path.join(here, 'versiondep.txt'), encoding='utf-8') as f: modversion[l2[0]] = {'min': l2[1], 'max': l2[2], 'prefix': l2[3]} # tryton-version -major_version = 6 -minor_version = 8 +major_version = 7 +minor_version = 0 requires = [] for dep in info.get('depends', []): diff --git a/tryton.cfg b/tryton.cfg index 458dffc..8fb9398 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -1,5 +1,5 @@ [tryton] -version=6.8.4 +version=7.0.0 depends: cashbook xml: diff --git a/versiondep.txt b/versiondep.txt index 4191fe8..afb67b8 100644 --- a/versiondep.txt +++ b/versiondep.txt @@ -1,2 +1,2 @@ -cashbook;6.8.28;6.8.999;mds +cashbook;7.0.31;7.0.999;mds From a98b4387c4bac042d3d801b31f45b4e055b9a299 Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Mon, 4 Dec 2023 20:05:06 +0100 Subject: [PATCH 3/5] ir-rule: condition --> Eval('user_id', -1) --- __init__.py | 2 ++ category.xml | 2 +- ir.py | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 ir.py diff --git a/__init__.py b/__init__.py index e8af3da..e5bafe6 100644 --- a/__init__.py +++ b/__init__.py @@ -6,6 +6,7 @@ from trytond.pool import Pool from .category import Category from .book import CategoryCashbookRel, Cashbook +from .ir import Rule def register(): @@ -13,4 +14,5 @@ def register(): Category, Cashbook, CategoryCashbookRel, + Rule, module='cashbook_bookcategory', type_='model') diff --git a/category.xml b/category.xml index eab3ea6..41b5fbb 100644 --- a/category.xml +++ b/category.xml @@ -115,7 +115,7 @@ diff --git a/ir.py b/ir.py new file mode 100644 index 0000000..0e71a97 --- /dev/null +++ b/ir.py @@ -0,0 +1,20 @@ +# -*- 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.transaction import Transaction +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 + """ + return super(Rule, cls)._context_modelnames() + [ + 'cashbook.bookcategory'] + +# end Rule From f7fee173d7a7fea0d6e80c0d45497fdfff0bce50 Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Fri, 19 Jul 2024 16:01:44 +0200 Subject: [PATCH 4/5] update gitignore --- .hgignore => .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .hgignore => .gitignore (87%) diff --git a/.hgignore b/.gitignore similarity index 87% rename from .hgignore rename to .gitignore index e2b39b0..88532e8 100644 --- a/.hgignore +++ b/.gitignore @@ -1,4 +1,4 @@ -syntax: glob +*.pyc build/* mds_cashbook_bookcategory.egg-info/* dist/* From 1bfa98774620c0b2593cbfbc2fd1a15cce3c9718 Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Fri, 19 Jul 2024 16:02:19 +0200 Subject: [PATCH 5/5] Use 'irrulecontext' to add 'user_id' to context of ir.rule --- ir.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ir.py b/ir.py index 0e71a97..182092e 100644 --- a/ir.py +++ b/ir.py @@ -3,7 +3,6 @@ # The COPYRIGHT file at the top level of this repository contains the # full copyright notices and license terms. -from trytond.transaction import Transaction from trytond.pool import PoolMeta @@ -14,7 +13,9 @@ class Rule(metaclass=PoolMeta): def _context_modelnames(cls): """ list of models to add 'user_id' to context """ - return super(Rule, cls)._context_modelnames() + [ - 'cashbook.bookcategory'] + result = super(Rule, cls)._context_modelnames() + return result | { + 'cashbook.bookcategory', + } # end Rule