add menu, groups, planner-list, forms...

This commit is contained in:
Frederik Jaeckel 2024-02-24 23:43:59 +01:00
parent cd79072e2c
commit ebb1efe7a8
15 changed files with 526 additions and 0 deletions

View file

@ -4,3 +4,4 @@ build/*
dist/* dist/*
mds_cashbook_planner.egg-info/* mds_cashbook_planner.egg-info/*
__pycache__/* __pycache__/*
locale/convert_de2en.py

View file

@ -4,8 +4,14 @@
# full copyright notices and license terms. # full copyright notices and license terms.
from trytond.pool import Pool from trytond.pool import Pool
from .ir import Rule
from .planner import ScheduledBooking
from .cashbook import Cashbook
def register(): def register():
Pool.register( Pool.register(
Rule,
ScheduledBooking,
Cashbook,
module='cashbook_planner', type_='model') module='cashbook_planner', type_='model')

20
cashbook.py Normal file
View file

@ -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

16
cashbook.xml Normal file
View 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>
<!-- views -->
<record model="ir.ui.view" id="book_view_form">
<field name="model">cashbook.book</field>
<field name="inherit" ref="cashbook.book_view_form"/>
<field name="name">book_form</field>
</record>
</data>
</tryton>

18
group.xml Normal file
View file

@ -0,0 +1,18 @@
<?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="res.group" id="group_planner">
<field name="name">Cashbook - Scheduled Bookings</field>
</record>
<record model="res.user-res.group" id="user_admin-group_planner">
<field name="user" ref="res.user_admin"/>
<field name="group" ref="group_planner"/>
</record>
</data>
</tryton>

20
ir.py Normal file
View file

@ -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

99
locale/de.po Normal file
View file

@ -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"

44
locale/en.po Normal file
View file

@ -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"

22
menu.xml Normal file
View file

@ -0,0 +1,22 @@
<?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>
<!-- menu: /Cashbook/Scheduled Bookings -->
<menuitem id="menu_planner" action="act_planner_view"
icon="tryton-list"
parent="cashbook.menu_cashbook" sequence="50"/>
<record model="ir.ui.menu-res.group" id="menu_planner-group_planner">
<field name="menu" ref="menu_planner"/>
<field name="group" ref="group_planner"/>
</record>
<record model="ir.ui.menu-res.group" id="menu_planner-group_cashbook_admin">
<field name="menu" ref="menu_planner"/>
<field name="group" ref="cashbook.group_cashbook_admin"/>
</record>
</data>
</tryton>

68
planner.py Normal file
View file

@ -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

161
planner.xml Normal file
View file

@ -0,0 +1,161 @@
<?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>
<!-- views -->
<record model="ir.ui.view" id="planner_view_list">
<field name="model">cashbook.planner</field>
<field name="type">tree</field>
<field name="priority" eval="10"/>
<field name="name">planner_list</field>
</record>
<record model="ir.ui.view" id="planner_view_form">
<field name="model">cashbook.planner</field>
<field name="type">form</field>
<field name="priority" eval="20"/>
<field name="name">planner_form</field>
</record>
<!-- action view - list -->
<record model="ir.action.act_window" id="act_planner_view">
<field name="name">Scheduled Bookings</field>
<field name="res_model">cashbook.planner</field>
</record>
<record model="ir.action.act_window.view" id="act_planner_view-1">
<field name="sequence" eval="10"/>
<field name="view" ref="planner_view_list"/>
<field name="act_window" ref="act_planner_view"/>
</record>
<record model="ir.action.act_window.view" id="act_planner_view-2">
<field name="sequence" eval="20"/>
<field name="view" ref="planner_view_form"/>
<field name="act_window" ref="act_planner_view"/>
</record>
<!-- permission -->
<!-- anon: deny all -->
<record model="ir.model.access" id="access_planner-anon">
<field name="model" search="[('model', '=', 'cashbook.planner')]"/>
<field name="perm_read" eval="False"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<!-- group_planner_write: read/write -->
<record model="ir.model.access" id="access_planner-group_planner">
<field name="model" search="[('model', '=', 'cashbook.planner')]"/>
<field name="group" ref="group_planner"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<!-- permission by rule - admin-write -->
<record model="ir.rule.group" id="rg_planner_admin">
<field name="model" search="[('model', '=', 'cashbook.planner')]"/>
<field name="name">Administrators: scheduled bookings read/write</field>
<field name="global_p" eval="False"/>
<field name="default_p" eval="False"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.rule" id="rg_planner_admin-1">
<field name="domain" eval="[]" pyson="1"/>
<field name="rule_group" ref="rg_planner_admin"/>
</record>
<record model="ir.rule.group-res.group"
id="rg_planner_admin-group_cashbook_admin">
<field name="rule_group" ref="rg_planner_admin"/>
<field name="group" ref="cashbook.group_cashbook_admin"/>
</record>
<!-- permission by rule - read/write: owner -->
<record model="ir.rule.group" id="rg_planner_owner">
<field name="model" search="[('model', '=', 'cashbook.planner')]"/>
<field name="name">Owners: scheduled bookings</field>
<field name="global_p" eval="False"/>
<field name="default_p" eval="False"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.rule" id="rg_planner_owner-1">
<field name="domain" eval="[
('cashbook.owner.id', '=', Eval('user_id', -1)),
]" pyson="1"/>
<field name="rule_group" ref="rg_planner_owner"/>
</record>
<record model="ir.rule.group-res.group"
id="rg_planner_owner-group_planner">
<field name="rule_group" ref="rg_planner_owner"/>
<field name="group" ref="group_planner"/>
</record>
<!-- permission by rule - read: observer -->
<record model="ir.rule.group" id="rg_planner_read_nonowner">
<field name="model" search="[('model', '=', 'cashbook.planner')]"/>
<field name="name">Observers: scheduled bookings read</field>
<field name="global_p" eval="False"/>
<field name="default_p" eval="False"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_delete" eval="False"/>
</record>
<record model="ir.rule" id="rg_planner_read_nonowner-1">
<field name="domain" eval="[
('cashbook.observer.id', 'in', Eval('groups', [])),
]" pyson="1"/>
<field name="rule_group" ref="rg_planner_read_nonowner"/>
</record>
<record model="ir.rule.group-res.group"
id="rg_planner_read_nonowner-group_planner">
<field name="rule_group" ref="rg_planner_read_nonowner"/>
<field name="group" ref="group_planner"/>
</record>
<!-- permission by rule - write: reviewer -->
<record model="ir.rule.group" id="rg_planner_write_nonowner">
<field name="model" search="[('model', '=', 'cashbook.planner')]"/>
<field name="name">Reviewer: scheduled bookings write</field>
<field name="global_p" eval="False"/>
<field name="default_p" eval="False"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="perm_delete" eval="True"/>
</record>
<record model="ir.rule" id="rg_planner_write_nonowner-1">
<field name="domain" eval="[
('cashbook.reviewer.id', 'in', Eval('groups', [])),
]" pyson="1"/>
<field name="rule_group" ref="rg_planner_write_nonowner"/>
</record>
<record model="ir.rule.group-res.group"
id="rg_planner_write_nonowner-group_planner">
<field name="rule_group" ref="rg_planner_write_nonowner"/>
<field name="group" ref="group_planner"/>
</record>
<record model="ir.rule.group" id="rg_planner_companies">
<field name="name">User in companies</field>
<field name="model"
search="[('model', '=', 'cashbook.planner')]"/>
<field name="global_p" eval="True"/>
</record>
<record model="ir.rule" id="r_planner_companies">
<field name="domain"
eval="[('company', 'in', Eval('companies', []))]"
pyson="1"/>
<field name="rule_group" ref="rg_planner_companies"/>
</record>
</data>
</tryton>

View file

@ -5,3 +5,7 @@ depends:
extras_depend: extras_depend:
cashbook_investment cashbook_investment
xml: xml:
group.xml
planner.xml
cashbook.xml
menu.xml

14
view/book_form.xml Normal file
View file

@ -0,0 +1,14 @@
<?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. -->
<data>
<xpath expr="/form/notebook/page[@id='pggeneral']" position="after">
<page name="planner" string="Scheduled Bookings" col="1">
<field name="planner"/>
</page>
</xpath>
</data>

24
view/planner_form.xml Normal file
View file

@ -0,0 +1,24 @@
<?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. -->
<form col="4">
<label name="cashbook"/>
<field name="cashbook" colspan="3"/>
<label name="name"/>
<field name="name"/>
<label name="active"/>
<field name="active"/>
<label name="start_date"/>
<field name="start_date"/>
<label name="end_date"/>
<field name="end_date"/>
<label name="description"/>
<newline/>
<field name="description" colspan="4"/>
</form>

9
view/planner_list.xml Normal file
View file

@ -0,0 +1,9 @@
<?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. -->
<tree>
<field name="active"/>
<field name="name"/>
<field name="cashbook"/>
</tree>