add notify
This commit is contained in:
parent
321aeb827d
commit
7504c676e7
6 changed files with 85 additions and 2 deletions
20
locale/de.po
20
locale/de.po
|
@ -3,6 +3,18 @@ msgid ""
|
||||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
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 #
|
# 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."
|
msgid "The booking is made on the last day of the month."
|
||||||
msgstr "Die Buchung wird am letzten Tag des Monats ausgeführt."
|
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 #
|
# cashbook.planner.nextrun #
|
||||||
|
|
16
locale/en.po
16
locale/en.po
|
@ -2,6 +2,14 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
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:"
|
msgctxt "selection:ir.cron,method:"
|
||||||
msgid "Execute scheduled bookings"
|
msgid "Execute scheduled bookings"
|
||||||
msgstr "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:"
|
msgctxt "help:cashbook.planner,last_day_of_month:"
|
||||||
msgid "The booking is made on the last day of the 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."
|
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."
|
||||||
|
|
16
message.xml
Normal file
16
message.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of the cashbook-planner from m-ds for Tryton.
|
||||||
|
The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
full copyright notices and license terms. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record model="ir.message" id="msg_title_notify">
|
||||||
|
<field name="text">Cashbook Scheduled Booking</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.message" id="msg_text_notify">
|
||||||
|
<field name="text">The following transaction was generated: %(bname)s</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</tryton>
|
31
planner.py
31
planner.py
|
@ -14,6 +14,7 @@ from trytond.pool import Pool
|
||||||
from trytond.report import Report
|
from trytond.report import Report
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.pyson import Eval, Bool, If, And
|
from trytond.pyson import Eval, Bool, If, And
|
||||||
|
from trytond.bus import notify
|
||||||
from trytond.modules.currency.fields import Monetary
|
from trytond.modules.currency.fields import Monetary
|
||||||
from trytond.modules.cashbook.book import sel_state_book
|
from trytond.modules.cashbook.book import sel_state_book
|
||||||
from trytond.modules.cashbook.line import sel_bookingtype as sel_bookingtype_cb
|
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,
|
string='If no business day', required=True, selection=SEL_MOVE_EVENT,
|
||||||
help='If the date of execution falls on a weekend or holiday, ' +
|
help='If the date of execution falls on a weekend or holiday, ' +
|
||||||
'it can be moved to a business day.')
|
'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(
|
bookingtype = fields.Selection(
|
||||||
string='Type', selection=sel_bookingtype, required=True,
|
string='Type', selection=sel_bookingtype, required=True,
|
||||||
|
@ -614,6 +618,15 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
||||||
IrDate = Pool().get('ir.date')
|
IrDate = Pool().get('ir.date')
|
||||||
return IrDate.today()
|
return IrDate.today()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def default_notify_bycron(cls):
|
||||||
|
""" get False as default
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
boolean: False
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fill_placeholder(cls, linedata):
|
def fill_placeholder(cls, linedata):
|
||||||
""" replace placeholder in description
|
""" replace placeholder in description
|
||||||
|
@ -843,11 +856,27 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
||||||
else:
|
else:
|
||||||
to_create.append(line)
|
to_create.append(line)
|
||||||
|
|
||||||
|
to_notify = []
|
||||||
if to_create_check:
|
if to_create_check:
|
||||||
lines = Line.create(to_create_check)
|
lines = Line.create(to_create_check)
|
||||||
Line.wfcheck(lines)
|
Line.wfcheck(lines)
|
||||||
|
to_notify.extend([
|
||||||
|
x for x in lines
|
||||||
|
if x.planners[0].notify_bycron])
|
||||||
|
|
||||||
if to_create:
|
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
|
@classmethod
|
||||||
def cronjob(cls):
|
def cronjob(cls):
|
||||||
|
|
|
@ -5,6 +5,7 @@ depends:
|
||||||
extras_depend:
|
extras_depend:
|
||||||
cashbook_investment
|
cashbook_investment
|
||||||
xml:
|
xml:
|
||||||
|
message.xml
|
||||||
group.xml
|
group.xml
|
||||||
planner.xml
|
planner.xml
|
||||||
nextrun.xml
|
nextrun.xml
|
||||||
|
|
|
@ -61,7 +61,8 @@ full copyright notices and license terms. -->
|
||||||
|
|
||||||
<label name="wfcheck"/>
|
<label name="wfcheck"/>
|
||||||
<field name="wfcheck"/>
|
<field name="wfcheck"/>
|
||||||
<newline/>
|
<label name="notify_bycron"/>
|
||||||
|
<field name="notify_bycron"/>
|
||||||
|
|
||||||
<separator name="subject" colspan="4" string="Booking text"/>
|
<separator name="subject" colspan="4" string="Booking text"/>
|
||||||
<field name="subject" colspan="4"/>
|
<field name="subject" colspan="4"/>
|
||||||
|
|
Loading…
Reference in a new issue