Allow to fixate a booking from Booking-Wizard
This commit is contained in:
parent
65437bc52e
commit
852ff6871d
5 changed files with 47 additions and 7 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue