add button 'execute booking now'
This commit is contained in:
parent
181f7405d6
commit
321aeb827d
6 changed files with 69 additions and 3 deletions
12
locale/de.po
12
locale/de.po
|
@ -35,6 +35,18 @@ msgid "Scheduled Bookings"
|
||||||
msgstr "geplante Buchungen"
|
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 #
|
# ir.rule.group #
|
||||||
#################
|
#################
|
||||||
|
|
|
@ -18,6 +18,14 @@ msgctxt "model:ir.action,name:act_planner_view"
|
||||||
msgid "Scheduled Bookings"
|
msgid "Scheduled Bookings"
|
||||||
msgstr "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"
|
msgctxt "model:ir.rule.group,name:rg_planner_admin"
|
||||||
msgid "Administrators: scheduled bookings read/write"
|
msgid "Administrators: scheduled bookings read/write"
|
||||||
msgstr "Administrators: scheduled bookings read/write"
|
msgstr "Administrators: scheduled bookings read/write"
|
||||||
|
|
20
planner.py
20
planner.py
|
@ -187,8 +187,10 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
||||||
Index(
|
Index(
|
||||||
t,
|
t,
|
||||||
(t.end_date, Index.Range(order='ASC')),
|
(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):
|
def get_rec_name(self, name=None):
|
||||||
""" get formatted name of record
|
""" get formatted name of record
|
||||||
|
@ -730,6 +732,20 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
||||||
if to_write:
|
if to_write:
|
||||||
NextRun.write(*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
|
@classmethod
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
""" update nextrun-records on create of planner-records
|
""" update nextrun-records on create of planner-records
|
||||||
|
|
12
planner.xml
12
planner.xml
|
@ -157,5 +157,17 @@ full copyright notices and license terms. -->
|
||||||
<field name="rule_group" ref="rg_planner_companies"/>
|
<field name="rule_group" ref="rg_planner_companies"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<!-- button -->
|
||||||
|
<record model="ir.model.button" id="book_now_button">
|
||||||
|
<field name="name">booknow</field>
|
||||||
|
<field name="string">Execute Booking Now</field>
|
||||||
|
<field name="help">The planned booking is brought forward and executed now. The next posting is then scheduled regularly for the following execution.</field>
|
||||||
|
<field name="model" search="[('model', '=', 'cashbook.planner')]"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.model.button-res.group" id="book_now_button-group_planner">
|
||||||
|
<field name="button" ref="book_now_button"/>
|
||||||
|
<field name="group" ref="group_planner"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
|
@ -388,6 +388,23 @@ class PlannerTestCase(object):
|
||||||
'setpos': 5, 'monthday': None, 'weekday': '2',
|
'setpos': 5, 'monthday': None, 'weekday': '2',
|
||||||
'end_date': None}])
|
'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()
|
@with_transaction()
|
||||||
def test_planner_create_update_nextrun(self):
|
def test_planner_create_update_nextrun(self):
|
||||||
""" create job, check nextrun-record
|
""" create job, check nextrun-record
|
||||||
|
|
|
@ -12,7 +12,8 @@ full copyright notices and license terms. -->
|
||||||
<label name="active"/>
|
<label name="active"/>
|
||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
|
|
||||||
<label name="nextrun_date" colspan="5"/>
|
<button colspan="2" name="booknow"/>
|
||||||
|
<label name="nextrun_date" colspan="3"/>
|
||||||
<field name="nextrun_date"/>
|
<field name="nextrun_date"/>
|
||||||
|
|
||||||
<notebook colspan="6">
|
<notebook colspan="6">
|
||||||
|
|
Loading…
Reference in a new issue