diff --git a/locale/de.po b/locale/de.po
index 4720fa4..e8dc999 100644
--- a/locale/de.po
+++ b/locale/de.po
@@ -35,6 +35,18 @@ msgid "Scheduled Bookings"
msgstr "geplante Buchungen"
+###################
+# ir.model.button #
+###################
+msgctxt "model:ir.model.button,string:book_now_button"
+msgid "Execute Booking Now"
+msgstr "Buchung jetzt ausführen"
+
+msgctxt "model:ir.model.button,help:book_now_button"
+msgid "The planned booking is brought forward and executed now. The next posting is then scheduled regularly for the following execution."
+msgstr "Die geplante Buchung wird vorgezogen und jetzt ausgeführt. Die nächste Buchung wird dann regulär für die nachfolgende Ausführung geplant."
+
+
#################
# ir.rule.group #
#################
diff --git a/locale/en.po b/locale/en.po
index ea5519a..fc40611 100644
--- a/locale/en.po
+++ b/locale/en.po
@@ -18,6 +18,14 @@ msgctxt "model:ir.action,name:act_planner_view"
msgid "Scheduled Bookings"
msgstr "Scheduled Bookings"
+msgctxt "model:ir.model.button,string:book_now_button"
+msgid "Execute Booking Now"
+msgstr "Execute Booking Now"
+
+msgctxt "model:ir.model.button,help:book_now_button"
+msgid "The planned booking is brought forward and executed now. The next posting is then scheduled regularly for the following execution."
+msgstr "The planned booking is brought forward and executed now. The next posting is then scheduled regularly for the following execution."
+
msgctxt "model:ir.rule.group,name:rg_planner_admin"
msgid "Administrators: scheduled bookings read/write"
msgstr "Administrators: scheduled bookings read/write"
diff --git a/planner.py b/planner.py
index 3bfc436..0c60fd3 100644
--- a/planner.py
+++ b/planner.py
@@ -187,8 +187,10 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
Index(
t,
(t.end_date, Index.Range(order='ASC')),
- where=t.end_date != DEF_NONE),
- })
+ where=t.end_date != DEF_NONE)})
+ cls._buttons.update({
+ 'booknow': {'readonly': ~Eval('active', False)},
+ })
def get_rec_name(self, name=None):
""" get formatted name of record
@@ -730,6 +732,20 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
if to_write:
NextRun.write(*to_write)
+ @classmethod
+ @ModelView.button
+ def booknow(cls, records):
+ """ run planned booking now
+ """
+ to_work = [x for x in records if x.active and x.nextrun_date]
+ cls.run_booking(to_work)
+
+ for record in to_work:
+ if record.active:
+ cls.update_next_occurence(
+ [record],
+ query_date=record.nextrun_date + timedelta(days=1))
+
@classmethod
def create(cls, vlist):
""" update nextrun-records on create of planner-records
diff --git a/planner.xml b/planner.xml
index 5146fe1..df428fc 100644
--- a/planner.xml
+++ b/planner.xml
@@ -157,5 +157,17 @@ full copyright notices and license terms. -->
+
+
+ booknow
+ Execute Booking Now
+ The planned booking is brought forward and executed now. The next posting is then scheduled regularly for the following execution.
+
+
+
+
+
+
+
diff --git a/tests/planner.py b/tests/planner.py
index 23e20f4..29271f5 100644
--- a/tests/planner.py
+++ b/tests/planner.py
@@ -388,6 +388,23 @@ class PlannerTestCase(object):
'setpos': 5, 'monthday': None, 'weekday': '2',
'end_date': None}])
+ @with_transaction()
+ def test_planner_run_booking_now(self):
+ """ create job, press button 'booknow'
+ """
+ Planner = Pool().get('cashbook.planner')
+
+ job = self.prep_create_job()
+ self.assertEqual(
+ job.rec_name, "Job 1|Book 1|Exp|Cat1|05/01/2022|usd0.00")
+ self.assertEqual(
+ job._compute_dates_by_rrule(
+ count=1, query_date=date(2022, 5, 1)), [
+ date(2022, 5, 1)])
+ Planner.booknow([job])
+ self.assertEqual(
+ job.rec_name, "Job 1|Book 1|Exp|Cat1|06/01/2022|usd0.00")
+
@with_transaction()
def test_planner_create_update_nextrun(self):
""" create job, check nextrun-record
diff --git a/view/planner_form.xml b/view/planner_form.xml
index f9d6547..1dcfff3 100644
--- a/view/planner_form.xml
+++ b/view/planner_form.xml
@@ -12,7 +12,8 @@ full copyright notices and license terms. -->
-
+
+