formatting, line: test for delete of party

This commit is contained in:
Frederik Jaeckel 2023-05-18 12:15:53 +02:00
parent 78f160bf0b
commit 619a17bcd6
16 changed files with 701 additions and 516 deletions

View file

@ -5,7 +5,8 @@
from trytond.model import ModelView, fields
from trytond.pyson import PYSONEncoder
from trytond.wizard import Wizard, StateView, StateTransition, StateAction, Button
from trytond.wizard import Wizard, StateView, StateTransition, \
StateAction, Button
from trytond.i18n import gettext
from trytond.pool import Pool
from trytond.exceptions import UserError
@ -28,7 +29,7 @@ class OLineMixin:
'checked': getattr(cfg1, 'checked', None),
'done': getattr(cfg1, 'done', None),
}),
'name' : '%(name)s: %(cashbook)s' % {
'name': '%(name)s: %(cashbook)s' % {
'name': gettext('cashbook.msg_name_cashbook'),
'cashbook': getattr(book, 'rec_name', '-/-'),
},
@ -42,10 +43,13 @@ class OpenCashBookStart(ModelView):
'Open Cashbook'
__name__ = 'cashbook.open_lines.start'
cashbook = fields.Many2One(string='Cashbook', model_name='cashbook.book',
cashbook = fields.Many2One(
string='Cashbook', model_name='cashbook.book',
required=True, domain=[('btype', '!=', None)])
checked = fields.Boolean(string='Checked', help="Show cashbook lines in Checked-state.")
done = fields.Boolean(string='Done', help="Show cashbook lines in Done-state")
checked = fields.Boolean(
string='Checked', help="Show cashbook lines in Checked-state.")
done = fields.Boolean(
string='Done', help="Show cashbook lines in Done-state")
date_from = fields.Date(string='Start Date')
date_to = fields.Date(string='End Date')
@ -66,7 +70,8 @@ class OpenCashBook(OLineMixin, Wizard):
start_state = 'check'
check = StateTransition()
askuser = StateView('cashbook.open_lines.start',
askuser = StateView(
'cashbook.open_lines.start',
'cashbook.open_lines_view_form', [
Button('Cancel', 'end', 'tryton-cancel'),
Button('Open', 'open_', 'tryton-ok', default=True),
@ -79,8 +84,7 @@ class OpenCashBook(OLineMixin, Wizard):
Book = Pool().get('cashbook.book')
with Transaction().set_context({
'_check_access': True,
}):
'_check_access': True}):
books = Book.search([('btype', '!=', None)])
if len(books) == 1:
return 'open_'
@ -115,8 +119,7 @@ class OpenCashBook(OLineMixin, Wizard):
book = getattr(self.askuser, 'cashbook', None)
if book is None:
with Transaction().set_context({
'_check_access': True,
}):
'_check_access': True}):
books = Book.search([('btype', '!=', None)])
if len(books) > 0:
book = books[0]
@ -158,17 +161,15 @@ class OpenCashBookTree(OLineMixin, Wizard):
book = self.record
if book is None:
with Transaction().set_context({
'_check_access': True,
}):
'_check_access': True}):
books = Book.search([('btype', '!=', None)])
if len(books) > 0:
book = books[0]
else :
else:
if book.btype is None:
raise UserError(gettext(
'cashbook.msg_book_no_type_noopen',
bookname = book.rec_name,
))
bookname=book.rec_name))
action.update(self.add_action_data(book))
return action, {}