add list of booking lines on scheduled bookings
This commit is contained in:
parent
be92110ae1
commit
9b0af0d64e
7 changed files with 118 additions and 3 deletions
|
@ -5,8 +5,8 @@
|
|||
|
||||
from trytond.pool import Pool
|
||||
from .ir import Rule
|
||||
from .planner import ScheduledBooking
|
||||
from .cashbook import Cashbook
|
||||
from .planner import ScheduledBooking, ScheduledBookingCashbookRel
|
||||
from .cashbook import Cashbook, CashbookLine
|
||||
from .cron import Cron
|
||||
from .nextrun import NextRun
|
||||
|
||||
|
@ -17,5 +17,7 @@ def register():
|
|||
ScheduledBooking,
|
||||
NextRun,
|
||||
Cashbook,
|
||||
CashbookLine,
|
||||
Cron,
|
||||
ScheduledBookingCashbookRel,
|
||||
module='cashbook_planner', type_='model')
|
||||
|
|
10
cashbook.py
10
cashbook.py
|
@ -18,3 +18,13 @@ class Cashbook(metaclass=PoolMeta):
|
|||
states={'invisible': ~Bool(Eval('btype'))})
|
||||
|
||||
# end Cashbook
|
||||
|
||||
|
||||
class CashbookLine(metaclass=PoolMeta):
|
||||
__name__ = 'cashbook.line'
|
||||
|
||||
planners = fields.Many2Many(
|
||||
string='Scheduled Bookings', relation_name='cashbook.planner_rel',
|
||||
origin='line', target='planner')
|
||||
|
||||
# end CashbookLine
|
||||
|
|
40
locale/de.po
40
locale/de.po
|
@ -110,6 +110,10 @@ msgctxt "view:cashbook.planner:"
|
|||
msgid "Available placeholders: ${date} ${month} ${year} ${amount} ${quantity}"
|
||||
msgstr "verfügbare Platzhalter: ${date} ${month} ${year} ${amount} ${quantity}"
|
||||
|
||||
msgctxt "view:cashbook.planner:"
|
||||
msgid "Cashbook lines"
|
||||
msgstr "Kassenbuchzeilen"
|
||||
|
||||
msgctxt "field:cashbook.planner,company:"
|
||||
msgid "Company"
|
||||
msgstr "Unternehmen"
|
||||
|
@ -306,6 +310,14 @@ msgctxt "field:cashbook.planner,booking_target:"
|
|||
msgid "Target"
|
||||
msgstr "Ziel"
|
||||
|
||||
msgctxt "field:cashbook.planner,cashbook_lines:"
|
||||
msgid "Cashbook lines"
|
||||
msgstr "Kassenbuchzeilen"
|
||||
|
||||
msgctxt "help:cashbook.planner,cashbook_lines:"
|
||||
msgid "This cash book lines was generated by the current scheduled booking."
|
||||
msgstr "Diese Kassenbuchzeilen wurden durch die aktuelle geplante Buchung generiert."
|
||||
|
||||
|
||||
############################
|
||||
# cashbook.planner.nextrun #
|
||||
|
@ -323,6 +335,22 @@ msgid "Date"
|
|||
msgstr "Datum"
|
||||
|
||||
|
||||
########################
|
||||
# cashbook.planner_rel #
|
||||
########################
|
||||
msgctxt "model:cashbook.planner_rel,name:"
|
||||
msgid "Scheduled Booking - Cashbook - Relation"
|
||||
msgstr "geplante Buchung - Kassenbuch - Verknüpfung"
|
||||
|
||||
msgctxt "field:cashbook.planner_rel,planner:"
|
||||
msgid "Planner"
|
||||
msgstr "geplante Buchung"
|
||||
|
||||
msgctxt "field:cashbook.planner_rel,line:"
|
||||
msgid "Cashbook Line"
|
||||
msgstr "Kassenbuchzeile"
|
||||
|
||||
|
||||
#################
|
||||
# cashbook.book #
|
||||
#################
|
||||
|
@ -333,3 +361,15 @@ msgstr "geplante Buchungen"
|
|||
msgctxt "field:cashbook.book,planner:"
|
||||
msgid "Scheduled Bookings"
|
||||
msgstr "geplante Buchungen"
|
||||
|
||||
|
||||
#################
|
||||
# cashbook.line #
|
||||
#################
|
||||
msgctxt "view:cashbook.line:"
|
||||
msgid "Scheduled Bookings"
|
||||
msgstr "geplante Buchungen"
|
||||
|
||||
msgctxt "field:cashbook.line,planners:"
|
||||
msgid "Scheduled Bookings"
|
||||
msgstr "geplante Buchungen"
|
||||
|
|
32
locale/en.po
32
locale/en.po
|
@ -86,6 +86,10 @@ msgctxt "view:cashbook.planner:"
|
|||
msgid "Available placeholders: ${date} ${month} ${year} ${amount} ${quantity}"
|
||||
msgstr "Available placeholders: ${date} ${month} ${year} ${amount} ${quantity}"
|
||||
|
||||
msgctxt "view:cashbook.planner:"
|
||||
msgid "Cashbook lines"
|
||||
msgstr "Cashbook lines"
|
||||
|
||||
msgctxt "field:cashbook.planner,company:"
|
||||
msgid "Company"
|
||||
msgstr "Company"
|
||||
|
@ -282,6 +286,14 @@ msgctxt "field:cashbook.planner,booking_target:"
|
|||
msgid "Target"
|
||||
msgstr "Target"
|
||||
|
||||
msgctxt "field:cashbook.planner,cashbook_lines:"
|
||||
msgid "Cashbook lines"
|
||||
msgstr "Cashbook lines"
|
||||
|
||||
msgctxt "help:cashbook.planner,cashbook_lines:"
|
||||
msgid "This cash book lines was generated by the current scheduled booking."
|
||||
msgstr "This cash book lines was generated by the current scheduled booking."
|
||||
|
||||
msgctxt "model:cashbook.planner.nextrun,name:"
|
||||
msgid "Next Execution Date"
|
||||
msgstr "Next Execution Date"
|
||||
|
@ -294,7 +306,27 @@ msgctxt "field:cashbook.planner.nextrun,date:"
|
|||
msgid "Date"
|
||||
msgstr "Date"
|
||||
|
||||
msgctxt "model:cashbook.planner_rel,name:"
|
||||
msgid "Scheduled Booking - Cashbook - Relation"
|
||||
msgstr "Scheduled Booking - Cashbook - Relation"
|
||||
|
||||
msgctxt "field:cashbook.planner_rel,planner:"
|
||||
msgid "Planner"
|
||||
msgstr "Planner"
|
||||
|
||||
msgctxt "field:cashbook.planner_rel,line:"
|
||||
msgid "Cashbook Line"
|
||||
msgstr "Cashbook Line"
|
||||
|
||||
msgctxt "view:cashbook.book:"
|
||||
msgid "Scheduled Bookings"
|
||||
msgstr "Scheduled Bookings"
|
||||
|
||||
msgctxt "field:cashbook.book,planner:"
|
||||
msgid "Scheduled Bookings"
|
||||
msgstr "Scheduled Bookings"
|
||||
|
||||
msgctxt "view:cashbook.line:"
|
||||
msgid "Scheduled Bookings"
|
||||
msgstr "Scheduled Bookings"
|
||||
|
||||
|
|
21
planner.py
21
planner.py
|
@ -151,6 +151,10 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
|||
booking_target = fields.Function(fields.Reference(
|
||||
string='Target', selection='get_booking_modelnames', readonly=True),
|
||||
'on_change_with_booking_target')
|
||||
cashbook_lines = fields.Many2Many(
|
||||
string='Cashbook lines', relation_name='cashbook.planner_rel',
|
||||
help='This cash book lines was generated by the current ' +
|
||||
'scheduled booking.', origin='planner', target='line')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -664,6 +668,7 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
|||
line.update(add_asset_values(
|
||||
line, record.cashbook, record.booktransf))
|
||||
line['description'] = cls.fill_placeholder(line)
|
||||
line['planners'] = [('add', [record.id])]
|
||||
|
||||
if record.wfcheck:
|
||||
to_create_check.append(line)
|
||||
|
@ -694,4 +699,18 @@ class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView):
|
|||
records,
|
||||
query_date=query_date + timedelta(days=1))
|
||||
|
||||
# ens ScheduledBooking
|
||||
# end ScheduledBooking
|
||||
|
||||
|
||||
class ScheduledBookingCashbookRel(ModelSQL):
|
||||
'Scheduled Booking - Cashbook Line - Relation'
|
||||
__name__ = 'cashbook.planner_rel'
|
||||
|
||||
planner = fields.Many2One(
|
||||
string='Scheduled Booking', required=True,
|
||||
model_name='cashbook.planner', ondelete='CASCADE')
|
||||
line = fields.Many2One(
|
||||
string='Cashbook Line', required=True,
|
||||
model_name='cashbook.line', ondelete='CASCADE')
|
||||
|
||||
# end ScheduledBookingCashbookRel
|
||||
|
|
|
@ -407,12 +407,21 @@ class PlannerTestCase(object):
|
|||
|
||||
job, = Planner.search([])
|
||||
self.assertEqual(job.nextrun[0].date, date(2022, 6, 1))
|
||||
self.assertEqual(len(job.cashbook_lines), 0)
|
||||
|
||||
IrDate.today = MagicMock(return_value=date(2022, 6, 1))
|
||||
Planner.cronjob()
|
||||
self.assertEqual(job.nextrun[0].date, date(2022, 7, 1))
|
||||
self.assertEqual(len(job.cashbook_lines), 1)
|
||||
self.assertEqual(
|
||||
job.cashbook_lines[0].rec_name,
|
||||
'06/01/2022|Exp|-10.00 usd|booking 6/2022, 06/01/2022 [Cat1]')
|
||||
|
||||
# check cashbook
|
||||
self.assertEqual(len(job.cashbook.lines), 1)
|
||||
self.assertEqual(len(job.cashbook.lines[0].planners), 1)
|
||||
self.assertEqual(job.cashbook.lines[0].planners[0].id, job.id)
|
||||
|
||||
self.assertEqual(
|
||||
job.cashbook.lines[0].rec_name,
|
||||
"06/01/2022|Exp|-10.00 usd|booking 6/2022, 06/01/2022 [Cat1]")
|
||||
|
|
|
@ -64,6 +64,9 @@ full copyright notices and license terms. -->
|
|||
<page name="description" col="1" string="Description">
|
||||
<field name="description"/>
|
||||
</page>
|
||||
<page name="cashbook_lines" col="1" string="Cashbook lines">
|
||||
<field name="cashbook_lines"/>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue