diff --git a/locale/de.po b/locale/de.po
index e8dc999..9d2a64b 100644
--- a/locale/de.po
+++ b/locale/de.po
@@ -3,6 +3,18 @@ msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
+##############
+# ir.message #
+##############
+msgctxt "model:ir.message,text:msg_title_notify"
+msgid "Cashbook Scheduled Booking"
+msgstr "Kassenbuch geplante Buchung"
+
+msgctxt "model:ir.message,text:msg_text_notify"
+msgid "The following transaction was generated: %(bname)s"
+msgstr "Die folgende Buchung wurde erzeugt: %(bname)s"
+
+
###########
# ir.cron #
###########
@@ -386,6 +398,14 @@ msgctxt "help:cashbook.planner,last_day_of_month:"
msgid "The booking is made on the last day of the month."
msgstr "Die Buchung wird am letzten Tag des Monats ausgeführt."
+msgctxt "field:cashbook.planner,notify_bycron:"
+msgid "Notify"
+msgstr "Benachrichtigen"
+
+msgctxt "help:cashbook.planner,notify_bycron:"
+msgid "A notification will appear in the web browser when the booking has been created."
+msgstr "Es wird eine Benachrichtigung im Webbrowser angezeigt wenn die Buchung erstellt wurde."
+
############################
# cashbook.planner.nextrun #
diff --git a/locale/en.po b/locale/en.po
index fc40611..2a86165 100644
--- a/locale/en.po
+++ b/locale/en.po
@@ -2,6 +2,14 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
+msgctxt "model:ir.message,text:msg_title_notify"
+msgid "Cashbook Scheduled Booking"
+msgstr "Cashbook Scheduled Booking"
+
+msgctxt "model:ir.message,text:msg_text_notify"
+msgid "The following transaction was generated: %(bname)s"
+msgstr "The following transaction was generated: %(bname)s"
+
msgctxt "selection:ir.cron,method:"
msgid "Execute scheduled bookings"
msgstr "Execute scheduled bookings"
@@ -389,3 +397,11 @@ msgstr "Last day of the month"
msgctxt "help:cashbook.planner,last_day_of_month:"
msgid "The booking is made on the last day of the month."
msgstr "The booking is made on the last day of the month."
+
+msgctxt "field:cashbook.planner,notify_bycron:"
+msgid "Notify"
+msgstr "Notify"
+
+msgctxt "help:cashbook.planner,notify_bycron:"
+msgid "A notification will appear in the web browser when the booking has been created."
+msgstr "A notification will appear in the web browser when the booking has been created."
diff --git a/message.xml b/message.xml
new file mode 100644
index 0000000..7686921
--- /dev/null
+++ b/message.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ Cashbook Scheduled Booking
+
+
+ The following transaction was generated: %(bname)s
+
+
+
+
diff --git a/planner.py b/planner.py
index 0c60fd3..2435007 100644
--- a/planner.py
+++ b/planner.py
@@ -14,6 +14,7 @@ from trytond.pool import Pool
from trytond.report import Report
from trytond.i18n import gettext
from trytond.pyson import Eval, Bool, If, And
+from trytond.bus import notify
from trytond.modules.currency.fields import Monetary
from trytond.modules.cashbook.book import sel_state_book
from trytond.modules.cashbook.line import sel_bookingtype as sel_bookingtype_cb
@@ -117,6 +118,9 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
string='If no business day', required=True, selection=SEL_MOVE_EVENT,
help='If the date of execution falls on a weekend or holiday, ' +
'it can be moved to a business day.')
+ notify_bycron = fields.Boolean(
+ string='Notify', help='A notification will appear in the web ' +
+ 'browser when the booking has been created.')
bookingtype = fields.Selection(
string='Type', selection=sel_bookingtype, required=True,
@@ -614,6 +618,15 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
IrDate = Pool().get('ir.date')
return IrDate.today()
+ @classmethod
+ def default_notify_bycron(cls):
+ """ get False as default
+
+ Returns:
+ boolean: False
+ """
+ return False
+
@classmethod
def fill_placeholder(cls, linedata):
""" replace placeholder in description
@@ -843,11 +856,27 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
else:
to_create.append(line)
+ to_notify = []
if to_create_check:
lines = Line.create(to_create_check)
Line.wfcheck(lines)
+ to_notify.extend([
+ x for x in lines
+ if x.planners[0].notify_bycron])
+
if to_create:
- Line.create(to_create)
+ lines = Line.create(to_create)
+ to_notify.extend([
+ x for x in lines
+ if x.planners[0].notify_bycron])
+
+ for line in to_notify:
+ notify(
+ title=gettext('cashbook_planner.msg_title_notify'),
+ body=gettext(
+ 'cashbook_planner.msg_text_notify',
+ bname=line.rec_name),
+ user=line.cashbook.owner.id)
@classmethod
def cronjob(cls):
diff --git a/tryton.cfg b/tryton.cfg
index 24da6fd..c51caaf 100644
--- a/tryton.cfg
+++ b/tryton.cfg
@@ -5,6 +5,7 @@ depends:
extras_depend:
cashbook_investment
xml:
+ message.xml
group.xml
planner.xml
nextrun.xml
diff --git a/view/planner_form.xml b/view/planner_form.xml
index 1dcfff3..d7b8fbb 100644
--- a/view/planner_form.xml
+++ b/view/planner_form.xml
@@ -61,7 +61,8 @@ full copyright notices and license terms. -->
-
+
+