diff --git a/locale/de.po b/locale/de.po
index 403ee1e..f74615d 100644
--- a/locale/de.po
+++ b/locale/de.po
@@ -1658,6 +1658,18 @@ msgctxt "field:cashbook.enterbooking.start,party:"
msgid "Party"
msgstr "Partei"
+msgctxt "field:cashbook.enterbooking.start,description:"
+msgid "Description"
+msgstr "Beschreibung"
+
+msgctxt "field:cashbook.enterbooking.start,fixate:"
+msgid "Fixate"
+msgstr "Festschreiben"
+
+msgctxt "help:cashbook.enterbooking.start,fixate:"
+msgid "The booking is fixed immediately."
+msgstr "Die Buchung wird sofort festgeschrieben."
+
#########################
# cashbook.enterbooking #
diff --git a/locale/en.po b/locale/en.po
index 1452c27..0286c5a 100644
--- a/locale/en.po
+++ b/locale/en.po
@@ -1566,6 +1566,18 @@ msgctxt "field:cashbook.enterbooking.start,party:"
msgid "Party"
msgstr "Party"
+msgctxt "field:cashbook.enterbooking.start,description:"
+msgid "Description"
+msgstr "Description"
+
+msgctxt "field:cashbook.enterbooking.start,fixate:"
+msgid "Fixate"
+msgstr "Fixate"
+
+msgctxt "help:cashbook.enterbooking.start,fixate:"
+msgid "The booking is fixed immediately."
+msgstr "The booking is fixed immediately."
+
msgctxt "model:cashbook.enterbooking,name:"
msgid "Enter Booking"
msgstr "Enter Booking"
diff --git a/tests/bookingwiz.py b/tests/bookingwiz.py
index 690fcd6..f1def0d 100644
--- a/tests/bookingwiz.py
+++ b/tests/bookingwiz.py
@@ -65,6 +65,7 @@ class BookingWizardTestCase(object):
self.assertEqual(result['view']['defaults']['booktransf'], None)
self.assertEqual(result['view']['defaults']['description'], None)
self.assertEqual(result['view']['defaults']['category'], None)
+ self.assertEqual(result['view']['defaults']['fixate'], False)
self.assertEqual(len(book.lines), 0)
@@ -75,7 +76,7 @@ class BookingWizardTestCase(object):
'description': 'Test 1',
'category': categories[1].id,
'bookingtype': 'out',
- }
+ 'fixate': True}
for x in r1.keys():
setattr(w_obj.start, x, r1[x])
@@ -88,6 +89,7 @@ class BookingWizardTestCase(object):
self.assertEqual(
book.lines[0].rec_name,
'05/01/2022|Exp|-10.00 usd|Test 1 [Food]')
+ self.assertEqual(book.lines[0].state, 'check')
@with_transaction()
def test_bookwiz_transfer(self):
@@ -147,6 +149,7 @@ class BookingWizardTestCase(object):
self.assertEqual(result['view']['defaults']['booktransf'], None)
self.assertEqual(result['view']['defaults']['description'], None)
self.assertEqual(result['view']['defaults']['category'], None)
+ self.assertEqual(result['view']['defaults']['fixate'], False)
self.assertEqual(len(books[0].lines), 0)
self.assertEqual(len(books[1].lines), 0)
@@ -157,7 +160,7 @@ class BookingWizardTestCase(object):
'description': 'Test 1',
'booktransf': books[1].id,
'bookingtype': 'mvout',
- }
+ 'fixate': False}
for x in r1.keys():
setattr(w_obj.start, x, r1[x])
diff --git a/view/enterbooking_start_form.xml b/view/enterbooking_start_form.xml
index 9b16ddc..72fc034 100644
--- a/view/enterbooking_start_form.xml
+++ b/view/enterbooking_start_form.xml
@@ -22,6 +22,10 @@ full copyright notices and license terms. -->
+
+
+
+
@@ -29,4 +33,3 @@ full copyright notices and license terms. -->
-
diff --git a/wizard_booking.py b/wizard_booking.py
index 9530a35..9be9f69 100644
--- a/wizard_booking.py
+++ b/wizard_booking.py
@@ -7,7 +7,7 @@ from trytond.model import ModelView, fields
from trytond.wizard import Wizard, StateView, StateTransition, Button
from trytond.pool import Pool
from trytond.transaction import Transaction
-from trytond.pyson import Eval, Bool, If
+from trytond.pyson import Eval, Bool, If, And
from decimal import Decimal
from .line import sel_bookingtype
@@ -45,7 +45,9 @@ class EnterBookingStart(ModelView):
depends=['currency_digits', 'bookingtype'],
digits=(16, Eval('currency_digits', 2)), required=True,
domain=[('amount', '>=', Decimal('0.0'))])
- description = fields.Text(string='Description')
+ description = fields.Text(
+ string='Description', states={'required': Bool(Eval('fixate'))},
+ depends=['fixate'])
category = fields.Many2One(
string='Category',
model_name='cashbook.category', depends=['bookingtype'],
@@ -60,6 +62,8 @@ class EnterBookingStart(ModelView):
('cattype', '=', 'in'),
('cattype', '=', 'out'),
)])
+ fixate = fields.Boolean(
+ string='Fixate', help='The booking is fixed immediately.')
# party or cashbook as counterpart
booktransf = fields.Many2One(
@@ -77,7 +81,10 @@ class EnterBookingStart(ModelView):
string='Party', model_name='party.party',
states={
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
- }, depends=['bookingtype'])
+ 'required': And(
+ Bool(Eval('fixate')),
+ Eval('bookingtype', '').in_(['in', 'out']))},
+ depends=['bookingtype', 'fixate'])
@fields.depends('bookingtype', 'category')
def on_change_bookingtype(self):
@@ -150,6 +157,7 @@ class EnterBookingWizard(Wizard):
book_ids.append(getattr(cfg1, x, None).id)
result = {
+ 'fixate': False,
'cashbooks': [x.id for x in Cashbook.search([
('state', '=', 'open'),
('btype', '!=', None),
@@ -187,7 +195,9 @@ class EnterBookingWizard(Wizard):
elif self.start.bookingtype in ['mvin', 'mvout']:
query['booktransf'] = self.start.booktransf.id
- Line.create([query])
+ lines = Line.create([query])
+ if self.start.fixate:
+ Line.wfcheck(lines)
return 'end'
def transition_savenext_(self):