Allow to fixate a booking from Booking-Wizard
This commit is contained in:
parent
f060d909fd
commit
a4509b4009
5 changed files with 47 additions and 7 deletions
12
locale/de.po
12
locale/de.po
|
@ -1658,6 +1658,18 @@ msgctxt "field:cashbook.enterbooking.start,party:"
|
||||||
msgid "Party"
|
msgid "Party"
|
||||||
msgstr "Partei"
|
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 #
|
# cashbook.enterbooking #
|
||||||
|
|
12
locale/en.po
12
locale/en.po
|
@ -1566,6 +1566,18 @@ msgctxt "field:cashbook.enterbooking.start,party:"
|
||||||
msgid "Party"
|
msgid "Party"
|
||||||
msgstr "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:"
|
msgctxt "model:cashbook.enterbooking,name:"
|
||||||
msgid "Enter Booking"
|
msgid "Enter Booking"
|
||||||
msgstr "Enter Booking"
|
msgstr "Enter Booking"
|
||||||
|
|
|
@ -65,6 +65,7 @@ class BookingWizardTestCase(object):
|
||||||
self.assertEqual(result['view']['defaults']['booktransf'], None)
|
self.assertEqual(result['view']['defaults']['booktransf'], None)
|
||||||
self.assertEqual(result['view']['defaults']['description'], None)
|
self.assertEqual(result['view']['defaults']['description'], None)
|
||||||
self.assertEqual(result['view']['defaults']['category'], None)
|
self.assertEqual(result['view']['defaults']['category'], None)
|
||||||
|
self.assertEqual(result['view']['defaults']['fixate'], False)
|
||||||
|
|
||||||
self.assertEqual(len(book.lines), 0)
|
self.assertEqual(len(book.lines), 0)
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ class BookingWizardTestCase(object):
|
||||||
'description': 'Test 1',
|
'description': 'Test 1',
|
||||||
'category': categories[1].id,
|
'category': categories[1].id,
|
||||||
'bookingtype': 'out',
|
'bookingtype': 'out',
|
||||||
}
|
'fixate': True}
|
||||||
for x in r1.keys():
|
for x in r1.keys():
|
||||||
setattr(w_obj.start, x, r1[x])
|
setattr(w_obj.start, x, r1[x])
|
||||||
|
|
||||||
|
@ -88,6 +89,7 @@ class BookingWizardTestCase(object):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
book.lines[0].rec_name,
|
book.lines[0].rec_name,
|
||||||
'05/01/2022|Exp|-10.00 usd|Test 1 [Food]')
|
'05/01/2022|Exp|-10.00 usd|Test 1 [Food]')
|
||||||
|
self.assertEqual(book.lines[0].state, 'check')
|
||||||
|
|
||||||
@with_transaction()
|
@with_transaction()
|
||||||
def test_bookwiz_transfer(self):
|
def test_bookwiz_transfer(self):
|
||||||
|
@ -147,6 +149,7 @@ class BookingWizardTestCase(object):
|
||||||
self.assertEqual(result['view']['defaults']['booktransf'], None)
|
self.assertEqual(result['view']['defaults']['booktransf'], None)
|
||||||
self.assertEqual(result['view']['defaults']['description'], None)
|
self.assertEqual(result['view']['defaults']['description'], None)
|
||||||
self.assertEqual(result['view']['defaults']['category'], 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[0].lines), 0)
|
||||||
self.assertEqual(len(books[1].lines), 0)
|
self.assertEqual(len(books[1].lines), 0)
|
||||||
|
@ -157,7 +160,7 @@ class BookingWizardTestCase(object):
|
||||||
'description': 'Test 1',
|
'description': 'Test 1',
|
||||||
'booktransf': books[1].id,
|
'booktransf': books[1].id,
|
||||||
'bookingtype': 'mvout',
|
'bookingtype': 'mvout',
|
||||||
}
|
'fixate': False}
|
||||||
for x in r1.keys():
|
for x in r1.keys():
|
||||||
setattr(w_obj.start, x, r1[x])
|
setattr(w_obj.start, x, r1[x])
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,10 @@ full copyright notices and license terms. -->
|
||||||
<page id="descr" string="Description" col="1">
|
<page id="descr" string="Description" col="1">
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
</page>
|
</page>
|
||||||
|
<page name="fixate" col="2">
|
||||||
|
<label name="fixate"/>
|
||||||
|
<field name="fixate"/>
|
||||||
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
|
|
||||||
<field name="cashbooks"/>
|
<field name="cashbooks"/>
|
||||||
|
@ -29,4 +33,3 @@ full copyright notices and license terms. -->
|
||||||
<field name="currency"/>
|
<field name="currency"/>
|
||||||
<field name="owner_cashbook"/>
|
<field name="owner_cashbook"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ from trytond.model import ModelView, fields
|
||||||
from trytond.wizard import Wizard, StateView, StateTransition, Button
|
from trytond.wizard import Wizard, StateView, StateTransition, Button
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.transaction import Transaction
|
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 decimal import Decimal
|
||||||
from .line import sel_bookingtype
|
from .line import sel_bookingtype
|
||||||
|
|
||||||
|
@ -45,7 +45,9 @@ class EnterBookingStart(ModelView):
|
||||||
depends=['currency_digits', 'bookingtype'],
|
depends=['currency_digits', 'bookingtype'],
|
||||||
digits=(16, Eval('currency_digits', 2)), required=True,
|
digits=(16, Eval('currency_digits', 2)), required=True,
|
||||||
domain=[('amount', '>=', Decimal('0.0'))])
|
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(
|
category = fields.Many2One(
|
||||||
string='Category',
|
string='Category',
|
||||||
model_name='cashbook.category', depends=['bookingtype'],
|
model_name='cashbook.category', depends=['bookingtype'],
|
||||||
|
@ -60,6 +62,8 @@ class EnterBookingStart(ModelView):
|
||||||
('cattype', '=', 'in'),
|
('cattype', '=', 'in'),
|
||||||
('cattype', '=', 'out'),
|
('cattype', '=', 'out'),
|
||||||
)])
|
)])
|
||||||
|
fixate = fields.Boolean(
|
||||||
|
string='Fixate', help='The booking is fixed immediately.')
|
||||||
|
|
||||||
# party or cashbook as counterpart
|
# party or cashbook as counterpart
|
||||||
booktransf = fields.Many2One(
|
booktransf = fields.Many2One(
|
||||||
|
@ -77,7 +81,10 @@ class EnterBookingStart(ModelView):
|
||||||
string='Party', model_name='party.party',
|
string='Party', model_name='party.party',
|
||||||
states={
|
states={
|
||||||
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
|
'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')
|
@fields.depends('bookingtype', 'category')
|
||||||
def on_change_bookingtype(self):
|
def on_change_bookingtype(self):
|
||||||
|
@ -150,6 +157,7 @@ class EnterBookingWizard(Wizard):
|
||||||
book_ids.append(getattr(cfg1, x, None).id)
|
book_ids.append(getattr(cfg1, x, None).id)
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
|
'fixate': False,
|
||||||
'cashbooks': [x.id for x in Cashbook.search([
|
'cashbooks': [x.id for x in Cashbook.search([
|
||||||
('state', '=', 'open'),
|
('state', '=', 'open'),
|
||||||
('btype', '!=', None),
|
('btype', '!=', None),
|
||||||
|
@ -187,7 +195,9 @@ class EnterBookingWizard(Wizard):
|
||||||
elif self.start.bookingtype in ['mvin', 'mvout']:
|
elif self.start.bookingtype in ['mvin', 'mvout']:
|
||||||
query['booktransf'] = self.start.booktransf.id
|
query['booktransf'] = self.start.booktransf.id
|
||||||
|
|
||||||
Line.create([query])
|
lines = Line.create([query])
|
||||||
|
if self.start.fixate:
|
||||||
|
Line.wfcheck(lines)
|
||||||
return 'end'
|
return 'end'
|
||||||
|
|
||||||
def transition_savenext_(self):
|
def transition_savenext_(self):
|
||||||
|
|
Loading…
Reference in a new issue