field 'nextrun_link' --> 'nextrun_date', add default-order
This commit is contained in:
parent
e1502cae53
commit
e7bd95ff31
6 changed files with 68 additions and 14 deletions
|
@ -204,7 +204,7 @@ msgstr "Tag des Monats"
|
||||||
|
|
||||||
msgctxt "help:cashbook.planner,monthday:"
|
msgctxt "help:cashbook.planner,monthday:"
|
||||||
msgid "If you want the rule to run on a specific day of the month, select the day here."
|
msgid "If you want the rule to run on a specific day of the month, select the day here."
|
||||||
msgstr "Wenn die Regel an einem bestimmten Tag im Monat ausgeführt soll, wählen Siehier den Tag."
|
msgstr "Wenn die Regel an einem bestimmten Tag im Monat ausgeführt soll, wählen Sie hier den Tag."
|
||||||
|
|
||||||
msgctxt "field:cashbook.planner,interval:"
|
msgctxt "field:cashbook.planner,interval:"
|
||||||
msgid "Interval"
|
msgid "Interval"
|
||||||
|
@ -234,7 +234,7 @@ msgctxt "field:cashbook.planner,nextrun:"
|
||||||
msgid "Next Execution Date"
|
msgid "Next Execution Date"
|
||||||
msgstr "Nächster Ausführungstermin"
|
msgstr "Nächster Ausführungstermin"
|
||||||
|
|
||||||
msgctxt "field:cashbook.planner,nextrun_link:"
|
msgctxt "field:cashbook.planner,nextrun_date:"
|
||||||
msgid "Next Execution Date"
|
msgid "Next Execution Date"
|
||||||
msgstr "Nächster Ausführungstermin"
|
msgstr "Nächster Ausführungstermin"
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ msgctxt "field:cashbook.planner,nextrun:"
|
||||||
msgid "Next Execution Date"
|
msgid "Next Execution Date"
|
||||||
msgstr "Next Execution Date"
|
msgstr "Next Execution Date"
|
||||||
|
|
||||||
msgctxt "field:cashbook.planner,nextrun_link:"
|
msgctxt "field:cashbook.planner,nextrun_date:"
|
||||||
msgid "Next Execution Date"
|
msgid "Next Execution Date"
|
||||||
msgstr "Next Execution Date"
|
msgstr "Next Execution Date"
|
||||||
|
|
||||||
|
|
56
planner.py
56
planner.py
|
@ -98,10 +98,9 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
||||||
nextrun = fields.One2Many(
|
nextrun = fields.One2Many(
|
||||||
string='Next Execution Date', size=1, field='planner',
|
string='Next Execution Date', size=1, field='planner',
|
||||||
model_name='cashbook.planner.nextrun')
|
model_name='cashbook.planner.nextrun')
|
||||||
nextrun_link = fields.Function(fields.Many2One(
|
nextrun_date = fields.Function(fields.Date(
|
||||||
string='Next Execution Date', readonly=True,
|
string='Next Execution Date', readonly=True),
|
||||||
model_name='cashbook.planner.nextrun'),
|
'on_change_with_nextrun_date', searcher='search_nextrun_date')
|
||||||
'on_change_with_nextrun_link')
|
|
||||||
|
|
||||||
bookingtype = fields.Selection(
|
bookingtype = fields.Selection(
|
||||||
string='Type', selection=sel_bookingtype, required=True,
|
string='Type', selection=sel_bookingtype, required=True,
|
||||||
|
@ -159,6 +158,8 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
super(ScheduledBooking, cls).__setup__()
|
super(ScheduledBooking, cls).__setup__()
|
||||||
|
cls._order.insert(0, ('name', 'ASC'))
|
||||||
|
cls._order.insert(0, ('nextrun_date', 'ASC'))
|
||||||
t = cls.__table__()
|
t = cls.__table__()
|
||||||
cls._sql_indexes.update({
|
cls._sql_indexes.update({
|
||||||
Index(
|
Index(
|
||||||
|
@ -189,7 +190,8 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
||||||
self.booktransf.name
|
self.booktransf.name
|
||||||
if self.booktransf
|
if self.booktransf
|
||||||
else self.category.rec_name if self.category else '-',
|
else self.category.rec_name if self.category else '-',
|
||||||
self.nextrun_link.rec_name if self.nextrun_link else '-',
|
Report.format_date(self.nextrun_date, lang=None)
|
||||||
|
if self.nextrun_date else '-',
|
||||||
Report.format_currency(
|
Report.format_currency(
|
||||||
self.amount, lang=None, currency=self.cashbook.currency)
|
self.amount, lang=None, currency=self.cashbook.currency)
|
||||||
])
|
])
|
||||||
|
@ -302,17 +304,17 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
||||||
return self.cashbook.currency.id
|
return self.cashbook.currency.id
|
||||||
|
|
||||||
@fields.depends('nextrun')
|
@fields.depends('nextrun')
|
||||||
def on_change_with_nextrun_link(self, name=None):
|
def on_change_with_nextrun_date(self, name=None):
|
||||||
""" get nextrun-record if exist
|
""" get nextrun-record if exist
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name (str, optional): field name. Defaults to None.
|
name (str, optional): field name. Defaults to None.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
int: id of nextrun-record or None
|
date: date of nextrun or None
|
||||||
"""
|
"""
|
||||||
if self.nextrun:
|
if self.nextrun:
|
||||||
return self.nextrun[0].id
|
return self.nextrun[0].date
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@fields.depends(
|
@fields.depends(
|
||||||
|
@ -402,6 +404,44 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
||||||
"""
|
"""
|
||||||
self.on_change_frequ()
|
self.on_change_frequ()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def order_nextrun_date(tables):
|
||||||
|
""" get query to sort by date of next execution
|
||||||
|
|
||||||
|
Args:
|
||||||
|
tables (list): tables
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list of query: sort-query
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Nextrun = pool.get('cashbook.planner.nextrun')
|
||||||
|
Planner2 = pool.get('cashbook.planner')
|
||||||
|
tab_nxrun = Nextrun.__table__()
|
||||||
|
tab_plan = Planner2.__table__()
|
||||||
|
table, _ = tables[None]
|
||||||
|
|
||||||
|
query = tab_plan.join(
|
||||||
|
tab_nxrun,
|
||||||
|
condition=tab_nxrun.planner == tab_plan.id
|
||||||
|
).select(
|
||||||
|
tab_nxrun.date,
|
||||||
|
where=tab_plan.id == table.id)
|
||||||
|
return [query]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def search_nextrun_date(cls, name, clause):
|
||||||
|
""" get query for search on 'nextrun_date'
|
||||||
|
|
||||||
|
Args:
|
||||||
|
name (str): name of field to search on
|
||||||
|
clause (dict): search clause
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
list of dict: search clause
|
||||||
|
"""
|
||||||
|
return [('nextrun.date',) + tuple(clause[1:])]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_wfcheck(cls):
|
def default_wfcheck(cls):
|
||||||
""" False as default for wf-state 'checked'
|
""" False as default for wf-state 'checked'
|
||||||
|
|
|
@ -292,6 +292,20 @@ class PlannerTestCase(object):
|
||||||
Planner.update_next_occurence([job], query_date=date(2022, 5, 25))
|
Planner.update_next_occurence([job], query_date=date(2022, 5, 25))
|
||||||
self.assertEqual(len(job.nextrun), 1)
|
self.assertEqual(len(job.nextrun), 1)
|
||||||
self.assertEqual(job.nextrun[0].date, date(2022, 6, 1))
|
self.assertEqual(job.nextrun[0].date, date(2022, 6, 1))
|
||||||
|
self.assertEqual(job.nextrun_date, date(2022, 6, 1))
|
||||||
|
|
||||||
|
# check searcher + order
|
||||||
|
self.assertEqual(
|
||||||
|
Planner.search(
|
||||||
|
[('nextrun_date', '=', date(2022, 6, 1))],
|
||||||
|
order=[('nextrun_date', 'ASC')]),
|
||||||
|
[job])
|
||||||
|
self.assertEqual(
|
||||||
|
Planner.search_count([('nextrun_date', '=', date(2022, 6, 1))]),
|
||||||
|
1)
|
||||||
|
self.assertEqual(
|
||||||
|
Planner.search_count([('nextrun_date', '=', date(2022, 6, 2))]),
|
||||||
|
0)
|
||||||
|
|
||||||
Planner.update_next_occurence([job], query_date=date(2022, 5, 30))
|
Planner.update_next_occurence([job], query_date=date(2022, 5, 30))
|
||||||
self.assertEqual(len(job.nextrun), 1)
|
self.assertEqual(len(job.nextrun), 1)
|
||||||
|
|
|
@ -12,8 +12,8 @@ full copyright notices and license terms. -->
|
||||||
<label name="active"/>
|
<label name="active"/>
|
||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
|
|
||||||
<label name="nextrun_link" colspan="5"/>
|
<label name="nextrun_date" colspan="5"/>
|
||||||
<field name="nextrun_link"/>
|
<field name="nextrun_date"/>
|
||||||
|
|
||||||
<notebook colspan="6">
|
<notebook colspan="6">
|
||||||
<page id="rrule" col="6" string="Recurrence Rule">
|
<page id="rrule" col="6" string="Recurrence Rule">
|
||||||
|
|
|
@ -14,7 +14,7 @@ full copyright notices and license terms. -->
|
||||||
<field name="wfcheck" optional="1"/>
|
<field name="wfcheck" optional="1"/>
|
||||||
|
|
||||||
<field name="cashbook" optional="0"/>
|
<field name="cashbook" optional="0"/>
|
||||||
<field name="nextrun_link" optional="0"/>
|
<field name="nextrun_date" optional="0"/>
|
||||||
<field name="amount" optional="0"/>
|
<field name="amount" optional="0"/>
|
||||||
<field name="bookingtype" optional="0"/>
|
<field name="bookingtype" optional="0"/>
|
||||||
<field name="booking_target" optional="0"/>
|
<field name="booking_target" optional="0"/>
|
||||||
|
|
Loading…
Reference in a new issue