kategorie: constraint gegen gleiche Namen auf toplevel,

importer: list/erstellt kategorie, list transaktionen
This commit is contained in:
Frederik Jaeckel 2022-08-28 12:24:25 +02:00
parent 532d9cc7c8
commit 937124bcaf
8 changed files with 207 additions and 77 deletions

View file

@ -3,12 +3,13 @@
# 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, Unique, tree, sequence_ordered
from trytond.model import ModelView, ModelSQL, fields, Unique, Exclude, tree, sequence_ordered
from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.pyson import Eval, If, Bool
from trytond.exceptions import UserError
from trytond.i18n import gettext
from sql.operators import Equal
sel_categorytype = [
@ -51,7 +52,15 @@ class Category(tree(separator='/'), sequence_ordered(), ModelSQL, ModelView):
cls._order.insert(0, ('name', 'ASC'))
t = cls.__table__()
cls._sql_constraints.extend([
('name_uniq', Unique(t, t.name, t.company, t.parent), 'cashbook.msg_category_name_unique'),
('name_uniq',
Unique(t, t.name, t.company, t.parent),
'cashbook.msg_category_name_unique'),
('name2_uniq',
Exclude(t,
(t.name, Equal),
(t.cattype, Equal),
where=(t.parent == None)),
'cashbook.msg_category_name_unique'),
])
@classmethod