From ebb1efe7a81414228d669f9af238d41d085fb38a Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Sat, 24 Feb 2024 23:43:59 +0100 Subject: [PATCH] add menu, groups, planner-list, forms... --- .hgignore | 1 + __init__.py | 6 ++ cashbook.py | 20 ++++++ cashbook.xml | 16 +++++ group.xml | 18 +++++ ir.py | 20 ++++++ locale/de.po | 99 ++++++++++++++++++++++++++ locale/en.po | 44 ++++++++++++ menu.xml | 22 ++++++ planner.py | 68 ++++++++++++++++++ planner.xml | 161 ++++++++++++++++++++++++++++++++++++++++++ tryton.cfg | 4 ++ view/book_form.xml | 14 ++++ view/planner_form.xml | 24 +++++++ view/planner_list.xml | 9 +++ 15 files changed, 526 insertions(+) create mode 100644 cashbook.py create mode 100644 cashbook.xml create mode 100644 group.xml create mode 100644 ir.py create mode 100644 locale/de.po create mode 100644 locale/en.po create mode 100644 menu.xml create mode 100644 planner.py create mode 100644 planner.xml create mode 100644 view/book_form.xml create mode 100644 view/planner_form.xml create mode 100644 view/planner_list.xml diff --git a/.hgignore b/.hgignore index 47c5feb..fe73df3 100644 --- a/.hgignore +++ b/.hgignore @@ -4,3 +4,4 @@ build/* dist/* mds_cashbook_planner.egg-info/* __pycache__/* +locale/convert_de2en.py diff --git a/__init__.py b/__init__.py index 82c1d0a..53c377a 100644 --- a/__init__.py +++ b/__init__.py @@ -4,8 +4,14 @@ # full copyright notices and license terms. from trytond.pool import Pool +from .ir import Rule +from .planner import ScheduledBooking +from .cashbook import Cashbook def register(): Pool.register( + Rule, + ScheduledBooking, + Cashbook, module='cashbook_planner', type_='model') diff --git a/cashbook.py b/cashbook.py new file mode 100644 index 0000000..7c13530 --- /dev/null +++ b/cashbook.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# 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. + + +from trytond.pool import PoolMeta +from trytond.model import fields +from trytond.pyson import Eval, Bool + + +class Cashbook(metaclass=PoolMeta): + __name__ = 'cashbook.book' + + planner = fields.One2Many( + string='Scheduled Bookings', model_name='cashbook.planner', + field='cashbook', depends=['btype'], + states={'invisible': ~Bool(Eval('btype'))}) + +# end Cashbook diff --git a/cashbook.xml b/cashbook.xml new file mode 100644 index 0000000..ae0402f --- /dev/null +++ b/cashbook.xml @@ -0,0 +1,16 @@ + + + + + + + + cashbook.book + + book_form + + + + diff --git a/group.xml b/group.xml new file mode 100644 index 0000000..5ae80f0 --- /dev/null +++ b/group.xml @@ -0,0 +1,18 @@ + + + + + + + Cashbook - Scheduled Bookings + + + + + + + + + diff --git a/ir.py b/ir.py new file mode 100644 index 0000000..7cfd296 --- /dev/null +++ b/ir.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# 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. + +from trytond.pool import PoolMeta + + +class Rule(metaclass=PoolMeta): + __name__ = 'ir.rule' + + @classmethod + def _context_modelnames(cls): + """ list of models to add 'user_id' to context + """ + result = super(Rule, cls)._context_modelnames() + result.append('cashbook.planner') + return result + +# end Rule diff --git a/locale/de.po b/locale/de.po new file mode 100644 index 0000000..de361b3 --- /dev/null +++ b/locale/de.po @@ -0,0 +1,99 @@ +# +msgid "" +msgstr "Content-Type: text/plain; charset=utf-8\n" + + +############# +# res.group # +############# +msgctxt "model:res.group,name:group_planner" +msgid "Cashbook - Scheduled Bookings" +msgstr "Kassenbuch - geplante Buchungen" + + +############## +# ir.ui.menu # +############## +msgctxt "model:ir.ui.menu,name:menu_planner" +msgid "Scheduled Bookings" +msgstr "geplante Buchungen" + + +############# +# ir.action # +############# +msgctxt "model:ir.action,name:act_planner_view" +msgid "Scheduled Bookings" +msgstr "geplante Buchungen" + + +################# +# ir.rule.group # +################# +msgctxt "model:ir.rule.group,name:rg_planner_write_admin" +msgid "Administrators: scheduled bookings read/write" +msgstr "Administratoren: geplante Buchungen schreiben" + +msgctxt "model:ir.rule.group,name:rg_planner_owner" +msgid "Owners: scheduled bookings" +msgstr "Eigentümer: geplante Buchungen" + +msgctxt "model:ir.rule.group,name:rg_planner_read_nonowner" +msgid "Observers: scheduled bookings read" +msgstr "Beobachter: geplante Buchungen lesen" + +msgctxt "model:ir.rule.group,name:rg_planner_write_nonowner" +msgid "Reviewer: scheduled bookings write" +msgstr "Bearbeiter: geplante Buchungen schreiben" + +msgctxt "model:ir.rule.group,name:rg_planner_companies" +msgid "User in companies" +msgstr "Benutzer im Unternehmen" + + +#################### +# cashbook.planner # +#################### +msgctxt "model:cashbook.planner,name:" +msgid "Scheduled Booking" +msgstr "geplante Buchung" + +msgctxt "field:cashbook.planner,company:" +msgid "Company" +msgstr "Unternehmen" + +msgctxt "field:cashbook.planner,cashbook:" +msgid "Cashbook" +msgstr "Kassenbuch" + +msgctxt "help:cashbook.planner,cashbook:" +msgid "Cash book for which the planned posting is to be executed." +msgstr "Kassenbuch für welches die geplante Buchung ausgeführt werden soll." + +msgctxt "field:cashbook.planner,name:" +msgid "Name" +msgstr "Name" + +msgctxt "field:cashbook.planner,description:" +msgid "Description" +msgstr "Beschreibung" + +msgctxt "field:cashbook.planner,start_date:" +msgid "Start Date" +msgstr "Startdatum" + +msgctxt "field:cashbook.planner,end_date:" +msgid "End Date" +msgstr "Endedatum" + + +################# +# cashbook.book # +################# +msgctxt "view:cashbook.book:" +msgid "Scheduled Bookings" +msgstr "geplante Buchungen" + +msgctxt "field:cashbook.book,planner:" +msgid "Scheduled Bookings" +msgstr "geplante Buchungen" diff --git a/locale/en.po b/locale/en.po new file mode 100644 index 0000000..ecc234c --- /dev/null +++ b/locale/en.po @@ -0,0 +1,44 @@ +# +msgid "" +msgstr "Content-Type: text/plain; charset=utf-8\n" + +msgctxt "model:res.group,name:group_planner_read" +msgid "Cashbook - Scheduled Bookings (read)" +msgstr "Cashbook - Scheduled Bookings (read)" + +msgctxt "model:res.group,name:group_planner_write" +msgid "Cashbook - Scheduled Bookings (write)" +msgstr "Cashbook - Scheduled Bookings (write)" + +msgctxt "model:res.group,name:group_planner_admin" +msgid "Cashbook - Scheduled Bookings (admin)" +msgstr "Cashbook - Scheduled Bookings (admin)" + +msgctxt "model:ir.ui.menu,name:menu_planner" +msgid "Scheduled Bookings" +msgstr "Scheduled Bookings" + +msgctxt "model:ir.action,name:act_planner_view" +msgid "Scheduled Bookings" +msgstr "Scheduled Bookings" + +msgctxt "model:ir.rule.group,name:rg_planner_write_admin" +msgid "Administrators: scheduled bookings read/write" +msgstr "Administrators: scheduled bookings read/write" + +msgctxt "model:ir.rule.group,name:rg_planner_owner" +msgid "Owners: scheduled bookings" +msgstr "Owners: scheduled bookings" + +msgctxt "model:ir.rule.group,name:rg_planner_read_nonowner" +msgid "Observers: scheduled bookings read" +msgstr "Observers: scheduled bookings read" + +msgctxt "model:ir.rule.group,name:rg_planner_write_nonowner" +msgid "Reviewer: scheduled bookings write" +msgstr "Reviewer: scheduled bookings write" + +msgctxt "model:ir.rule.group,name:rg_planner_companies" +msgid "User in companies" +msgstr "User in companies" + diff --git a/menu.xml b/menu.xml new file mode 100644 index 0000000..7f16004 --- /dev/null +++ b/menu.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/planner.py b/planner.py new file mode 100644 index 0000000..e7d25d7 --- /dev/null +++ b/planner.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# 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. + +from trytond.model import ModelSQL, ModelView, fields, Index, DeactivableMixin +from trytond.transaction import Transaction +from trytond.pool import Pool +from trytond.pyson import Eval, Bool + +DEF_NONE = None + + +class ScheduledBooking(DeactivableMixin, ModelSQL, ModelView): + 'Scheduled Booking' + __name__ = 'cashbook.planner' + + company = fields.Many2One( + string='Company', model_name='company.company', + required=True, ondelete="RESTRICT") + name = fields.Char(string='Name', required=True) + description = fields.Text(string='Description') + cashbook = fields.Many2One( + string='Cashbook', required=True, + help='Cash book for which the planned posting is to be executed.', + model_name='cashbook.book', ondelete='CASCADE', + domain=[('btype', '!=', None)]) + start_date = fields.Date(string='Start Date', required=True) + end_date = fields.Date( + string='End Date', depends=['start_date'], + states={'readonly': ~Bool(Eval('start_date'))}, + domain=[ + 'OR', + ('end_date', '>', Eval('start_date')), + ('end_date', '=', DEF_NONE)]) + + @classmethod + def __setup__(cls): + super(ScheduledBooking, cls).__setup__() + t = cls.__table__() + cls._sql_indexes.update({ + Index( + t, + (t.company, Index.Equality())), + Index( + t, + (t.start_date, Index.Range(order='ASC'))), + Index( + t, + (t.end_date, Index.Range(order='ASC')), + where=t.end_date != DEF_NONE), + }) + + @staticmethod + def default_company(): + return Transaction().context.get('company') or None + + @classmethod + def default_start_date(cls): + """ get today as start-date + + Returns: + date: date of today + """ + IrDate = Pool().get('ir.date') + return IrDate.today() + +# ens ScheduledBooking diff --git a/planner.xml b/planner.xml new file mode 100644 index 0000000..5146fe1 --- /dev/null +++ b/planner.xml @@ -0,0 +1,161 @@ + + + + + + + + cashbook.planner + tree + + planner_list + + + cashbook.planner + form + + planner_form + + + + + Scheduled Bookings + cashbook.planner + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Administrators: scheduled bookings read/write + + + + + + + + + + + + + + + + + + + + Owners: scheduled bookings + + + + + + + + + + + + + + + + + + + + Observers: scheduled bookings read + + + + + + + + + + + + + + + + + + + + Reviewer: scheduled bookings write + + + + + + + + + + + + + + + + + + User in companies + + + + + + + + + + diff --git a/tryton.cfg b/tryton.cfg index 7699e24..5c94af5 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -5,3 +5,7 @@ depends: extras_depend: cashbook_investment xml: + group.xml + planner.xml + cashbook.xml + menu.xml diff --git a/view/book_form.xml b/view/book_form.xml new file mode 100644 index 0000000..f83d8ae --- /dev/null +++ b/view/book_form.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/view/planner_form.xml b/view/planner_form.xml new file mode 100644 index 0000000..2eb2129 --- /dev/null +++ b/view/planner_form.xml @@ -0,0 +1,24 @@ + + +
+