2022-08-05 14:47:43 +00:00
|
|
|
# -*- 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.
|
|
|
|
|
|
|
|
from trytond.model import ModelView, ModelSQL, fields, Unique
|
book, line, category, types: berechtigung für company-user + test,
book: währung neu,
line: buchungstyp, betrag, credit, debit, währung, sortierung
2022-08-10 14:30:08 +00:00
|
|
|
from trytond.transaction import Transaction
|
2022-12-21 18:12:39 +00:00
|
|
|
from trytond.i18n import gettext
|
2022-08-05 14:47:43 +00:00
|
|
|
|
|
|
|
|
2022-08-08 12:31:42 +00:00
|
|
|
class Type(ModelSQL, ModelView):
|
|
|
|
'Cashbook Type'
|
2022-08-05 14:47:43 +00:00
|
|
|
__name__ = 'cashbook.type'
|
|
|
|
|
|
|
|
name = fields.Char(string='Name', required=True, translate=True)
|
|
|
|
short = fields.Char(string='Abbreviation', required=True, size=3)
|
2023-05-18 10:15:53 +00:00
|
|
|
company = fields.Many2One(
|
|
|
|
string='Company', model_name='company.company',
|
book, line, category, types: berechtigung für company-user + test,
book: währung neu,
line: buchungstyp, betrag, credit, debit, währung, sortierung
2022-08-10 14:30:08 +00:00
|
|
|
required=True, ondelete="RESTRICT")
|
2023-05-18 10:15:53 +00:00
|
|
|
feature = fields.Selection(
|
|
|
|
string='Feature', required=True,
|
2023-06-03 17:13:05 +00:00
|
|
|
selection='get_sel_feature',
|
2022-12-21 18:12:39 +00:00
|
|
|
help='Select feature set of the Cashbook.')
|
2022-08-05 14:47:43 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def __setup__(cls):
|
2022-08-08 12:31:42 +00:00
|
|
|
super(Type, cls).__setup__()
|
2022-08-05 14:47:43 +00:00
|
|
|
cls._order.insert(0, ('name', 'ASC'))
|
|
|
|
t = cls.__table__()
|
2022-08-09 13:08:41 +00:00
|
|
|
cls._sql_constraints.extend([
|
2022-08-05 14:47:43 +00:00
|
|
|
('code_uniq', Unique(t, t.short), 'cashbook.msg_type_short_unique'),
|
2022-08-09 13:08:41 +00:00
|
|
|
])
|
2022-08-05 14:47:43 +00:00
|
|
|
|
2022-12-21 18:12:39 +00:00
|
|
|
@classmethod
|
|
|
|
def default_feature(cls):
|
|
|
|
""" default: general
|
|
|
|
"""
|
|
|
|
return 'gen'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def get_sel_feature(cls):
|
|
|
|
""" get feature-modes
|
|
|
|
"""
|
|
|
|
return [('gen', gettext('cashbook.msg_btype_general'))]
|
|
|
|
|
2022-08-05 14:47:43 +00:00
|
|
|
def get_rec_name(self, name):
|
|
|
|
""" short + name
|
|
|
|
"""
|
|
|
|
return '%(short)s - %(name)s' % {
|
|
|
|
'short': self.short or '-',
|
|
|
|
'name': self.name or '-',
|
|
|
|
}
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def search_rec_name(cls, name, clause):
|
2022-08-09 13:08:41 +00:00
|
|
|
""" search in name + short
|
2022-08-05 14:47:43 +00:00
|
|
|
"""
|
2023-05-18 10:15:53 +00:00
|
|
|
return [
|
|
|
|
'OR',
|
2022-08-05 14:47:43 +00:00
|
|
|
('name',) + tuple(clause[1:]),
|
|
|
|
('short',) + tuple(clause[1:]),
|
|
|
|
]
|
|
|
|
|
book, line, category, types: berechtigung für company-user + test,
book: währung neu,
line: buchungstyp, betrag, credit, debit, währung, sortierung
2022-08-10 14:30:08 +00:00
|
|
|
@staticmethod
|
|
|
|
def default_company():
|
|
|
|
return Transaction().context.get('company') or None
|
|
|
|
|
2022-08-08 12:31:42 +00:00
|
|
|
# end Type
|