add field 'bookingtype', optimize form/list

This commit is contained in:
Frederik Jaeckel 2024-03-02 22:54:13 +01:00
parent d800b17561
commit 69b2a387ee
7 changed files with 148 additions and 30 deletions

View file

@ -11,6 +11,8 @@ from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.report import Report
from trytond.pyson import Eval, Bool, If, And
from trytond.modules.cashbook.line import sel_bookingtype
DEF_NONE = None
SEL_FREQU = [
@ -87,6 +89,14 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
nextrun = fields.One2Many(
string='Next Execution Date', size=1, field='planner',
model_name='cashbook.planner.nextrun')
nextrun_link = fields.Function(fields.Many2One(
string='Next Execution Date', readonly=True,
model_name='cashbook.planner.nextrun'),
'on_change_with_nextrun_link')
bookingtype = fields.Selection(
string='Type', selection=sel_bookingtype, required=True,
help='Type of Booking')
@classmethod
def __setup__(cls):
@ -167,6 +177,20 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
break
return result
@fields.depends('nextrun')
def on_change_with_nextrun_link(self, name=None):
""" get nextrun-record if exist
Args:
name (str, optional): field name. Defaults to None.
Returns:
int: id of nextrun-record or None
"""
if self.nextrun:
return self.nextrun[0].id
return None
@fields.depends(
'start_date', 'end_date', 'frequ', 'weekday', 'monthday',
'interval', 'setpos')