Compare commits
26 commits
ver_6.8.33
...
main
Author | SHA1 | Date | |
---|---|---|---|
![]() |
08d8121f57 | ||
![]() |
6aca58bcc2 | ||
![]() |
400ebed692 | ||
![]() |
865a2c7fa6 | ||
![]() |
852ff6871d | ||
![]() |
65437bc52e | ||
![]() |
206cd1e0e5 | ||
![]() |
d0f5b0aa38 | ||
![]() |
52011f5166 | ||
![]() |
f9e55fab77 | ||
![]() |
0442591d52 | ||
![]() |
5ef3a52fdc | ||
![]() |
5d8f924960 | ||
![]() |
9ef465f40f | ||
![]() |
d2ad96db35 | ||
![]() |
e79bcca989 | ||
![]() |
52e788db17 | ||
![]() |
72f0325a71 | ||
![]() |
7e6d2660ad | ||
![]() |
cf92b2d7b5 | ||
![]() |
7062399319 | ||
![]() |
fbdc68c642 | ||
![]() |
7220cff5ac | ||
![]() |
77ee7d15b7 | ||
![]() |
90298d3eb8 | ||
![]() |
e605d5f0d3 |
49 changed files with 2445 additions and 589 deletions
3
.hgignore → .gitignore
vendored
3
.hgignore → .gitignore
vendored
|
@ -1,7 +1,8 @@
|
||||||
syntax: glob
|
*.pyc
|
||||||
build/*
|
build/*
|
||||||
dist/*
|
dist/*
|
||||||
mds_cashbook.egg-info/*
|
mds_cashbook.egg-info/*
|
||||||
locale/convert_de2en.py
|
locale/convert_de2en.py
|
||||||
__pycache__/*
|
__pycache__/*
|
||||||
.pytest_cache/*
|
.pytest_cache/*
|
||||||
|
.env
|
16
COPYRIGHT
Normal file
16
COPYRIGHT
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
Copyright (C) 2015-2023 Cédric Krier.
|
||||||
|
Copyright (C) 2015-2023 B2CK SPRL.
|
||||||
|
Copyright (C) 2021-2024 martin-data services.
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
674
LICENSE
Normal file
674
LICENSE
Normal file
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
4
MANIFEST.in
Normal file
4
MANIFEST.in
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
include LICENSE
|
||||||
|
include COPYRIGHT
|
||||||
|
include README.rst
|
||||||
|
include versiondep.txt
|
|
@ -9,7 +9,7 @@ pip install mds-cashbook
|
||||||
|
|
||||||
Requires
|
Requires
|
||||||
========
|
========
|
||||||
- Tryton 6.0
|
- Tryton 7.0
|
||||||
|
|
||||||
How to
|
How to
|
||||||
======
|
======
|
||||||
|
@ -153,6 +153,6 @@ currency are converted into the display currency of the parent cash book.
|
||||||
Changes
|
Changes
|
||||||
=======
|
=======
|
||||||
|
|
||||||
*6.0.0 - 05.08.2022*
|
*7.0.0 - 30.11.2023*
|
||||||
|
|
||||||
- init
|
- compatibility to Tryton 7.0
|
||||||
|
|
|
@ -16,12 +16,13 @@ from .category import Category
|
||||||
from .reconciliation import Reconciliation
|
from .reconciliation import Reconciliation
|
||||||
from .cbreport import ReconciliationReport
|
from .cbreport import ReconciliationReport
|
||||||
from .currency import CurrencyRate
|
from .currency import CurrencyRate
|
||||||
from .model import MemCache
|
from .valuestore import ValueStore
|
||||||
|
from .ir import Rule
|
||||||
|
from .cron import Cron
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
MemCache,
|
|
||||||
Configuration,
|
Configuration,
|
||||||
UserConfiguration,
|
UserConfiguration,
|
||||||
CurrencyRate,
|
CurrencyRate,
|
||||||
|
@ -35,6 +36,9 @@ def register():
|
||||||
OpenCashBookStart,
|
OpenCashBookStart,
|
||||||
RunCbReportStart,
|
RunCbReportStart,
|
||||||
EnterBookingStart,
|
EnterBookingStart,
|
||||||
|
ValueStore,
|
||||||
|
Rule,
|
||||||
|
Cron,
|
||||||
module='cashbook', type_='model')
|
module='cashbook', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
ReconciliationReport,
|
ReconciliationReport,
|
||||||
|
|
233
book.py
233
book.py
|
@ -4,30 +4,19 @@
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.model import (
|
from trytond.model import (
|
||||||
Workflow, ModelView, ModelSQL, fields, Check,
|
Workflow, ModelView, ModelSQL, fields, Check, tree, Index)
|
||||||
tree, Index)
|
from trytond.pyson import Eval, Or, Bool, Id
|
||||||
from trytond.pyson import Eval, Or, Bool, Id, Len
|
|
||||||
from trytond.exceptions import UserError
|
from trytond.exceptions import UserError
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.report import Report
|
from trytond.report import Report
|
||||||
from trytond.config import config
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from sql.aggregate import Sum
|
from sql.aggregate import Sum
|
||||||
from sql.conditionals import Case
|
from sql.conditionals import Case
|
||||||
from .model import order_name_hierarchical, sub_ids_hierarchical, \
|
from .model import (
|
||||||
AnyInArray, CACHEKEY_CURRENCY
|
order_name_hierarchical, sub_ids_hierarchical, AnyInArray)
|
||||||
|
|
||||||
|
|
||||||
# enable/disable caching of cachekey for 'currency.rate'
|
|
||||||
if config.get(
|
|
||||||
'cashbook', 'cache_currency', default='yes'
|
|
||||||
).lower() in ['yes', '1', 'true']:
|
|
||||||
ENA_CURRKEY = True
|
|
||||||
else:
|
|
||||||
ENA_CURRKEY = False
|
|
||||||
|
|
||||||
|
|
||||||
STATES = {
|
STATES = {
|
||||||
|
@ -73,10 +62,9 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
model_name='cashbook.type', ondelete='RESTRICT',
|
model_name='cashbook.type', ondelete='RESTRICT',
|
||||||
states={
|
states={
|
||||||
'readonly': Or(
|
'readonly': Or(
|
||||||
STATES['readonly'],
|
STATES['readonly'],
|
||||||
Len(Eval('lines')) > 0,
|
Eval('has_lines', False))},
|
||||||
),
|
depends=DEPENDS+['has_lines'])
|
||||||
}, depends=DEPENDS+['lines'])
|
|
||||||
feature = fields.Function(fields.Char(
|
feature = fields.Function(fields.Char(
|
||||||
string='Feature', readonly=True,
|
string='Feature', readonly=True,
|
||||||
states={'invisible': True}), 'on_change_with_feature')
|
states={'invisible': True}), 'on_change_with_feature')
|
||||||
|
@ -98,6 +86,9 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
string='Lines', field='cashbook',
|
string='Lines', field='cashbook',
|
||||||
model_name='cashbook.line',
|
model_name='cashbook.line',
|
||||||
states=STATES, depends=DEPENDS)
|
states=STATES, depends=DEPENDS)
|
||||||
|
has_lines = fields.Function(fields.Boolean(
|
||||||
|
string='Has Lines', readonly=True, states={'invisible': True}),
|
||||||
|
'on_change_with_has_lines')
|
||||||
reconciliations = fields.One2Many(
|
reconciliations = fields.One2Many(
|
||||||
string='Reconciliations',
|
string='Reconciliations',
|
||||||
field='cashbook', model_name='cashbook.recon',
|
field='cashbook', model_name='cashbook.recon',
|
||||||
|
@ -124,11 +115,14 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
states={
|
states={
|
||||||
'readonly': Or(
|
'readonly': Or(
|
||||||
STATES2['readonly'],
|
STATES2['readonly'],
|
||||||
Len(Eval('lines')) > 0,
|
Eval('has_lines', False)),
|
||||||
),
|
|
||||||
'invisible': STATES2['invisible'],
|
'invisible': STATES2['invisible'],
|
||||||
'required': ~STATES2['invisible'],
|
'required': ~STATES2['invisible'],
|
||||||
}, depends=DEPENDS2+['lines'])
|
}, depends=DEPENDS2+['has_lines'])
|
||||||
|
|
||||||
|
value_store = fields.One2Many(
|
||||||
|
string='Values', model_name='cashbook.values', field='cashbook',
|
||||||
|
readonly=True)
|
||||||
balance = fields.Function(fields.Numeric(
|
balance = fields.Function(fields.Numeric(
|
||||||
string='Balance',
|
string='Balance',
|
||||||
readonly=True, depends=['currency_digits'],
|
readonly=True, depends=['currency_digits'],
|
||||||
|
@ -141,7 +135,6 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
help='Balance of all bookings',
|
help='Balance of all bookings',
|
||||||
digits=(16, Eval('currency_digits', 2))),
|
digits=(16, Eval('currency_digits', 2))),
|
||||||
'get_balance_cashbook', searcher='search_balance')
|
'get_balance_cashbook', searcher='search_balance')
|
||||||
|
|
||||||
balance_ref = fields.Function(fields.Numeric(
|
balance_ref = fields.Function(fields.Numeric(
|
||||||
string='Balance (Ref.)',
|
string='Balance (Ref.)',
|
||||||
help='Balance in company currency',
|
help='Balance in company currency',
|
||||||
|
@ -149,7 +142,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
states={
|
states={
|
||||||
'invisible': ~Bool(Eval('company_currency')),
|
'invisible': ~Bool(Eval('company_currency')),
|
||||||
}, depends=['company_currency_digits', 'company_currency']),
|
}, depends=['company_currency_digits', 'company_currency']),
|
||||||
'get_balance_cashbook')
|
'get_balance_cashbook', searcher='search_balance')
|
||||||
company_currency = fields.Function(fields.Many2One(
|
company_currency = fields.Function(fields.Many2One(
|
||||||
readonly=True,
|
readonly=True,
|
||||||
string='Company Currency', states={'invisible': True},
|
string='Company Currency', states={'invisible': True},
|
||||||
|
@ -165,9 +158,8 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
states={
|
states={
|
||||||
'readonly': Or(
|
'readonly': Or(
|
||||||
STATES2['readonly'],
|
STATES2['readonly'],
|
||||||
Len(Eval('lines', [])) > 0,
|
Eval('has_lines', False))},
|
||||||
),
|
depends=DEPENDS2+['has_lines'])
|
||||||
}, depends=DEPENDS2+['lines'])
|
|
||||||
currency_digits = fields.Function(fields.Integer(
|
currency_digits = fields.Function(fields.Integer(
|
||||||
string='Currency Digits',
|
string='Currency Digits',
|
||||||
readonly=True), 'on_change_with_currency_digits')
|
readonly=True), 'on_change_with_currency_digits')
|
||||||
|
@ -202,9 +194,6 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
Index(
|
Index(
|
||||||
t,
|
t,
|
||||||
(t.btype, Index.Equality())),
|
(t.btype, Index.Equality())),
|
||||||
Index(
|
|
||||||
t,
|
|
||||||
(t.parent, Index.Equality())),
|
|
||||||
Index(
|
Index(
|
||||||
t,
|
t,
|
||||||
(t.company, Index.Equality())),
|
(t.company, Index.Equality())),
|
||||||
|
@ -360,48 +349,141 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
)
|
)
|
||||||
return (query, tab_line)
|
return (query, tab_line)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def work_order_balance(cls, tables, field_name):
|
||||||
|
""" get order-query
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Book2 = pool.get('cashbook.book')
|
||||||
|
ValueStore = pool.get('cashbook.values')
|
||||||
|
context = Transaction().context
|
||||||
|
|
||||||
|
query_date = context.get('date', None)
|
||||||
|
table, _ = tables[None]
|
||||||
|
if query_date is not None:
|
||||||
|
if field_name == 'balance_ref':
|
||||||
|
raise UserError(gettext(
|
||||||
|
'cashbook.msg_nosearch_with_date',
|
||||||
|
fname=field_name, model=Book2.__name__))
|
||||||
|
|
||||||
|
(tab_book, tab2) = Book2.get_balance_of_cashbook_sql()
|
||||||
|
query = tab_book.select(
|
||||||
|
getattr(tab_book, field_name),
|
||||||
|
where=tab_book.cashbook == table.id)
|
||||||
|
return [query]
|
||||||
|
else:
|
||||||
|
tab_val = ValueStore.__table__()
|
||||||
|
tab_book = Book2.__table__()
|
||||||
|
|
||||||
|
query = tab_book.join(
|
||||||
|
tab_val,
|
||||||
|
condition=(
|
||||||
|
tab_book.id == tab_val.cashbook) & (
|
||||||
|
tab_val.field_name == field_name),
|
||||||
|
).select(
|
||||||
|
tab_val.numvalue,
|
||||||
|
where=tab_book.id == table.id)
|
||||||
|
return [query]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def order_balance(tables):
|
def order_balance(tables):
|
||||||
""" order by balance
|
""" order by balance
|
||||||
"""
|
"""
|
||||||
Book2 = Pool().get('cashbook.book')
|
Book2 = Pool().get('cashbook.book')
|
||||||
(tab_book, tab2) = Book2.get_balance_of_cashbook_sql()
|
return Book2.work_order_balance(tables, 'balance')
|
||||||
table, _ = tables[None]
|
|
||||||
|
|
||||||
query = tab_book.select(
|
|
||||||
tab_book.balance,
|
|
||||||
where=tab_book.cashbook == table.id)
|
|
||||||
return [query]
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def order_balance_all(tables):
|
def order_balance_all(tables):
|
||||||
""" order by balance-all
|
""" order by balance-all
|
||||||
"""
|
"""
|
||||||
Book2 = Pool().get('cashbook.book')
|
Book2 = Pool().get('cashbook.book')
|
||||||
(tab_book, tab2) = Book2.get_balance_of_cashbook_sql()
|
return Book2.work_order_balance(tables, 'balance_all')
|
||||||
table, _ = tables[None]
|
|
||||||
|
|
||||||
query = tab_book.select(
|
@staticmethod
|
||||||
tab_book.balance_all,
|
def order_balance_ref(tables):
|
||||||
where=tab_book.cashbook == table.id)
|
""" order by balance-all
|
||||||
return [query]
|
"""
|
||||||
|
Book2 = Pool().get('cashbook.book')
|
||||||
|
return Book2.work_order_balance(tables, 'balance_ref')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def search_balance(cls, name, clause):
|
def search_balance(cls, name, clause):
|
||||||
""" search in 'balance'
|
""" search in 'balance'
|
||||||
"""
|
"""
|
||||||
(tab_line, tab2) = cls.get_balance_of_cashbook_sql()
|
ValueStore = Pool().get('cashbook.values')
|
||||||
Operator = fields.SQL_OPERATORS[clause[1]]
|
Operator = fields.SQL_OPERATORS[clause[1]]
|
||||||
|
context = Transaction().context
|
||||||
|
|
||||||
query = tab_line.select(
|
query_date = context.get('date', None)
|
||||||
tab_line.cashbook,
|
if query_date is not None:
|
||||||
where=Operator(
|
|
||||||
getattr(tab_line, name), clause[2]),
|
if name == 'balance_ref':
|
||||||
)
|
raise UserError(gettext(
|
||||||
return [('id', 'in', query)]
|
'cashbook.msg_nosearch_with_date',
|
||||||
|
fname=name, model=cls.__name__))
|
||||||
|
|
||||||
|
(tab_line, tab2) = cls.get_balance_of_cashbook_sql()
|
||||||
|
query = tab_line.select(
|
||||||
|
tab_line.cashbook,
|
||||||
|
where=Operator(
|
||||||
|
getattr(tab_line, name), clause[2]))
|
||||||
|
return [('id', 'in', query)]
|
||||||
|
else:
|
||||||
|
value_query = ValueStore.search([
|
||||||
|
('field_name', '=', clause[0]),
|
||||||
|
('numvalue',) + tuple(clause[1:]),
|
||||||
|
],
|
||||||
|
query=True)
|
||||||
|
return [('value_store', 'in', value_query)]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def valuestore_delete_records(cls, records):
|
||||||
|
""" delete value-records
|
||||||
|
"""
|
||||||
|
ValStore = Pool().get('cashbook.values')
|
||||||
|
if records:
|
||||||
|
ValStore.delete_values(records)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def valuestore_fields(cls):
|
||||||
|
""" field to update
|
||||||
|
"""
|
||||||
|
return ['balance', 'balance_all', 'balance_ref']
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def valuestore_update_records(cls, records):
|
||||||
|
""" compute current values of records,
|
||||||
|
store to global storage
|
||||||
|
"""
|
||||||
|
ValStore = Pool().get('cashbook.values')
|
||||||
|
|
||||||
|
if records:
|
||||||
|
ValStore.update_values(
|
||||||
|
cls.get_balance_values(
|
||||||
|
records,
|
||||||
|
['balance', 'balance_all', 'balance_ref']))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_balance_cashbook(cls, cashbooks, names):
|
def get_balance_cashbook(cls, cashbooks, names):
|
||||||
|
""" get balance of cashbooks
|
||||||
|
"""
|
||||||
|
context = Transaction().context
|
||||||
|
|
||||||
|
result = {x: {y.id: Decimal('0.0') for y in cashbooks} for x in names}
|
||||||
|
|
||||||
|
# return computed values if 'date' is in context
|
||||||
|
query_date = context.get('date', None)
|
||||||
|
if query_date is not None:
|
||||||
|
return cls.get_balance_values(cashbooks, names)
|
||||||
|
|
||||||
|
for cashbook in cashbooks:
|
||||||
|
for value in cashbook.value_store:
|
||||||
|
if value.field_name in names:
|
||||||
|
result[value.field_name][cashbook.id] = value.numvalue
|
||||||
|
return result
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_balance_values(cls, cashbooks, names):
|
||||||
""" get balance of cashbook
|
""" get balance of cashbook
|
||||||
"""
|
"""
|
||||||
pool = Pool()
|
pool = Pool()
|
||||||
|
@ -409,7 +491,6 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
Currency = pool.get('currency.currency')
|
Currency = pool.get('currency.currency')
|
||||||
Company = pool.get('company.company')
|
Company = pool.get('company.company')
|
||||||
IrDate = pool.get('ir.date')
|
IrDate = pool.get('ir.date')
|
||||||
MemCache = pool.get('cashbook.memcache')
|
|
||||||
tab_book = Book2.__table__()
|
tab_book = Book2.__table__()
|
||||||
tab_comp = Company.__table__()
|
tab_comp = Company.__table__()
|
||||||
cursor = Transaction().connection.cursor()
|
cursor = Transaction().connection.cursor()
|
||||||
|
@ -427,28 +508,6 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
except Exception:
|
except Exception:
|
||||||
query_date = IrDate.today()
|
query_date = IrDate.today()
|
||||||
|
|
||||||
cache_keys = {
|
|
||||||
x.id: MemCache.get_key_by_record(
|
|
||||||
name='get_balance_cashbook',
|
|
||||||
record=x,
|
|
||||||
query=[{
|
|
||||||
'model': 'cashbook.line',
|
|
||||||
'query': [('cashbook.parent', 'child_of', [x.id])],
|
|
||||||
}, {
|
|
||||||
'model': 'currency.currency.rate',
|
|
||||||
'query': [('currency.id', '=', x.currency.id)],
|
|
||||||
'cachekey' if ENA_CURRKEY
|
|
||||||
else 'disabled': CACHEKEY_CURRENCY % x.currency.id,
|
|
||||||
}, ],
|
|
||||||
addkeys=[query_date.isoformat()])
|
|
||||||
for x in cashbooks}
|
|
||||||
|
|
||||||
# read from cache
|
|
||||||
(todo_cashbook, result) = MemCache.read_from_cache(
|
|
||||||
cashbooks, cache_keys, names, result)
|
|
||||||
if len(todo_cashbook) == 0:
|
|
||||||
return result
|
|
||||||
|
|
||||||
# query balances of cashbooks and sub-cashbooks
|
# query balances of cashbooks and sub-cashbooks
|
||||||
with Transaction().set_context({
|
with Transaction().set_context({
|
||||||
'date': query_date}):
|
'date': query_date}):
|
||||||
|
@ -473,7 +532,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
Sum(tab_line.balance_all).as_('balance_all'),
|
Sum(tab_line.balance_all).as_('balance_all'),
|
||||||
group_by=[
|
group_by=[
|
||||||
tab_book.id, tab_line.currency, tab_comp.currency],
|
tab_book.id, tab_line.currency, tab_comp.currency],
|
||||||
where=tab_book.id.in_([x.id for x in todo_cashbook]),
|
where=tab_book.id.in_([x.id for x in cashbooks]),
|
||||||
)
|
)
|
||||||
cursor.execute(*query)
|
cursor.execute(*query)
|
||||||
records = cursor.fetchall()
|
records = cursor.fetchall()
|
||||||
|
@ -485,10 +544,19 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
record[2], record[5], record[1])
|
record[2], record[5], record[1])
|
||||||
result['balance_ref'][record[0]] += Currency.compute(
|
result['balance_ref'][record[0]] += Currency.compute(
|
||||||
record[2], record[5], record[3])
|
record[2], record[5], record[3])
|
||||||
|
|
||||||
MemCache.store_result(cashbooks, cache_keys, result, todo_cashbook)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@fields.depends('id')
|
||||||
|
def on_change_with_has_lines(self, name=None):
|
||||||
|
""" return True if cashbook has lines
|
||||||
|
(we dont use 'if self.lines:' this would slow down the client)
|
||||||
|
"""
|
||||||
|
Line = Pool().get('cashbook.line')
|
||||||
|
|
||||||
|
if Line.search_count([('cashbook', '=', self.id)]):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@fields.depends('btype')
|
@fields.depends('btype')
|
||||||
def on_change_with_feature(self, name=None):
|
def on_change_with_feature(self, name=None):
|
||||||
""" get feature-set
|
""" get feature-set
|
||||||
|
@ -540,6 +608,14 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create(cls, vlist):
|
||||||
|
""" update values
|
||||||
|
"""
|
||||||
|
records = super(Book, cls).create(vlist)
|
||||||
|
cls.valuestore_update_records(records)
|
||||||
|
return records
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def write(cls, *args):
|
def write(cls, *args):
|
||||||
""" deny update if book is not 'open'
|
""" deny update if book is not 'open'
|
||||||
|
@ -548,7 +624,9 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
actions = iter(args)
|
actions = iter(args)
|
||||||
to_write_config = []
|
to_write_config = []
|
||||||
|
to_update = []
|
||||||
for books, values in zip(actions, actions):
|
for books, values in zip(actions, actions):
|
||||||
|
to_update.extend(books)
|
||||||
for book in books:
|
for book in books:
|
||||||
# deny btype-->None if lines not empty
|
# deny btype-->None if lines not empty
|
||||||
if 'btype' in values.keys():
|
if 'btype' in values.keys():
|
||||||
|
@ -574,7 +652,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
'defbook', 'book1', 'book2', 'book3',
|
'defbook', 'book1', 'book2', 'book3',
|
||||||
'book4', 'book5']:
|
'book4', 'book5']:
|
||||||
cfg1 = ConfigUser.search([
|
cfg1 = ConfigUser.search([
|
||||||
('iduser.id', '=', book.owner.id),
|
('iduser', '=', book.owner.id),
|
||||||
('%s.id' % x, '=', book.id)])
|
('%s.id' % x, '=', book.id)])
|
||||||
if len(cfg1) > 0:
|
if len(cfg1) > 0:
|
||||||
to_write_config.extend([cfg1, {x: None}])
|
to_write_config.extend([cfg1, {x: None}])
|
||||||
|
@ -582,6 +660,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
if len(to_write_config) > 0:
|
if len(to_write_config) > 0:
|
||||||
ConfigUser.write(*to_write_config)
|
ConfigUser.write(*to_write_config)
|
||||||
|
cls.valuestore_update_records(to_update)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete(cls, books):
|
def delete(cls, books):
|
||||||
|
|
6
book.xml
6
book.xml
|
@ -121,7 +121,7 @@ full copyright notices and license terms. -->
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.rule" id="rg_book_rw_owner-1">
|
<record model="ir.rule" id="rg_book_rw_owner-1">
|
||||||
<field name="domain" eval="[
|
<field name="domain" eval="[
|
||||||
('owner.id', '=', Eval('user', {}).get('id', -1)),
|
('owner.id', '=', Eval('user_id', -1)),
|
||||||
]" pyson="1"/>
|
]" pyson="1"/>
|
||||||
<field name="rule_group" ref="rg_book_rw_owner"/>
|
<field name="rule_group" ref="rg_book_rw_owner"/>
|
||||||
</record>
|
</record>
|
||||||
|
@ -143,8 +143,8 @@ full copyright notices and license terms. -->
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.rule" id="rg_book_read_nonowner-1">
|
<record model="ir.rule" id="rg_book_read_nonowner-1">
|
||||||
<field name="domain" eval="['OR',
|
<field name="domain" eval="['OR',
|
||||||
('observer.id', 'in', Eval('user', {}).get('groups', [])),
|
('observer.id', 'in', Eval('groups', [])),
|
||||||
('reviewer.id', 'in', Eval('user', {}).get('groups', [])),
|
('reviewer.id', 'in', Eval('groups', [])),
|
||||||
]" pyson="1"/>
|
]" pyson="1"/>
|
||||||
<field name="rule_group" ref="rg_book_read_nonowner"/>
|
<field name="rule_group" ref="rg_book_read_nonowner"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
@ -11,6 +11,7 @@ from trytond.exceptions import UserError
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from sql.operators import Equal
|
from sql.operators import Equal
|
||||||
from .model import order_name_hierarchical
|
from .model import order_name_hierarchical
|
||||||
|
from .const import DEF_NONE
|
||||||
|
|
||||||
|
|
||||||
sel_categorytype = [
|
sel_categorytype = [
|
||||||
|
@ -70,7 +71,7 @@ class Category(tree(separator='/'), ModelSQL, ModelView):
|
||||||
t,
|
t,
|
||||||
(t.name, Equal),
|
(t.name, Equal),
|
||||||
(t.cattype, Equal),
|
(t.cattype, Equal),
|
||||||
where=(t.parent == None)),
|
where=(t.parent == DEF_NONE)),
|
||||||
'cashbook.msg_category_name_unique'),
|
'cashbook.msg_category_name_unique'),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,8 @@ field_done = fields.Boolean(
|
||||||
help='Show cashbook lines in Done-state.')
|
help='Show cashbook lines in Done-state.')
|
||||||
field_catnamelong = fields.Boolean(
|
field_catnamelong = fields.Boolean(
|
||||||
string='Category: Show long name',
|
string='Category: Show long name',
|
||||||
help='Shows the long name of the category in the Category field of a cash book line.')
|
help='Shows the long name of the category in the Category ' +
|
||||||
|
'field of a cash book line.')
|
||||||
|
|
||||||
|
|
||||||
class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
|
class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
|
||||||
|
@ -29,60 +30,49 @@ class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
|
||||||
domain=[
|
domain=[
|
||||||
If(Eval('date_to') & Eval('date_from'),
|
If(Eval('date_to') & Eval('date_from'),
|
||||||
('date_from', '<=', Eval('date_to')),
|
('date_from', '<=', Eval('date_to')),
|
||||||
()),
|
())]))
|
||||||
]))
|
|
||||||
date_to = fields.MultiValue(fields.Date(
|
date_to = fields.MultiValue(fields.Date(
|
||||||
string='End Date', depends=['date_from'],
|
string='End Date', depends=['date_from'],
|
||||||
domain=[
|
domain=[
|
||||||
If(Eval('date_to') & Eval('date_from'),
|
If(Eval('date_to') & Eval('date_from'),
|
||||||
('date_from', '<=', Eval('date_to')),
|
('date_from', '<=', Eval('date_to')),
|
||||||
()),
|
())]))
|
||||||
]))
|
|
||||||
checked = fields.MultiValue(field_checked)
|
checked = fields.MultiValue(field_checked)
|
||||||
done = fields.MultiValue(field_done)
|
done = fields.MultiValue(field_done)
|
||||||
catnamelong = fields.MultiValue(field_catnamelong)
|
catnamelong = fields.MultiValue(field_catnamelong)
|
||||||
defbook = fields.MultiValue(fields.Many2One(
|
defbook = fields.MultiValue(fields.Many2One(
|
||||||
string='Default Cashbook',
|
string='Default Cashbook',
|
||||||
help='The default cashbook is selected when you open the booking wizard.',
|
help='The default cashbook is selected when you open ' +
|
||||||
|
'the booking wizard.',
|
||||||
model_name='cashbook.book', ondelete='SET NULL',
|
model_name='cashbook.book', ondelete='SET NULL',
|
||||||
domain=[
|
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||||
('btype', '!=', None), ('state', '=', 'open'),
|
|
||||||
]))
|
|
||||||
book1 = fields.MultiValue(fields.Many2One(
|
book1 = fields.MultiValue(fields.Many2One(
|
||||||
string='Cashbook 1',
|
string='Cashbook 1',
|
||||||
help='Cash book available in selection dialog.',
|
help='Cash book available in selection dialog.',
|
||||||
model_name='cashbook.book', ondelete='SET NULL',
|
model_name='cashbook.book', ondelete='SET NULL',
|
||||||
domain=[
|
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||||
('btype', '!=', None), ('state', '=', 'open'),
|
|
||||||
]))
|
|
||||||
book2 = fields.MultiValue(fields.Many2One(
|
book2 = fields.MultiValue(fields.Many2One(
|
||||||
string='Cashbook 2',
|
string='Cashbook 2',
|
||||||
help='Cash book available in selection dialog.',
|
help='Cash book available in selection dialog.',
|
||||||
model_name='cashbook.book', ondelete='SET NULL',
|
model_name='cashbook.book', ondelete='SET NULL',
|
||||||
domain=[
|
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||||
('btype', '!=', None), ('state', '=', 'open'),
|
|
||||||
]))
|
|
||||||
book3 = fields.MultiValue(fields.Many2One(
|
book3 = fields.MultiValue(fields.Many2One(
|
||||||
string='Cashbook 3',
|
string='Cashbook 3',
|
||||||
help='Cash book available in selection dialog.',
|
help='Cash book available in selection dialog.',
|
||||||
model_name='cashbook.book', ondelete='SET NULL',
|
model_name='cashbook.book', ondelete='SET NULL',
|
||||||
domain=[
|
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||||
('btype', '!=', None), ('state', '=', 'open'),
|
|
||||||
]))
|
|
||||||
book4 = fields.MultiValue(fields.Many2One(
|
book4 = fields.MultiValue(fields.Many2One(
|
||||||
string='Cashbook 4',
|
string='Cashbook 4',
|
||||||
help='Cash book available in selection dialog.',
|
help='Cash book available in selection dialog.',
|
||||||
model_name='cashbook.book', ondelete='SET NULL',
|
model_name='cashbook.book', ondelete='SET NULL',
|
||||||
domain=[
|
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||||
('btype', '!=', None), ('state', '=', 'open'),
|
|
||||||
]))
|
|
||||||
book5 = fields.MultiValue(fields.Many2One(
|
book5 = fields.MultiValue(fields.Many2One(
|
||||||
string='Cashbook 5',
|
string='Cashbook 5',
|
||||||
help='Cash book available in selection dialog.',
|
help='Cash book available in selection dialog.',
|
||||||
model_name='cashbook.book', ondelete='SET NULL',
|
model_name='cashbook.book', ondelete='SET NULL',
|
||||||
domain=[
|
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||||
('btype', '!=', None), ('state', '=', 'open'),
|
fixate = fields.MultiValue(fields.Boolean(
|
||||||
]))
|
string='Fixate', help='Fixating of the booking is activated.'))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def multivalue_model(cls, field):
|
def multivalue_model(cls, field):
|
||||||
|
@ -93,7 +83,7 @@ class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
|
||||||
if field in [
|
if field in [
|
||||||
'date_from', 'date_to', 'checked', 'done',
|
'date_from', 'date_to', 'checked', 'done',
|
||||||
'catnamelong', 'defbook', 'book1', 'book2',
|
'catnamelong', 'defbook', 'book1', 'book2',
|
||||||
'book3', 'book4', 'book5']:
|
'book3', 'book4', 'book5', 'fixate']:
|
||||||
return pool.get('cashbook.configuration_user')
|
return pool.get('cashbook.configuration_user')
|
||||||
return super(Configuration, cls).multivalue_model(field)
|
return super(Configuration, cls).multivalue_model(field)
|
||||||
|
|
||||||
|
@ -109,6 +99,10 @@ class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
|
||||||
def default_catnamelong(cls, **pattern):
|
def default_catnamelong(cls, **pattern):
|
||||||
return cls.multivalue_model('catnamelong').default_catnamelong()
|
return cls.multivalue_model('catnamelong').default_catnamelong()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def default_fixate(cls, **pattern):
|
||||||
|
return cls.multivalue_model('fixate').default_fixate()
|
||||||
|
|
||||||
# end Configuration
|
# end Configuration
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,21 +115,20 @@ class UserConfiguration(ModelSQL, UserValueMixin):
|
||||||
domain=[
|
domain=[
|
||||||
If(Eval('date_to') & Eval('date_from'),
|
If(Eval('date_to') & Eval('date_from'),
|
||||||
('date_from', '<=', Eval('date_to')),
|
('date_from', '<=', Eval('date_to')),
|
||||||
()),
|
())])
|
||||||
])
|
|
||||||
date_to = fields.Date(
|
date_to = fields.Date(
|
||||||
string='End Date', depends=['date_from'],
|
string='End Date', depends=['date_from'],
|
||||||
domain=[
|
domain=[
|
||||||
If(Eval('date_to') & Eval('date_from'),
|
If(Eval('date_to') & Eval('date_from'),
|
||||||
('date_from', '<=', Eval('date_to')),
|
('date_from', '<=', Eval('date_to')),
|
||||||
()),
|
())])
|
||||||
])
|
|
||||||
checked = field_checked
|
checked = field_checked
|
||||||
done = field_done
|
done = field_done
|
||||||
catnamelong = field_catnamelong
|
catnamelong = field_catnamelong
|
||||||
defbook = fields.Many2One(
|
defbook = fields.Many2One(
|
||||||
string='Default Cashbook',
|
string='Default Cashbook',
|
||||||
help='The default cashbook is selected when you open the booking wizard.',
|
help='The default cashbook is selected when you open ' +
|
||||||
|
'the booking wizard.',
|
||||||
model_name='cashbook.book', ondelete='SET NULL',
|
model_name='cashbook.book', ondelete='SET NULL',
|
||||||
domain=[
|
domain=[
|
||||||
('btype', '!=', None),
|
('btype', '!=', None),
|
||||||
|
@ -188,6 +181,9 @@ class UserConfiguration(ModelSQL, UserValueMixin):
|
||||||
('owner.id', '=', Eval('iduser', -1))
|
('owner.id', '=', Eval('iduser', -1))
|
||||||
], depends=['iduser'])
|
], depends=['iduser'])
|
||||||
|
|
||||||
|
fixate = fields.Boolean(
|
||||||
|
string='Fixate', help='Fixating of the booking is activated.')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_checked(cls):
|
def default_checked(cls):
|
||||||
return True
|
return True
|
||||||
|
@ -200,4 +196,8 @@ class UserConfiguration(ModelSQL, UserValueMixin):
|
||||||
def default_done(cls):
|
def default_done(cls):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def default_fixate(cls):
|
||||||
|
return False
|
||||||
|
|
||||||
# end UserConfiguration
|
# end UserConfiguration
|
||||||
|
|
8
const.py
Normal file
8
const.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# This file is part of the cashbook-module from m-ds.de for Tryton.
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
|
||||||
|
DEF_NONE = None
|
||||||
|
|
18
cron.py
Normal file
18
cron.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# This file is part of the cashbook-module from m-ds.de 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 Cron(metaclass=PoolMeta):
|
||||||
|
__name__ = 'ir.cron'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def __setup__(cls):
|
||||||
|
super(Cron, cls).__setup__()
|
||||||
|
cls.method.selection.append(
|
||||||
|
('cashbook.values|maintenance_values', "Update Cashbooks"))
|
||||||
|
|
||||||
|
# end Cron
|
15
cron.xml
Normal file
15
cron.xml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of the cashbook-module from m-ds.de 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.cron" id="asset_cron">
|
||||||
|
<field name="method">cashbook.values|maintenance_values</field>
|
||||||
|
<field name="interval_number" eval="1"/>
|
||||||
|
<field name="interval_type">hours</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</tryton>
|
43
currency.py
43
currency.py
|
@ -3,8 +3,7 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import PoolMeta, Pool
|
||||||
from .model import CACHEKEY_CURRENCY
|
|
||||||
|
|
||||||
|
|
||||||
class CurrencyRate(metaclass=PoolMeta):
|
class CurrencyRate(metaclass=PoolMeta):
|
||||||
|
@ -14,35 +13,51 @@ class CurrencyRate(metaclass=PoolMeta):
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
""" update cache-value
|
""" update cache-value
|
||||||
"""
|
"""
|
||||||
MemCache = Pool().get('cashbook.memcache')
|
pool = Pool()
|
||||||
|
Cashbook = pool.get('cashbook.book')
|
||||||
|
ValueStore = pool.get('cashbook.values')
|
||||||
|
|
||||||
records = super(CurrencyRate, cls).create(vlist)
|
records = super(CurrencyRate, cls).create(vlist)
|
||||||
for rate in records:
|
|
||||||
MemCache.record_update(CACHEKEY_CURRENCY % rate.currency.id, rate)
|
ValueStore.update_books(
|
||||||
|
ValueStore.get_book_by_books(
|
||||||
|
Cashbook.search([
|
||||||
|
('currency', 'in', [
|
||||||
|
x.currency.id for x in records])])))
|
||||||
return records
|
return records
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def write(cls, *args):
|
def write(cls, *args):
|
||||||
""" update cache-value
|
""" update cache-value
|
||||||
"""
|
"""
|
||||||
MemCache = Pool().get('cashbook.memcache')
|
pool = Pool()
|
||||||
|
Cashbook = pool.get('cashbook.book')
|
||||||
|
ValueStore = pool.get('cashbook.values')
|
||||||
|
|
||||||
|
actions = iter(args)
|
||||||
|
all_rates = []
|
||||||
|
for rates, values in zip(actions, actions):
|
||||||
|
all_rates.extend(rates)
|
||||||
|
|
||||||
super(CurrencyRate, cls).write(*args)
|
super(CurrencyRate, cls).write(*args)
|
||||||
|
|
||||||
actions = iter(args)
|
ValueStore.update_books(
|
||||||
for rates, values in zip(actions, actions):
|
ValueStore.get_book_by_books(
|
||||||
for rate in rates:
|
Cashbook.search([
|
||||||
MemCache.record_update(
|
('currency', 'in', [
|
||||||
CACHEKEY_CURRENCY % rate.currency.id, rate)
|
x.currency.id for x in all_rates])])))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete(cls, records):
|
def delete(cls, records):
|
||||||
""" set cache to None
|
""" set cache to None
|
||||||
"""
|
"""
|
||||||
MemCache = Pool().get('cashbook.memcache')
|
pool = Pool()
|
||||||
|
Cashbook = pool.get('cashbook.book')
|
||||||
|
ValueStore = pool.get('cashbook.values')
|
||||||
|
|
||||||
for record in records:
|
books = ValueStore.get_book_by_books(Cashbook.search([
|
||||||
MemCache.record_update(CACHEKEY_CURRENCY % record.currency.id, None)
|
('currency', 'in', [x.currency.id for x in records])]))
|
||||||
super(CurrencyRate, cls).delete(records)
|
super(CurrencyRate, cls).delete(records)
|
||||||
|
ValueStore.update_books(books)
|
||||||
|
|
||||||
# end
|
# end
|
||||||
|
|
24
ir.py
Normal file
24
ir.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# This file is part of the cashbook-module from m-ds.de 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()
|
||||||
|
return result | {
|
||||||
|
'cashbook.book',
|
||||||
|
'cashbook.line',
|
||||||
|
'cashbook.recon',
|
||||||
|
'cashbook.split'
|
||||||
|
}
|
||||||
|
|
||||||
|
# end Rule
|
88
line.py
88
line.py
|
@ -15,7 +15,8 @@ from sql import Literal
|
||||||
from sql.functions import DatePart
|
from sql.functions import DatePart
|
||||||
from sql.conditionals import Case
|
from sql.conditionals import Case
|
||||||
from .book import sel_state_book
|
from .book import sel_state_book
|
||||||
from .mixin import SecondCurrencyMixin, MemCacheIndexMx
|
from .mixin import SecondCurrencyMixin
|
||||||
|
from .const import DEF_NONE
|
||||||
|
|
||||||
|
|
||||||
sel_payee = [
|
sel_payee = [
|
||||||
|
@ -23,7 +24,7 @@ sel_payee = [
|
||||||
('party.party', 'Party')
|
('party.party', 'Party')
|
||||||
]
|
]
|
||||||
|
|
||||||
sel_linetype = [
|
sel_linestate = [
|
||||||
('edit', 'Edit'),
|
('edit', 'Edit'),
|
||||||
('check', 'Checked'),
|
('check', 'Checked'),
|
||||||
('recon', 'Reconciled'),
|
('recon', 'Reconciled'),
|
||||||
|
@ -48,7 +49,7 @@ STATES = {
|
||||||
DEPENDS = ['state', 'state_cashbook']
|
DEPENDS = ['state', 'state_cashbook']
|
||||||
|
|
||||||
|
|
||||||
class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
||||||
'Cashbook Line'
|
'Cashbook Line'
|
||||||
__name__ = 'cashbook.line'
|
__name__ = 'cashbook.line'
|
||||||
|
|
||||||
|
@ -75,8 +76,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
states={
|
states={
|
||||||
'readonly': Or(
|
'readonly': Or(
|
||||||
STATES['readonly'],
|
STATES['readonly'],
|
||||||
Bool(Eval('bookingtype')) == False,
|
~Bool(Eval('bookingtype'))),
|
||||||
),
|
|
||||||
'required': Eval('bookingtype', '').in_(['in', 'out']),
|
'required': Eval('bookingtype', '').in_(['in', 'out']),
|
||||||
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
|
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
|
||||||
}, depends=DEPENDS+['bookingtype'],
|
}, depends=DEPENDS+['bookingtype'],
|
||||||
|
@ -161,7 +161,8 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
splitlines = fields.One2Many(
|
splitlines = fields.One2Many(
|
||||||
string='Split booking lines',
|
string='Split booking lines',
|
||||||
model_name='cashbook.split',
|
model_name='cashbook.split',
|
||||||
help='Rows with different categories form the total sum of the booking',
|
help='Rows with different categories form the total ' +
|
||||||
|
'sum of the booking',
|
||||||
states={
|
states={
|
||||||
'invisible': ~Eval('bookingtype' '').in_(['spin', 'spout']),
|
'invisible': ~Eval('bookingtype' '').in_(['spin', 'spout']),
|
||||||
'readonly': Or(
|
'readonly': Or(
|
||||||
|
@ -197,7 +198,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
string='State', required=True, readonly=True,
|
string='State', required=True, readonly=True,
|
||||||
selection=sel_linetype)
|
selection=sel_linestate)
|
||||||
state_string = state.translated('state')
|
state_string = state.translated('state')
|
||||||
state_cashbook = fields.Function(fields.Selection(
|
state_cashbook = fields.Function(fields.Selection(
|
||||||
string='State of Cashbook',
|
string='State of Cashbook',
|
||||||
|
@ -225,9 +226,6 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
t = cls.__table__()
|
t = cls.__table__()
|
||||||
|
|
||||||
cls._sql_indexes.update({
|
cls._sql_indexes.update({
|
||||||
Index(
|
|
||||||
t,
|
|
||||||
(t.cashbook, Index.Equality())),
|
|
||||||
Index(
|
Index(
|
||||||
t,
|
t,
|
||||||
(t.date, Index.Range(order='ASC'))),
|
(t.date, Index.Range(order='ASC'))),
|
||||||
|
@ -245,7 +243,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
(t.state, Index.Equality())),
|
(t.state, Index.Equality())),
|
||||||
Index(
|
Index(
|
||||||
t,
|
t,
|
||||||
(t.reference, Index.Range())),
|
(t.reference, Index.Equality())),
|
||||||
})
|
})
|
||||||
cls._sql_constraints.extend([
|
cls._sql_constraints.extend([
|
||||||
('state_val2',
|
('state_val2',
|
||||||
|
@ -308,7 +306,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
).select(
|
).select(
|
||||||
tab_line.id,
|
tab_line.id,
|
||||||
where=tab_line.bookingtype.in_(['mvin', 'mvout']) &
|
where=tab_line.bookingtype.in_(['mvin', 'mvout']) &
|
||||||
(tab_line.amount_2nd_currency == None) &
|
(tab_line.amount_2nd_currency == DEF_NONE) &
|
||||||
(tab_book.currency != tab_book2.currency)
|
(tab_book.currency != tab_book2.currency)
|
||||||
)
|
)
|
||||||
lines = Line2.search([('id', 'in', query)])
|
lines = Line2.search([('id', 'in', query)])
|
||||||
|
@ -344,7 +342,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.reference:
|
if line.reference:
|
||||||
if Transaction().context.get(
|
if Transaction().context.get(
|
||||||
'line.allow.wfedit', False) == False:
|
'line.allow.wfedit', False) is False:
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
'cashbook.msg_line_denywf_by_reference',
|
'cashbook.msg_line_denywf_by_reference',
|
||||||
recname=line.reference.rec_name,
|
recname=line.reference.rec_name,
|
||||||
|
@ -375,7 +373,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
# allow cashbook-line at range-limits
|
# allow cashbook-line at range-limits
|
||||||
if Recon.search_count([
|
if Recon.search_count([
|
||||||
('state', 'in', ['check', 'done']),
|
('state', 'in', ['check', 'done']),
|
||||||
('cashbook.id', '=', line.cashbook.id),
|
('cashbook', '=', line.cashbook.id),
|
||||||
('date_from', '<', line.date),
|
('date_from', '<', line.date),
|
||||||
('date_to', '>', line.date)]) > 0:
|
('date_to', '>', line.date)]) > 0:
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
|
@ -386,7 +384,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
# reconciliations exist
|
# reconciliations exist
|
||||||
if Recon.search_count([
|
if Recon.search_count([
|
||||||
('state', 'in', ['check', 'done']),
|
('state', 'in', ['check', 'done']),
|
||||||
('cashbook.id', '=', line.cashbook.id),
|
('cashbook', '=', line.cashbook.id),
|
||||||
['OR',
|
['OR',
|
||||||
('date_from', '=', line.date),
|
('date_from', '=', line.date),
|
||||||
('date_to', '=', line.date)]]) > 1:
|
('date_to', '=', line.date)]]) > 1:
|
||||||
|
@ -508,19 +506,20 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
"""
|
"""
|
||||||
credit = self.credit if self.credit is not None else Decimal('0.0')
|
credit = self.credit if self.credit is not None else Decimal('0.0')
|
||||||
debit = self.debit if self.debit is not None else Decimal('0.0')
|
debit = self.debit if self.debit is not None else Decimal('0.0')
|
||||||
return '%(date)s|%(type)s|%(amount)s %(symbol)s|%(desc)s [%(category)s]' % {
|
return '|'.join([
|
||||||
'date': Report.format_date(self.date),
|
Report.format_date(self.date),
|
||||||
'desc': (self.description or '-')[:40],
|
gettext('cashbook.msg_line_bookingtype_%s' % self.bookingtype),
|
||||||
'amount': Report.format_number(
|
'%(amount)s %(symbol)s' % {
|
||||||
credit - debit, None,
|
'amount': Report.format_number(
|
||||||
digits=getattr(self.currency, 'digits', 2)),
|
credit - debit, None,
|
||||||
'symbol': getattr(self.currency, 'symbol', '-'),
|
digits=getattr(self.currency, 'digits', 2)),
|
||||||
'category': self.category_view
|
'symbol': getattr(self.currency, 'symbol', '-')},
|
||||||
if self.bookingtype in ['in', 'out']
|
'%(desc)s [%(category)s]' % {
|
||||||
else getattr(self.booktransf, 'rec_name', '-'),
|
'desc': (self.description or '-')[:40],
|
||||||
'type': gettext(
|
'category': self.category_view
|
||||||
'cashbook.msg_line_bookingtype_%s' %
|
if self.bookingtype in ['in', 'out']
|
||||||
self.bookingtype)}
|
else getattr(self.booktransf, 'rec_name', '-')},
|
||||||
|
])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def order_state(tables):
|
def order_state(tables):
|
||||||
|
@ -535,8 +534,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
(tab_line.state == 'edit', 1),
|
(tab_line.state == 'edit', 1),
|
||||||
(tab_line.state.in_(['check', 'recon', 'done']), 0),
|
(tab_line.state.in_(['check', 'recon', 'done']), 0),
|
||||||
else_=2),
|
else_=2),
|
||||||
where=tab_line.id == table.id
|
where=tab_line.id == table.id)
|
||||||
)
|
|
||||||
return [query]
|
return [query]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -626,7 +624,8 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
if self.bookingtype:
|
if self.bookingtype:
|
||||||
if self.category:
|
if self.category:
|
||||||
if self.bookingtype not in types.get(self.category.cattype, ''):
|
if self.bookingtype not in types.get(
|
||||||
|
self.category.cattype, ''):
|
||||||
self.category = None
|
self.category = None
|
||||||
|
|
||||||
if self.bookingtype.startswith('sp'): # split booking
|
if self.bookingtype.startswith('sp'): # split booking
|
||||||
|
@ -751,7 +750,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
end_value = None
|
end_value = None
|
||||||
|
|
||||||
recons = Reconciliation.search([
|
recons = Reconciliation.search([
|
||||||
('cashbook.id', '=', line.cashbook.id),
|
('cashbook', '=', line.cashbook.id),
|
||||||
('date_to', '<=', line2.date),
|
('date_to', '<=', line2.date),
|
||||||
('state', '=', 'done'),
|
('state', '=', 'done'),
|
||||||
], order=[('date_from', 'DESC')], limit=1)
|
], order=[('date_from', 'DESC')], limit=1)
|
||||||
|
@ -761,14 +760,14 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
('date', '<=', line2.date),
|
('date', '<=', line2.date),
|
||||||
['OR',
|
['OR',
|
||||||
('reconciliation', '=', None),
|
('reconciliation', '=', None),
|
||||||
('reconciliation.id', '!=', recons[0])],
|
('reconciliation', '!=', recons[0])],
|
||||||
])
|
])
|
||||||
end_value = getattr(recons[0], 'end_%s' % field_name)
|
end_value = getattr(recons[0], 'end_%s' % field_name)
|
||||||
return (query2, end_value)
|
return (query2, end_value)
|
||||||
|
|
||||||
if line.cashbook:
|
if line.cashbook:
|
||||||
query = [
|
query = [
|
||||||
('cashbook.id', '=', line.cashbook.id),
|
('cashbook', '=', line.cashbook.id),
|
||||||
]
|
]
|
||||||
balance = Decimal('0.0')
|
balance = Decimal('0.0')
|
||||||
|
|
||||||
|
@ -778,7 +777,7 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
if line.reconciliation:
|
if line.reconciliation:
|
||||||
if line.reconciliation.state == 'done':
|
if line.reconciliation.state == 'done':
|
||||||
query.append(
|
query.append(
|
||||||
('reconciliation.id', '=', line.reconciliation.id),
|
('reconciliation', '=', line.reconciliation.id),
|
||||||
)
|
)
|
||||||
balance = getattr(
|
balance = getattr(
|
||||||
line.reconciliation, 'start_%s' % field_name)
|
line.reconciliation, 'start_%s' % field_name)
|
||||||
|
@ -1036,6 +1035,8 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
""" add debit/credit
|
""" add debit/credit
|
||||||
"""
|
"""
|
||||||
|
ValueStore = Pool().get('cashbook.values')
|
||||||
|
|
||||||
vlist = [x.copy() for x in vlist]
|
vlist = [x.copy() for x in vlist]
|
||||||
for values in vlist:
|
for values in vlist:
|
||||||
values.update(cls.add_values_from_splitlines(values))
|
values.update(cls.add_values_from_splitlines(values))
|
||||||
|
@ -1055,18 +1056,26 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
recname='%(date)s|%(descr)s' % {
|
recname='%(date)s|%(descr)s' % {
|
||||||
'date': date_txt,
|
'date': date_txt,
|
||||||
'descr': values.get('description', '-')}))
|
'descr': values.get('description', '-')}))
|
||||||
return super(Line, cls).create(vlist)
|
records = super(Line, cls).create(vlist)
|
||||||
|
|
||||||
|
if records:
|
||||||
|
ValueStore.update_books(ValueStore.get_book_by_line(records))
|
||||||
|
return records
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def write(cls, *args):
|
def write(cls, *args):
|
||||||
""" deny update if cashbook.line!='open',
|
""" deny update if cashbook.line!='open',
|
||||||
add or update debit/credit
|
add or update debit/credit
|
||||||
"""
|
"""
|
||||||
|
ValueStore = Pool().get('cashbook.values')
|
||||||
|
|
||||||
actions = iter(args)
|
actions = iter(args)
|
||||||
to_write = []
|
to_write = []
|
||||||
|
to_update = []
|
||||||
for lines, values in zip(actions, actions):
|
for lines, values in zip(actions, actions):
|
||||||
cls.check_permission_write(lines, values)
|
cls.check_permission_write(lines, values)
|
||||||
|
|
||||||
|
to_update.extend(lines)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.reconciliation:
|
if line.reconciliation:
|
||||||
# deny state-change to 'edit' if line is
|
# deny state-change to 'edit' if line is
|
||||||
|
@ -1110,12 +1119,19 @@ class Line(SecondCurrencyMixin, MemCacheIndexMx, Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
super(Line, cls).write(*to_write)
|
super(Line, cls).write(*to_write)
|
||||||
|
|
||||||
|
if to_update:
|
||||||
|
ValueStore.update_books(ValueStore.get_book_by_line(to_update))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def delete(cls, lines):
|
def delete(cls, lines):
|
||||||
""" deny delete if book is not 'open' or wf is not 'edit'
|
""" deny delete if book is not 'open' or wf is not 'edit'
|
||||||
"""
|
"""
|
||||||
|
ValueStore = Pool().get('cashbook.values')
|
||||||
|
|
||||||
cls.check_permission_delete(lines)
|
cls.check_permission_delete(lines)
|
||||||
|
to_update = ValueStore.get_book_by_line(lines)
|
||||||
super(Line, cls).delete(lines)
|
super(Line, cls).delete(lines)
|
||||||
|
ValueStore.update_books(to_update)
|
||||||
|
|
||||||
# end Line
|
# end Line
|
||||||
|
|
||||||
|
|
6
line.xml
6
line.xml
|
@ -145,8 +145,8 @@ full copyright notices and license terms. -->
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.rule" id="rg_line_write-1">
|
<record model="ir.rule" id="rg_line_write-1">
|
||||||
<field name="domain" eval="['OR',
|
<field name="domain" eval="['OR',
|
||||||
('cashbook.owner.id', '=', Eval('user', {}).get('id', -1)),
|
('cashbook.owner.id', '=', Eval('user_id', -1)),
|
||||||
('cashbook.reviewer.id', 'in', Eval('user', {}).get('groups', [])),
|
('cashbook.reviewer.id', 'in', Eval('groups', [])),
|
||||||
]" pyson="1"/>
|
]" pyson="1"/>
|
||||||
<field name="rule_group" ref="rg_line_write"/>
|
<field name="rule_group" ref="rg_line_write"/>
|
||||||
</record>
|
</record>
|
||||||
|
@ -168,7 +168,7 @@ full copyright notices and license terms. -->
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.rule" id="rg_line_read-1">
|
<record model="ir.rule" id="rg_line_read-1">
|
||||||
<field name="domain" eval="[
|
<field name="domain" eval="[
|
||||||
('cashbook.observer.id', 'in', Eval('user', {}).get('groups', [])),
|
('cashbook.observer.id', 'in', Eval('groups', [])),
|
||||||
]" pyson="1"/>
|
]" pyson="1"/>
|
||||||
<field name="rule_group" ref="rg_line_read"/>
|
<field name="rule_group" ref="rg_line_read"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
84
locale/de.po
84
locale/de.po
|
@ -3,6 +3,14 @@ msgid ""
|
||||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
|
||||||
|
|
||||||
|
###########
|
||||||
|
# ir.cron #
|
||||||
|
###########
|
||||||
|
msgctxt "selection:ir.cron,method:"
|
||||||
|
msgid "Update Cashbooks"
|
||||||
|
msgstr "Kassenbücher Aktualisieren"
|
||||||
|
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# ir.message #
|
# ir.message #
|
||||||
##############
|
##############
|
||||||
|
@ -158,6 +166,14 @@ msgctxt "model:ir.message,text:msg_btype_general"
|
||||||
msgid "General"
|
msgid "General"
|
||||||
msgstr "Allgemein"
|
msgstr "Allgemein"
|
||||||
|
|
||||||
|
msgctxt "model:ir.message,text:msg_value_exists_in_store"
|
||||||
|
msgid "The value already exists for the record."
|
||||||
|
msgstr "Der Wert existiert für den Datensatz bereits."
|
||||||
|
|
||||||
|
msgctxt "model:ir.message,text:msg_nosearch_with_date"
|
||||||
|
msgid "Search with 'date' no allowed for field '%(fname)s' on model '%(model)s'."
|
||||||
|
msgstr "Suche mit 'date' nicht erlaubt für Feld '%(fname)s' auf Modell '%(model)s'."
|
||||||
|
|
||||||
|
|
||||||
#############
|
#############
|
||||||
# res.group #
|
# res.group #
|
||||||
|
@ -450,10 +466,6 @@ msgctxt "view:cashbook.book:"
|
||||||
msgid "Amount and Numbering"
|
msgid "Amount and Numbering"
|
||||||
msgstr "Betrag und Nummerierung"
|
msgstr "Betrag und Nummerierung"
|
||||||
|
|
||||||
msgctxt "view:cashbook.book:"
|
|
||||||
msgid "Balance"
|
|
||||||
msgstr "Saldo"
|
|
||||||
|
|
||||||
msgctxt "view:cashbook.book:"
|
msgctxt "view:cashbook.book:"
|
||||||
msgid "Reconciliations"
|
msgid "Reconciliations"
|
||||||
msgstr "Abstimmungen"
|
msgstr "Abstimmungen"
|
||||||
|
@ -602,6 +614,10 @@ msgctxt "field:cashbook.book,booktransf_feature:"
|
||||||
msgid "Feature"
|
msgid "Feature"
|
||||||
msgstr "Merkmal"
|
msgstr "Merkmal"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.book,value_store:"
|
||||||
|
msgid "Values"
|
||||||
|
msgstr "Werte"
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# cashbook.split #
|
# cashbook.split #
|
||||||
|
@ -774,14 +790,6 @@ msgctxt "model:cashbook.line,name:"
|
||||||
msgid "Cashbook Line"
|
msgid "Cashbook Line"
|
||||||
msgstr "Kassenbuchzeile"
|
msgstr "Kassenbuchzeile"
|
||||||
|
|
||||||
msgctxt "view:cashbook.line:"
|
|
||||||
msgid "Credit"
|
|
||||||
msgstr "Einnahme"
|
|
||||||
|
|
||||||
msgctxt "view:cashbook.line:"
|
|
||||||
msgid "Debit"
|
|
||||||
msgstr "Ausgabe"
|
|
||||||
|
|
||||||
msgctxt "view:cashbook.line:"
|
msgctxt "view:cashbook.line:"
|
||||||
msgid "Cashbook Line"
|
msgid "Cashbook Line"
|
||||||
msgstr "Kassenbuchzeile"
|
msgstr "Kassenbuchzeile"
|
||||||
|
@ -1250,6 +1258,14 @@ msgctxt "help:cashbook.configuration,book5:"
|
||||||
msgid "Cash book available in selection dialog."
|
msgid "Cash book available in selection dialog."
|
||||||
msgstr "in Auswahldialog verfügbares Kassenbuch."
|
msgstr "in Auswahldialog verfügbares Kassenbuch."
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.configuration,fixate:"
|
||||||
|
msgid "Fixate"
|
||||||
|
msgstr "Festschreiben"
|
||||||
|
|
||||||
|
msgctxt "help:cashbook.configuration,fixate:"
|
||||||
|
msgid "Fixating of the booking is activated."
|
||||||
|
msgstr "Die Festschreiben der Buchung ist aktiviert."
|
||||||
|
|
||||||
msgctxt "field:cashbook.configuration,date_from:"
|
msgctxt "field:cashbook.configuration,date_from:"
|
||||||
msgid "Start Date"
|
msgid "Start Date"
|
||||||
msgstr "Beginndatum"
|
msgstr "Beginndatum"
|
||||||
|
@ -1370,6 +1386,14 @@ msgctxt "help:cashbook.configuration_user,book5:"
|
||||||
msgid "Cash book available in selection dialog."
|
msgid "Cash book available in selection dialog."
|
||||||
msgstr "in Auswahldialog verfügbares Kassenbuch."
|
msgstr "in Auswahldialog verfügbares Kassenbuch."
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.configuration_user,fixate:"
|
||||||
|
msgid "Fixate"
|
||||||
|
msgstr "Festschreiben"
|
||||||
|
|
||||||
|
msgctxt "help:cashbook.configuration_user,fixate:"
|
||||||
|
msgid "Fixating of the booking is activated."
|
||||||
|
msgstr "Die Festschreiben der Buchung ist aktiviert."
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# cashbook.recon #
|
# cashbook.recon #
|
||||||
|
@ -1638,6 +1662,18 @@ msgctxt "field:cashbook.enterbooking.start,party:"
|
||||||
msgid "Party"
|
msgid "Party"
|
||||||
msgstr "Partei"
|
msgstr "Partei"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.enterbooking.start,description:"
|
||||||
|
msgid "Description"
|
||||||
|
msgstr "Beschreibung"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.enterbooking.start,fixate:"
|
||||||
|
msgid "Fixate"
|
||||||
|
msgstr "Festschreiben"
|
||||||
|
|
||||||
|
msgctxt "help:cashbook.enterbooking.start,fixate:"
|
||||||
|
msgid "The booking is fixed immediately."
|
||||||
|
msgstr "Die Buchung wird sofort festgeschrieben."
|
||||||
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
# cashbook.enterbooking #
|
# cashbook.enterbooking #
|
||||||
|
@ -1657,3 +1693,27 @@ msgstr "Speichern"
|
||||||
msgctxt "wizard_button:cashbook.enterbooking,start,savenext_:"
|
msgctxt "wizard_button:cashbook.enterbooking,start,savenext_:"
|
||||||
msgid "Save & Next"
|
msgid "Save & Next"
|
||||||
msgstr "Speichern & Weiter"
|
msgstr "Speichern & Weiter"
|
||||||
|
|
||||||
|
|
||||||
|
###################
|
||||||
|
# cashbook.values #
|
||||||
|
###################
|
||||||
|
msgctxt "model:cashbook.values,name:"
|
||||||
|
msgid "Value Store"
|
||||||
|
msgstr "Wertespeicher"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.values,resource:"
|
||||||
|
msgid "Resource"
|
||||||
|
msgstr "Ressource"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.values,field_name:"
|
||||||
|
msgid "Field Name"
|
||||||
|
msgstr "Feldname"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.values,numvalue:"
|
||||||
|
msgid "Value"
|
||||||
|
msgstr "Wert"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.values,valuedigits:"
|
||||||
|
msgid "Digits"
|
||||||
|
msgstr "Dezimalstellen"
|
||||||
|
|
76
locale/en.po
76
locale/en.po
|
@ -2,6 +2,10 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
|
||||||
|
msgctxt "selection:ir.cron,method:"
|
||||||
|
msgid "Update Cashbooks"
|
||||||
|
msgstr "Update Cashbooks"
|
||||||
|
|
||||||
msgctxt "model:ir.message,text:msg_type_short_unique"
|
msgctxt "model:ir.message,text:msg_type_short_unique"
|
||||||
msgid "The Abbreviation must be unique."
|
msgid "The Abbreviation must be unique."
|
||||||
msgstr "The Abbreviation must be unique."
|
msgstr "The Abbreviation must be unique."
|
||||||
|
@ -154,6 +158,14 @@ msgctxt "model:ir.message,text:msg_btype_general"
|
||||||
msgid "General"
|
msgid "General"
|
||||||
msgstr "General"
|
msgstr "General"
|
||||||
|
|
||||||
|
msgctxt "model:ir.message,text:msg_value_exists_in_store"
|
||||||
|
msgid "The value already exists for the record."
|
||||||
|
msgstr "The value already exists for the record."
|
||||||
|
|
||||||
|
msgctxt "model:ir.message,text:msg_nosearch_with_date"
|
||||||
|
msgid "Search with 'date' no allowed for field '%(fname)s' on model '%(model)s'."
|
||||||
|
msgstr "Search with 'date' no allowed for field '%(fname)s' on model '%(model)s'."
|
||||||
|
|
||||||
msgctxt "model:res.group,name:group_cashbook"
|
msgctxt "model:res.group,name:group_cashbook"
|
||||||
msgid "Cashbook"
|
msgid "Cashbook"
|
||||||
msgstr "Cashbook"
|
msgstr "Cashbook"
|
||||||
|
@ -414,10 +426,6 @@ msgctxt "view:cashbook.book:"
|
||||||
msgid "Amount and Numbering"
|
msgid "Amount and Numbering"
|
||||||
msgstr "Amount and Numbering"
|
msgstr "Amount and Numbering"
|
||||||
|
|
||||||
msgctxt "view:cashbook.book:"
|
|
||||||
msgid "Balance"
|
|
||||||
msgstr "Balance"
|
|
||||||
|
|
||||||
msgctxt "view:cashbook.book:"
|
msgctxt "view:cashbook.book:"
|
||||||
msgid "Reconciliations"
|
msgid "Reconciliations"
|
||||||
msgstr "Reconciliations"
|
msgstr "Reconciliations"
|
||||||
|
@ -566,6 +574,10 @@ msgctxt "field:cashbook.book,booktransf_feature:"
|
||||||
msgid "Feature"
|
msgid "Feature"
|
||||||
msgstr "Feature"
|
msgstr "Feature"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.book,value_store:"
|
||||||
|
msgid "Values"
|
||||||
|
msgstr "Values"
|
||||||
|
|
||||||
msgctxt "model:cashbook.split,name:"
|
msgctxt "model:cashbook.split,name:"
|
||||||
msgid "Split booking line"
|
msgid "Split booking line"
|
||||||
msgstr "Split booking line"
|
msgstr "Split booking line"
|
||||||
|
@ -730,14 +742,6 @@ msgctxt "model:cashbook.line,name:"
|
||||||
msgid "Cashbook Line"
|
msgid "Cashbook Line"
|
||||||
msgstr "Cashbook Line"
|
msgstr "Cashbook Line"
|
||||||
|
|
||||||
msgctxt "view:cashbook.line:"
|
|
||||||
msgid "Credit"
|
|
||||||
msgstr "Credit"
|
|
||||||
|
|
||||||
msgctxt "view:cashbook.line:"
|
|
||||||
msgid "Debit"
|
|
||||||
msgstr "Debit"
|
|
||||||
|
|
||||||
msgctxt "view:cashbook.line:"
|
msgctxt "view:cashbook.line:"
|
||||||
msgid "Cashbook Line"
|
msgid "Cashbook Line"
|
||||||
msgstr "Cashbook Line"
|
msgstr "Cashbook Line"
|
||||||
|
@ -1182,6 +1186,14 @@ msgctxt "help:cashbook.configuration,book5:"
|
||||||
msgid "Cash book available in selection dialog."
|
msgid "Cash book available in selection dialog."
|
||||||
msgstr "Cash book available in selection dialog."
|
msgstr "Cash book available in selection dialog."
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.configuration,fixate:"
|
||||||
|
msgid "Fixate"
|
||||||
|
msgstr "Fixate"
|
||||||
|
|
||||||
|
msgctxt "help:cashbook.configuration,fixate:"
|
||||||
|
msgid "Fixating of the booking is activated."
|
||||||
|
msgstr "Fixating of the booking is activated."
|
||||||
|
|
||||||
msgctxt "field:cashbook.configuration,date_from:"
|
msgctxt "field:cashbook.configuration,date_from:"
|
||||||
msgid "Start Date"
|
msgid "Start Date"
|
||||||
msgstr "Start Date"
|
msgstr "Start Date"
|
||||||
|
@ -1298,6 +1310,14 @@ msgctxt "help:cashbook.configuration_user,book5:"
|
||||||
msgid "Cash book available in selection dialog."
|
msgid "Cash book available in selection dialog."
|
||||||
msgstr "Cash book available in selection dialog."
|
msgstr "Cash book available in selection dialog."
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.configuration_user,fixate:"
|
||||||
|
msgid "Fixate"
|
||||||
|
msgstr "Fixate"
|
||||||
|
|
||||||
|
msgctxt "help:cashbook.configuration_user,fixate:"
|
||||||
|
msgid "Fixating of the booking is activated."
|
||||||
|
msgstr "Fixating of the booking is activated."
|
||||||
|
|
||||||
msgctxt "model:cashbook.recon,name:"
|
msgctxt "model:cashbook.recon,name:"
|
||||||
msgid "Cashbook Reconciliation"
|
msgid "Cashbook Reconciliation"
|
||||||
msgstr "Cashbook Reconciliation"
|
msgstr "Cashbook Reconciliation"
|
||||||
|
@ -1550,6 +1570,18 @@ msgctxt "field:cashbook.enterbooking.start,party:"
|
||||||
msgid "Party"
|
msgid "Party"
|
||||||
msgstr "Party"
|
msgstr "Party"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.enterbooking.start,description:"
|
||||||
|
msgid "Description"
|
||||||
|
msgstr "Description"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.enterbooking.start,fixate:"
|
||||||
|
msgid "Fixate"
|
||||||
|
msgstr "Fixate"
|
||||||
|
|
||||||
|
msgctxt "help:cashbook.enterbooking.start,fixate:"
|
||||||
|
msgid "The booking is fixed immediately."
|
||||||
|
msgstr "The booking is fixed immediately."
|
||||||
|
|
||||||
msgctxt "model:cashbook.enterbooking,name:"
|
msgctxt "model:cashbook.enterbooking,name:"
|
||||||
msgid "Enter Booking"
|
msgid "Enter Booking"
|
||||||
msgstr "Enter Booking"
|
msgstr "Enter Booking"
|
||||||
|
@ -1562,3 +1594,23 @@ msgctxt "wizard_button:cashbook.enterbooking,start,save_:"
|
||||||
msgid "Save"
|
msgid "Save"
|
||||||
msgstr "Save"
|
msgstr "Save"
|
||||||
|
|
||||||
|
msgctxt "wizard_button:cashbook.enterbooking,start,savenext_:"
|
||||||
|
msgid "Save & Next"
|
||||||
|
msgstr "Save & Next"
|
||||||
|
|
||||||
|
msgctxt "model:cashbook.values,name:"
|
||||||
|
msgid "Value Store"
|
||||||
|
msgstr "Value Store"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.values,resource:"
|
||||||
|
msgid "Resource"
|
||||||
|
msgstr "Resource"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.values,field_name:"
|
||||||
|
msgid "Field Name"
|
||||||
|
msgstr "Field Name"
|
||||||
|
|
||||||
|
msgctxt "field:cashbook.values,numvalue:"
|
||||||
|
msgid "Value"
|
||||||
|
msgstr "Value"
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,12 @@ full copyright notices and license terms. -->
|
||||||
<record model="ir.message" id="msg_btype_general">
|
<record model="ir.message" id="msg_btype_general">
|
||||||
<field name="text">General</field>
|
<field name="text">General</field>
|
||||||
</record>
|
</record>
|
||||||
|
<record model="ir.message" id="msg_value_exists_in_store">
|
||||||
|
<field name="text">The value already exists for the record.</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.message" id="msg_nosearch_with_date">
|
||||||
|
<field name="text">Search with 'date' no allowed for field '%(fname)s' on model '%(model)s'.</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</tryton>
|
</tryton>
|
||||||
|
|
39
mixin.py
39
mixin.py
|
@ -3,7 +3,7 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.model import fields, Index
|
from trytond.model import fields
|
||||||
from trytond.pyson import Eval, Bool, Or
|
from trytond.pyson import Eval, Bool, Or
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.modules.currency.ir import rate_decimal
|
from trytond.modules.currency.ir import rate_decimal
|
||||||
|
@ -31,20 +31,19 @@ class SecondCurrencyMixin:
|
||||||
states={
|
states={
|
||||||
'readonly': Or(
|
'readonly': Or(
|
||||||
STATES['readonly'],
|
STATES['readonly'],
|
||||||
~Bool(Eval('currency2nd'))
|
~Bool(Eval('currency2nd'))),
|
||||||
),
|
|
||||||
'required': Bool(Eval('currency2nd')),
|
'required': Bool(Eval('currency2nd')),
|
||||||
'invisible': ~Bool(Eval('currency2nd')),
|
'invisible': ~Bool(Eval('currency2nd')),
|
||||||
}, depends=DEPENDS+['currency2nd_digits', 'currency2nd'])
|
}, depends=DEPENDS+['currency2nd_digits', 'currency2nd'])
|
||||||
rate_2nd_currency = fields.Function(fields.Numeric(
|
rate_2nd_currency = fields.Function(fields.Numeric(
|
||||||
string='Rate',
|
string='Rate',
|
||||||
help='Exchange rate between the currencies of the participating cashbooks.',
|
help='Exchange rate between the currencies of the ' +
|
||||||
|
'participating cashbooks.',
|
||||||
digits=(rate_decimal * 2, rate_decimal),
|
digits=(rate_decimal * 2, rate_decimal),
|
||||||
states={
|
states={
|
||||||
'readonly': Or(
|
'readonly': Or(
|
||||||
STATES['readonly'],
|
STATES['readonly'],
|
||||||
~Bool(Eval('currency2nd'))
|
~Bool(Eval('currency2nd'))),
|
||||||
),
|
|
||||||
'required': Bool(Eval('currency2nd')),
|
'required': Bool(Eval('currency2nd')),
|
||||||
'invisible': ~Bool(Eval('currency2nd')),
|
'invisible': ~Bool(Eval('currency2nd')),
|
||||||
}, depends=DEPENDS+['currency2nd_digits', 'currency2nd']),
|
}, depends=DEPENDS+['currency2nd_digits', 'currency2nd']),
|
||||||
|
@ -124,15 +123,13 @@ class SecondCurrencyMixin:
|
||||||
self.amount_2nd_currency = Currency.compute(
|
self.amount_2nd_currency = Currency.compute(
|
||||||
self.currency,
|
self.currency,
|
||||||
self.amount,
|
self.amount,
|
||||||
self.booktransf.currency
|
self.booktransf.currency)
|
||||||
)
|
|
||||||
if self.amount != Decimal('0.0'):
|
if self.amount != Decimal('0.0'):
|
||||||
self.rate_2nd_currency = \
|
self.rate_2nd_currency = \
|
||||||
self.amount_2nd_currency / self.amount
|
self.amount_2nd_currency / self.amount
|
||||||
else:
|
else:
|
||||||
self.amount_2nd_currency = self.booktransf.currency.round(
|
self.amount_2nd_currency = self.booktransf.currency.round(
|
||||||
self.amount * self.rate_2nd_currency
|
self.amount * self.rate_2nd_currency)
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_rate_2nd_currency(cls, lines, name, value):
|
def set_rate_2nd_currency(cls, lines, name, value):
|
||||||
|
@ -199,25 +196,3 @@ class SecondCurrencyMixin:
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
# end SecondCurrencyMixin
|
# end SecondCurrencyMixin
|
||||||
|
|
||||||
|
|
||||||
class MemCacheIndexMx:
|
|
||||||
""" add index to 'create_date' + 'write_date'
|
|
||||||
"""
|
|
||||||
__slots__ = ()
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def __setup__(cls):
|
|
||||||
super(MemCacheIndexMx, cls).__setup__()
|
|
||||||
t = cls.__table__()
|
|
||||||
# add index
|
|
||||||
cls._sql_indexes.update({
|
|
||||||
Index(
|
|
||||||
t,
|
|
||||||
(t.write_date, Index.Range())),
|
|
||||||
Index(
|
|
||||||
t,
|
|
||||||
(t.create_date, Index.Range())),
|
|
||||||
})
|
|
||||||
|
|
||||||
# end MemCacheIndexMx
|
|
||||||
|
|
174
model.py
174
model.py
|
@ -4,31 +4,12 @@
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.model import (
|
from trytond.model import (
|
||||||
MultiValueMixin, ValueMixin, fields, Unique, Model, Index)
|
MultiValueMixin, ValueMixin, fields, Unique, Index)
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.cache import MemoryCache
|
|
||||||
from trytond.config import config
|
|
||||||
from datetime import timedelta
|
|
||||||
from decimal import Decimal
|
|
||||||
from sql import With
|
from sql import With
|
||||||
from sql.functions import Function
|
from sql.functions import Function
|
||||||
from sql.conditionals import Coalesce
|
from .const import DEF_NONE
|
||||||
import copy
|
|
||||||
|
|
||||||
if config.get('cashbook', 'memcache', default='yes').lower() \
|
|
||||||
in ['yes', '1', 'true']:
|
|
||||||
ENABLE_CACHE = True
|
|
||||||
else:
|
|
||||||
ENABLE_CACHE = False
|
|
||||||
|
|
||||||
if config.get('cashbook', 'sync', default='yes').lower() \
|
|
||||||
in ['yes', '1', 'true']:
|
|
||||||
ENABLE_CACHESYNC = True
|
|
||||||
else:
|
|
||||||
ENABLE_CACHESYNC = False
|
|
||||||
|
|
||||||
CACHEKEY_CURRENCY = 'currency-%s'
|
|
||||||
|
|
||||||
|
|
||||||
class ArrayAgg(Function):
|
class ArrayAgg(Function):
|
||||||
|
@ -84,155 +65,6 @@ class Array(Function):
|
||||||
# end Array
|
# end Array
|
||||||
|
|
||||||
|
|
||||||
class MemCache(Model):
|
|
||||||
""" store values to cache
|
|
||||||
"""
|
|
||||||
__name__ = 'cashbook.memcache'
|
|
||||||
|
|
||||||
_cashbook_value_cache = MemoryCache(
|
|
||||||
'cashbook.book.valuecache',
|
|
||||||
context=False,
|
|
||||||
duration=timedelta(seconds=60*60*4))
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def read_value(cls, cache_key):
|
|
||||||
""" read values from cache
|
|
||||||
"""
|
|
||||||
if ENABLE_CACHE is False:
|
|
||||||
return None
|
|
||||||
return copy.deepcopy(cls._cashbook_value_cache.get(cache_key))
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def store_result(cls, records, cache_keys, values, skip_records=[]):
|
|
||||||
""" store result to cache
|
|
||||||
"""
|
|
||||||
if ENABLE_CACHE is False:
|
|
||||||
return
|
|
||||||
for record in records:
|
|
||||||
if record not in skip_records:
|
|
||||||
continue
|
|
||||||
data = {
|
|
||||||
x: values[x][record.id]
|
|
||||||
for x in values.keys() if record.id in values[x].keys()}
|
|
||||||
cls._cashbook_value_cache.set(
|
|
||||||
cache_keys[record.id], copy.deepcopy(data))
|
|
||||||
if ENABLE_CACHESYNC is True:
|
|
||||||
cls._cashbook_value_cache.sync(Transaction())
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def store_value(cls, cache_key, values):
|
|
||||||
""" store values to cache
|
|
||||||
"""
|
|
||||||
if ENABLE_CACHE is False:
|
|
||||||
return
|
|
||||||
cls._cashbook_value_cache.set(cache_key, copy.deepcopy(values))
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def read_from_cache(cls, records, cache_keys, names, result):
|
|
||||||
""" get stored values from memcache
|
|
||||||
"""
|
|
||||||
if ENABLE_CACHE is False:
|
|
||||||
return (records, result)
|
|
||||||
|
|
||||||
todo_records = []
|
|
||||||
for record in records:
|
|
||||||
values = copy.deepcopy(cls.read_value(cache_keys[record.id]))
|
|
||||||
if values:
|
|
||||||
for name in names:
|
|
||||||
if name not in values.keys():
|
|
||||||
continue
|
|
||||||
if values[name] is None:
|
|
||||||
continue
|
|
||||||
if result[name][record.id] is None:
|
|
||||||
result[name][record.id] = Decimal('0.0')
|
|
||||||
result[name][record.id] += values[name]
|
|
||||||
else:
|
|
||||||
todo_records.append(record)
|
|
||||||
return (todo_records, result)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_key_by_record(cls, name, record, query, addkeys=[]):
|
|
||||||
""" read records to build a cache-key
|
|
||||||
"""
|
|
||||||
pool = Pool()
|
|
||||||
cursor = Transaction().connection.cursor()
|
|
||||||
|
|
||||||
if ENABLE_CACHE is False:
|
|
||||||
return '-'
|
|
||||||
|
|
||||||
fname = [name, str(record.id)]
|
|
||||||
fname.extend(addkeys)
|
|
||||||
|
|
||||||
# query the last edited record for each item in 'query'
|
|
||||||
for line in query:
|
|
||||||
if len(line.keys()) == 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if 'cachekey' in line.keys():
|
|
||||||
key = cls.read_value(line['cachekey'])
|
|
||||||
if key:
|
|
||||||
fname.append(key)
|
|
||||||
continue
|
|
||||||
|
|
||||||
Model = pool.get(line['model'])
|
|
||||||
tab_model = Model.__table__()
|
|
||||||
|
|
||||||
tab_query = Model.search(line['query'], query=True)
|
|
||||||
qu1 = tab_model.join(
|
|
||||||
tab_query,
|
|
||||||
condition=tab_query.id == tab_model.id,
|
|
||||||
).select(
|
|
||||||
tab_model.id,
|
|
||||||
tab_model.write_date,
|
|
||||||
tab_model.create_date,
|
|
||||||
limit=1,
|
|
||||||
order_by=[
|
|
||||||
Coalesce(
|
|
||||||
tab_model.write_date, tab_model.create_date).desc,
|
|
||||||
tab_model.id.desc,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
cursor.execute(*qu1)
|
|
||||||
records = cursor.fetchall()
|
|
||||||
if len(records) > 0:
|
|
||||||
fname.append(cls.genkey(
|
|
||||||
records[0][0],
|
|
||||||
records[0][1],
|
|
||||||
records[0][2],
|
|
||||||
))
|
|
||||||
else:
|
|
||||||
fname.append('0')
|
|
||||||
|
|
||||||
if 'cachekey' in line.keys():
|
|
||||||
key = cls.store_value(line['cachekey'], fname[-1])
|
|
||||||
return '-'.join(fname)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def genkey(cls, id_record, write_date, create_date):
|
|
||||||
""" get key as text
|
|
||||||
"""
|
|
||||||
date_val = write_date if write_date is not None else create_date
|
|
||||||
return '-'.join([
|
|
||||||
str(id_record),
|
|
||||||
'%s%s' % (
|
|
||||||
'w' if write_date is not None else 'c',
|
|
||||||
date_val.timestamp() if date_val is not None else '-'),
|
|
||||||
])
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def record_update(cls, cache_key, record):
|
|
||||||
""" update cache-value
|
|
||||||
"""
|
|
||||||
if ENABLE_CACHE is False:
|
|
||||||
return
|
|
||||||
cls.store_value(
|
|
||||||
cache_key,
|
|
||||||
cls.genkey(record.id, record.write_date, record.create_date)
|
|
||||||
if record is not None else None)
|
|
||||||
|
|
||||||
# end mem_cache
|
|
||||||
|
|
||||||
|
|
||||||
def sub_ids_hierarchical(model_name):
|
def sub_ids_hierarchical(model_name):
|
||||||
""" get table with id and sub-ids
|
""" get table with id and sub-ids
|
||||||
"""
|
"""
|
||||||
|
@ -269,7 +101,7 @@ def order_name_hierarchical(model_name, tables):
|
||||||
lines = With('id', 'name', 'name_path', recursive=True)
|
lines = With('id', 'name', 'name_path', recursive=True)
|
||||||
lines.query = tab_mod.select(
|
lines.query = tab_mod.select(
|
||||||
tab_mod.id, tab_mod.name, Array(tab_mod.name),
|
tab_mod.id, tab_mod.name, Array(tab_mod.name),
|
||||||
where=tab_mod.parent == None,
|
where=tab_mod.parent == DEF_NONE,
|
||||||
)
|
)
|
||||||
lines.query |= tab_mod2.join(
|
lines.query |= tab_mod2.join(
|
||||||
lines,
|
lines,
|
||||||
|
|
|
@ -183,7 +183,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
if Line.search_count([
|
if Line.search_count([
|
||||||
('date', '>', reconciliation.date_from),
|
('date', '>', reconciliation.date_from),
|
||||||
('date', '<', reconciliation.date_to),
|
('date', '<', reconciliation.date_to),
|
||||||
('cashbook.id', '=', reconciliation.cashbook.id),
|
('cashbook', '=', reconciliation.cashbook.id),
|
||||||
('state', 'not in', ['check', 'recon']),
|
('state', 'not in', ['check', 'recon']),
|
||||||
]) > 0:
|
]) > 0:
|
||||||
raise UserError(gettext(
|
raise UserError(gettext(
|
||||||
|
@ -204,7 +204,8 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
# unlink lines from reconciliation
|
# unlink lines from reconciliation
|
||||||
if len(reconciliation.lines) > 0:
|
if len(reconciliation.lines) > 0:
|
||||||
values['lines'] = [('remove', [x.id for x in reconciliation.lines])]
|
values['lines'] = [
|
||||||
|
('remove', [x.id for x in reconciliation.lines])]
|
||||||
return values
|
return values
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -224,7 +225,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
lines = Line.search([
|
lines = Line.search([
|
||||||
('date', '>=', reconciliation.date_from),
|
('date', '>=', reconciliation.date_from),
|
||||||
('date', '<=', reconciliation.date_to),
|
('date', '<=', reconciliation.date_to),
|
||||||
('cashbook.id', '=', reconciliation.cashbook.id),
|
('cashbook', '=', reconciliation.cashbook.id),
|
||||||
('reconciliation', '=', None),
|
('reconciliation', '=', None),
|
||||||
('state', 'in', ['check', 'recon']),
|
('state', 'in', ['check', 'recon']),
|
||||||
])
|
])
|
||||||
|
@ -315,7 +316,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
# deny if there are lines not linked to reconciliation
|
# deny if there are lines not linked to reconciliation
|
||||||
if Line.search_count([
|
if Line.search_count([
|
||||||
('cashbook.id', '=', reconciliation.cashbook.id),
|
('cashbook', '=', reconciliation.cashbook.id),
|
||||||
('reconciliation', '=', None),
|
('reconciliation', '=', None),
|
||||||
['OR',
|
['OR',
|
||||||
[ # lines inside of date-range
|
[ # lines inside of date-range
|
||||||
|
@ -339,20 +340,24 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
def get_rec_name(self, name):
|
def get_rec_name(self, name):
|
||||||
""" short + name
|
""" short + name
|
||||||
"""
|
"""
|
||||||
return '%(from)s - %(to)s | %(start_amount)s %(symbol)s - %(end_amount)s %(symbol)s [%(num)s]' % {
|
return ' '.join([
|
||||||
'from': Report.format_date(self.date_from, None)
|
Report.format_date(self.date_from, None)
|
||||||
if self.date_from is not None else '-',
|
if self.date_from is not None else '-',
|
||||||
'to': Report.format_date(self.date_to, None)
|
'-',
|
||||||
if self.date_to is not None else '-',
|
Report.format_date(self.date_to, None)
|
||||||
'start_amount': Report.format_number(
|
if self.date_to is not None else '-',
|
||||||
|
'|',
|
||||||
|
Report.format_number(
|
||||||
self.start_amount or 0.0, None,
|
self.start_amount or 0.0, None,
|
||||||
digits=getattr(self.currency, 'digits', 2)),
|
digits=getattr(self.currency, 'digits', 2)),
|
||||||
'end_amount': Report.format_number(
|
getattr(self.currency, 'symbol', '-'),
|
||||||
|
'-',
|
||||||
|
Report.format_number(
|
||||||
self.end_amount or 0.0, None,
|
self.end_amount or 0.0, None,
|
||||||
digits=getattr(self.currency, 'digits', 2)),
|
digits=getattr(self.currency, 'digits', 2)),
|
||||||
'symbol': getattr(self.currency, 'symbol', '-'),
|
getattr(self.currency, 'symbol', '-'),
|
||||||
'num': len(self.lines),
|
'[%(num)s]' % {'num': len(self.lines)},
|
||||||
}
|
])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_date_from(cls):
|
def default_date_from(cls):
|
||||||
|
@ -405,7 +410,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
if self.cashbook:
|
if self.cashbook:
|
||||||
if self.date_from is not None:
|
if self.date_from is not None:
|
||||||
reconciliations = Recon.search([
|
reconciliations = Recon.search([
|
||||||
('cashbook.id', '=', self.cashbook.id),
|
('cashbook', '=', self.cashbook.id),
|
||||||
('date_from', '<', self.date_from),
|
('date_from', '<', self.date_from),
|
||||||
], order=[('date_from', 'DESC')], limit=1)
|
], order=[('date_from', 'DESC')], limit=1)
|
||||||
if len(reconciliations) > 0:
|
if len(reconciliations) > 0:
|
||||||
|
@ -457,7 +462,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
# set date_from to date_to of predecessor
|
# set date_from to date_to of predecessor
|
||||||
recons = Recon.search([
|
recons = Recon.search([
|
||||||
('cashbook.id', '=', id_cashbook),
|
('cashbook', '=', id_cashbook),
|
||||||
], order=[('date_to', 'DESC')], limit=1)
|
], order=[('date_to', 'DESC')], limit=1)
|
||||||
if len(recons) > 0:
|
if len(recons) > 0:
|
||||||
values['date_from'] = recons[0].date_to
|
values['date_from'] = recons[0].date_to
|
||||||
|
@ -466,7 +471,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
||||||
|
|
||||||
# set date_to to day of last 'checked'-booking in selected cashbook
|
# set date_to to day of last 'checked'-booking in selected cashbook
|
||||||
lines = Line.search([
|
lines = Line.search([
|
||||||
('cashbook.id', '=', id_cashbook),
|
('cashbook', '=', id_cashbook),
|
||||||
('state', '=', 'check'),
|
('state', '=', 'check'),
|
||||||
('reconciliation', '=', None),
|
('reconciliation', '=', None),
|
||||||
], order=[('date', 'DESC')], limit=1)
|
], order=[('date', 'DESC')], limit=1)
|
||||||
|
|
|
@ -96,8 +96,8 @@ full copyright notices and license terms. -->
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.rule" id="rg_recon_write-1">
|
<record model="ir.rule" id="rg_recon_write-1">
|
||||||
<field name="domain" eval="['OR',
|
<field name="domain" eval="['OR',
|
||||||
('cashbook.owner.id', '=', Eval('user', {}).get('id', -1)),
|
('cashbook.owner.id', '=', Eval('user_id', -1)),
|
||||||
('cashbook.reviewer.id', 'in', Eval('user', {}).get('groups', [])),
|
('cashbook.reviewer.id', 'in', Eval('groups', [])),
|
||||||
]" pyson="1"/>
|
]" pyson="1"/>
|
||||||
<field name="rule_group" ref="rg_recon_write"/>
|
<field name="rule_group" ref="rg_recon_write"/>
|
||||||
</record>
|
</record>
|
||||||
|
@ -119,7 +119,7 @@ full copyright notices and license terms. -->
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.rule" id="rg_recon_read-1">
|
<record model="ir.rule" id="rg_recon_read-1">
|
||||||
<field name="domain" eval="[
|
<field name="domain" eval="[
|
||||||
('cashbook.observer.id', 'in', Eval('user', {}).get('groups', [])),
|
('cashbook.observer.id', 'in', Eval('groups', [])),
|
||||||
]" pyson="1"/>
|
]" pyson="1"/>
|
||||||
<field name="rule_group" ref="rg_recon_read"/>
|
<field name="rule_group" ref="rg_recon_read"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
69
setup.py
69
setup.py
|
@ -2,7 +2,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Always prefer setuptools over distutils
|
# Always prefer setuptools over distutils
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup
|
||||||
# To use a consistent encoding
|
# To use a consistent encoding
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from os import path
|
from os import path
|
||||||
|
@ -36,10 +36,10 @@ with open(path.join(here, 'versiondep.txt'), encoding='utf-8') as f:
|
||||||
l2 = i.strip().split(';')
|
l2 = i.strip().split(';')
|
||||||
if len(l2) < 4:
|
if len(l2) < 4:
|
||||||
continue
|
continue
|
||||||
modversion[l2[0]] = {'min':l2[1], 'max':l2[2], 'prefix':l2[3]}
|
modversion[l2[0]] = {'min': l2[1], 'max': l2[2], 'prefix': l2[3]}
|
||||||
|
|
||||||
# tryton-version
|
# tryton-version
|
||||||
major_version = 6
|
major_version = 7
|
||||||
minor_version = 0
|
minor_version = 0
|
||||||
|
|
||||||
requires = ['python-slugify']
|
requires = ['python-slugify']
|
||||||
|
@ -51,19 +51,21 @@ for dep in info.get('depends', []):
|
||||||
prefix = modversion[dep]['prefix']
|
prefix = modversion[dep]['prefix']
|
||||||
|
|
||||||
if len(modversion[dep]['max']) > 0:
|
if len(modversion[dep]['max']) > 0:
|
||||||
requires.append('%s_%s >= %s, <= %s' %
|
requires.append('%s_%s >= %s, <= %s' % (
|
||||||
(prefix, dep, modversion[dep]['min'], modversion[dep]['max']))
|
prefix, dep, modversion[dep]['min'],
|
||||||
else :
|
modversion[dep]['max']))
|
||||||
requires.append('%s_%s >= %s' %
|
else:
|
||||||
(prefix, dep, modversion[dep]['min']))
|
requires.append('%s_%s >= %s' % (
|
||||||
else :
|
prefix, dep, modversion[dep]['min']))
|
||||||
requires.append('%s_%s >= %s.%s, < %s.%s' %
|
else:
|
||||||
('trytond', dep, major_version, minor_version,
|
requires.append('%s_%s >= %s.%s, < %s.%s' % (
|
||||||
|
'trytond', dep, major_version, minor_version,
|
||||||
major_version, minor_version + 1))
|
major_version, minor_version + 1))
|
||||||
requires.append('trytond >= %s.%s, < %s.%s' %
|
requires.append('trytond >= %s.%s, < %s.%s' % (
|
||||||
(major_version, minor_version, major_version, minor_version + 1))
|
major_version, minor_version, major_version, minor_version + 1))
|
||||||
|
|
||||||
setup(name='%s_%s' % (PREFIX, MODULE),
|
setup(
|
||||||
|
name='%s_%s' % (PREFIX, MODULE),
|
||||||
version=info.get('version', '0.0.1'),
|
version=info.get('version', '0.0.1'),
|
||||||
description='Tryton module to add a cashbook.',
|
description='Tryton module to add a cashbook.',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
@ -74,21 +76,22 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
||||||
author_email='service@m-ds.de',
|
author_email='service@m-ds.de',
|
||||||
license='GPL-3',
|
license='GPL-3',
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'Development Status :: 5 - Production/Stable',
|
'Development Status :: 5 - Production/Stable',
|
||||||
'Environment :: Plugins',
|
'Environment :: Plugins',
|
||||||
'Framework :: Tryton',
|
'Framework :: Tryton',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
'Intended Audience :: Customer Service',
|
'Intended Audience :: Customer Service',
|
||||||
'Intended Audience :: Information Technology',
|
'Intended Audience :: Information Technology',
|
||||||
'Intended Audience :: Financial and Insurance Industry',
|
'Intended Audience :: Financial and Insurance Industry',
|
||||||
'Topic :: Office/Business',
|
'Topic :: Office/Business',
|
||||||
'Topic :: Office/Business :: Financial :: Accounting',
|
'Topic :: Office/Business :: Financial :: Accounting',
|
||||||
'Natural Language :: German',
|
'Natural Language :: German',
|
||||||
'Natural Language :: English',
|
'Natural Language :: English',
|
||||||
'Operating System :: OS Independent',
|
'Operating System :: OS Independent',
|
||||||
'License :: OSI Approved :: GNU General Public License (GPL)',
|
'License :: OSI Approved :: GNU General Public License (GPL)',
|
||||||
'Programming Language :: Python :: 3.7',
|
'Programming Language :: Python :: 3.7',
|
||||||
'Programming Language :: Python :: 3.8',
|
'Programming Language :: Python :: 3.8',
|
||||||
|
'Programming Language :: Python :: 3.9',
|
||||||
],
|
],
|
||||||
|
|
||||||
keywords='tryton cashbook',
|
keywords='tryton cashbook',
|
||||||
|
@ -97,10 +100,10 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
||||||
'trytond.modules.%s' % MODULE,
|
'trytond.modules.%s' % MODULE,
|
||||||
],
|
],
|
||||||
package_data={
|
package_data={
|
||||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
'trytond.modules.%s' % MODULE: (info.get('xml', []) + [
|
||||||
+ ['tryton.cfg', 'locale/*.po', 'tests/*.py',
|
'tryton.cfg', 'locale/*.po', 'tests/*.py',
|
||||||
'view/*.xml', 'icon/*.svg', 'docs/*.txt',
|
'view/*.xml', 'icon/*.svg', 'docs/*.txt',
|
||||||
'report/*.fods', 'versiondep.txt', 'README.rst']),
|
'report/*.fods', 'versiondep.txt', 'README.rst']),
|
||||||
},
|
},
|
||||||
|
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
|
|
|
@ -9,9 +9,9 @@ from trytond.pool import Pool
|
||||||
from trytond.pyson import Eval, If
|
from trytond.pyson import Eval, If
|
||||||
from trytond.report import Report
|
from trytond.report import Report
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
from .line import sel_bookingtype, STATES, DEPENDS
|
from .line import sel_bookingtype, sel_linestate, STATES, DEPENDS
|
||||||
from .book import sel_state_book
|
from .book import sel_state_book
|
||||||
from .mixin import SecondCurrencyMixin, MemCacheIndexMx
|
from .mixin import SecondCurrencyMixin
|
||||||
|
|
||||||
|
|
||||||
sel_linetype = [
|
sel_linetype = [
|
||||||
|
@ -25,7 +25,7 @@ sel_target = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class SplitLine(SecondCurrencyMixin, MemCacheIndexMx, ModelSQL, ModelView):
|
class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
||||||
'Split booking line'
|
'Split booking line'
|
||||||
__name__ = 'cashbook.split'
|
__name__ = 'cashbook.split'
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class SplitLine(SecondCurrencyMixin, MemCacheIndexMx, ModelSQL, ModelView):
|
||||||
selection=sel_bookingtype), 'on_change_with_bookingtype')
|
selection=sel_bookingtype), 'on_change_with_bookingtype')
|
||||||
state = fields.Function(fields.Selection(
|
state = fields.Function(fields.Selection(
|
||||||
string='State', readonly=True,
|
string='State', readonly=True,
|
||||||
selection=sel_linetype), 'on_change_with_state')
|
selection=sel_linestate), 'on_change_with_state')
|
||||||
cashbook = fields.Function(fields.Many2One(
|
cashbook = fields.Function(fields.Many2One(
|
||||||
string='Cashbook',
|
string='Cashbook',
|
||||||
readonly=True, states={'invisible': True}, model_name='cashbook.book'),
|
readonly=True, states={'invisible': True}, model_name='cashbook.book'),
|
||||||
|
|
|
@ -80,8 +80,8 @@ full copyright notices and license terms. -->
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.rule" id="rg_split_write-1">
|
<record model="ir.rule" id="rg_split_write-1">
|
||||||
<field name="domain" eval="['OR',
|
<field name="domain" eval="['OR',
|
||||||
('line.cashbook.owner.id', '=', Eval('user', {}).get('id', -1)),
|
('line.cashbook.owner.id', '=', Eval('user_id', -1)),
|
||||||
('line.cashbook.reviewer.id', 'in', Eval('user', {}).get('groups', [])),
|
('line.cashbook.reviewer.id', 'in', Eval('groups', [])),
|
||||||
]" pyson="1"/>
|
]" pyson="1"/>
|
||||||
<field name="rule_group" ref="rg_split_write"/>
|
<field name="rule_group" ref="rg_split_write"/>
|
||||||
</record>
|
</record>
|
||||||
|
@ -103,7 +103,7 @@ full copyright notices and license terms. -->
|
||||||
</record>
|
</record>
|
||||||
<record model="ir.rule" id="rg_split_read-1">
|
<record model="ir.rule" id="rg_split_read-1">
|
||||||
<field name="domain" eval="[
|
<field name="domain" eval="[
|
||||||
('line.cashbook.observer.id', 'in', Eval('user', {}).get('groups', [])),
|
('line.cashbook.observer.id', 'in', Eval('groups', [])),
|
||||||
]" pyson="1"/>
|
]" pyson="1"/>
|
||||||
<field name="rule_group" ref="rg_split_read"/>
|
<field name="rule_group" ref="rg_split_read"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
@ -307,6 +307,10 @@ class BookTestCase(object):
|
||||||
Book.search_count([('balance_all', '<', Decimal('5.0'))]),
|
Book.search_count([('balance_all', '<', Decimal('5.0'))]),
|
||||||
0)
|
0)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([('balance_ref', '<', Decimal('5.0'))]),
|
||||||
|
0)
|
||||||
|
|
||||||
@with_transaction()
|
@with_transaction()
|
||||||
def test_book_deny_btype_set_none(self):
|
def test_book_deny_btype_set_none(self):
|
||||||
""" create cashbook, add lines,
|
""" create cashbook, add lines,
|
||||||
|
|
|
@ -24,6 +24,7 @@ class BookingWizardTestCase(object):
|
||||||
Category = pool.get('cashbook.category')
|
Category = pool.get('cashbook.category')
|
||||||
Party = pool.get('party.party')
|
Party = pool.get('party.party')
|
||||||
IrDate = pool.get('ir.date')
|
IrDate = pool.get('ir.date')
|
||||||
|
Config = pool.get('cashbook.configuration')
|
||||||
|
|
||||||
company = self.prep_company()
|
company = self.prep_company()
|
||||||
with Transaction().set_context({
|
with Transaction().set_context({
|
||||||
|
@ -51,6 +52,10 @@ class BookingWizardTestCase(object):
|
||||||
'cattype': 'out',
|
'cattype': 'out',
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
cfg1 = Config()
|
||||||
|
cfg1.fixate = True
|
||||||
|
cfg1.save()
|
||||||
|
|
||||||
(sess_id, start_state, end_state) = BookingWiz.create()
|
(sess_id, start_state, end_state) = BookingWiz.create()
|
||||||
w_obj = BookingWiz(sess_id)
|
w_obj = BookingWiz(sess_id)
|
||||||
self.assertEqual(start_state, 'start')
|
self.assertEqual(start_state, 'start')
|
||||||
|
@ -65,6 +70,7 @@ class BookingWizardTestCase(object):
|
||||||
self.assertEqual(result['view']['defaults']['booktransf'], None)
|
self.assertEqual(result['view']['defaults']['booktransf'], None)
|
||||||
self.assertEqual(result['view']['defaults']['description'], None)
|
self.assertEqual(result['view']['defaults']['description'], None)
|
||||||
self.assertEqual(result['view']['defaults']['category'], None)
|
self.assertEqual(result['view']['defaults']['category'], None)
|
||||||
|
self.assertEqual(result['view']['defaults']['fixate'], True)
|
||||||
|
|
||||||
self.assertEqual(len(book.lines), 0)
|
self.assertEqual(len(book.lines), 0)
|
||||||
|
|
||||||
|
@ -75,7 +81,7 @@ class BookingWizardTestCase(object):
|
||||||
'description': 'Test 1',
|
'description': 'Test 1',
|
||||||
'category': categories[1].id,
|
'category': categories[1].id,
|
||||||
'bookingtype': 'out',
|
'bookingtype': 'out',
|
||||||
}
|
'fixate': True}
|
||||||
for x in r1.keys():
|
for x in r1.keys():
|
||||||
setattr(w_obj.start, x, r1[x])
|
setattr(w_obj.start, x, r1[x])
|
||||||
|
|
||||||
|
@ -88,6 +94,7 @@ class BookingWizardTestCase(object):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
book.lines[0].rec_name,
|
book.lines[0].rec_name,
|
||||||
'05/01/2022|Exp|-10.00 usd|Test 1 [Food]')
|
'05/01/2022|Exp|-10.00 usd|Test 1 [Food]')
|
||||||
|
self.assertEqual(book.lines[0].state, 'check')
|
||||||
|
|
||||||
@with_transaction()
|
@with_transaction()
|
||||||
def test_bookwiz_transfer(self):
|
def test_bookwiz_transfer(self):
|
||||||
|
@ -147,6 +154,7 @@ class BookingWizardTestCase(object):
|
||||||
self.assertEqual(result['view']['defaults']['booktransf'], None)
|
self.assertEqual(result['view']['defaults']['booktransf'], None)
|
||||||
self.assertEqual(result['view']['defaults']['description'], None)
|
self.assertEqual(result['view']['defaults']['description'], None)
|
||||||
self.assertEqual(result['view']['defaults']['category'], None)
|
self.assertEqual(result['view']['defaults']['category'], None)
|
||||||
|
self.assertEqual(result['view']['defaults']['fixate'], False)
|
||||||
|
|
||||||
self.assertEqual(len(books[0].lines), 0)
|
self.assertEqual(len(books[0].lines), 0)
|
||||||
self.assertEqual(len(books[1].lines), 0)
|
self.assertEqual(len(books[1].lines), 0)
|
||||||
|
@ -157,7 +165,7 @@ class BookingWizardTestCase(object):
|
||||||
'description': 'Test 1',
|
'description': 'Test 1',
|
||||||
'booktransf': books[1].id,
|
'booktransf': books[1].id,
|
||||||
'bookingtype': 'mvout',
|
'bookingtype': 'mvout',
|
||||||
}
|
'fixate': False}
|
||||||
for x in r1.keys():
|
for x in r1.keys():
|
||||||
setattr(w_obj.start, x, r1[x])
|
setattr(w_obj.start, x, r1[x])
|
||||||
|
|
||||||
|
|
|
@ -178,10 +178,12 @@ class ConfigTestCase(object):
|
||||||
self.assertEqual(cfg2.date_to, None)
|
self.assertEqual(cfg2.date_to, None)
|
||||||
self.assertEqual(cfg2.checked, True)
|
self.assertEqual(cfg2.checked, True)
|
||||||
self.assertEqual(cfg2.done, False)
|
self.assertEqual(cfg2.done, False)
|
||||||
|
self.assertEqual(cfg2.fixate, False)
|
||||||
|
|
||||||
cfg2.date_from = date(2022, 4, 1)
|
cfg2.date_from = date(2022, 4, 1)
|
||||||
cfg2.date_to = date(2022, 5, 30)
|
cfg2.date_to = date(2022, 5, 30)
|
||||||
cfg2.checked = False
|
cfg2.checked = False
|
||||||
|
cfg2.fixate = True
|
||||||
cfg2.save()
|
cfg2.save()
|
||||||
|
|
||||||
# change to user 'diego'
|
# change to user 'diego'
|
||||||
|
@ -194,6 +196,7 @@ class ConfigTestCase(object):
|
||||||
self.assertEqual(cfg2.date_to, None)
|
self.assertEqual(cfg2.date_to, None)
|
||||||
self.assertEqual(cfg2.checked, True)
|
self.assertEqual(cfg2.checked, True)
|
||||||
self.assertEqual(cfg2.done, False)
|
self.assertEqual(cfg2.done, False)
|
||||||
|
self.assertEqual(cfg2.fixate, False)
|
||||||
|
|
||||||
cfg2.date_from = date(2022, 4, 15)
|
cfg2.date_from = date(2022, 4, 15)
|
||||||
cfg2.date_to = date(2022, 5, 15)
|
cfg2.date_to = date(2022, 5, 15)
|
||||||
|
@ -209,5 +212,6 @@ class ConfigTestCase(object):
|
||||||
self.assertEqual(cfg2.date_to, date(2022, 5, 30))
|
self.assertEqual(cfg2.date_to, date(2022, 5, 30))
|
||||||
self.assertEqual(cfg2.checked, False)
|
self.assertEqual(cfg2.checked, False)
|
||||||
self.assertEqual(cfg2.done, False)
|
self.assertEqual(cfg2.done, False)
|
||||||
|
self.assertEqual(cfg2.fixate, True)
|
||||||
|
|
||||||
# end ConfigTestCase
|
# end ConfigTestCase
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# This file is part of the cashbook-module 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.tests.test_tryton import with_transaction
|
|
||||||
from trytond.pool import Pool
|
|
||||||
from trytond.modules.cashbook.model import CACHEKEY_CURRENCY, ENABLE_CACHE
|
|
||||||
from datetime import date
|
|
||||||
from decimal import Decimal
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
class CurrencyTestCase(object):
|
|
||||||
""" test currency
|
|
||||||
"""
|
|
||||||
@with_transaction()
|
|
||||||
def test_currency_update_cache(self):
|
|
||||||
""" add/update/del rate of currency, check cache
|
|
||||||
"""
|
|
||||||
pool = Pool()
|
|
||||||
MemCache = pool.get('cashbook.memcache')
|
|
||||||
Currency = pool.get('currency.currency')
|
|
||||||
CurrencyRate = pool.get('currency.currency.rate')
|
|
||||||
|
|
||||||
self.prep_config()
|
|
||||||
self.prep_company()
|
|
||||||
|
|
||||||
MemCache._cashbook_value_cache.clear_all()
|
|
||||||
currency, = Currency.search([('name', '=', 'usd')])
|
|
||||||
|
|
||||||
cache_key = CACHEKEY_CURRENCY % currency.id
|
|
||||||
|
|
||||||
# cache should be empty
|
|
||||||
self.assertEqual(MemCache.read_value(cache_key), None)
|
|
||||||
CurrencyRate.delete(currency.rates)
|
|
||||||
self.assertEqual(len(currency.rates), 0)
|
|
||||||
|
|
||||||
# add rate
|
|
||||||
Currency.write(*[
|
|
||||||
[currency],
|
|
||||||
{
|
|
||||||
'rates': [('create', [{
|
|
||||||
'date': date(2022, 5, 1),
|
|
||||||
'rate': Decimal('1.05'),
|
|
||||||
}])],
|
|
||||||
}])
|
|
||||||
self.assertEqual(len(currency.rates), 1)
|
|
||||||
|
|
||||||
# expected key
|
|
||||||
value = '%d-c%s' % (
|
|
||||||
currency.rates[0].id,
|
|
||||||
str(currency.rates[0].create_date.timestamp()))
|
|
||||||
if ENABLE_CACHE is True:
|
|
||||||
self.assertEqual(MemCache.read_value(cache_key), value)
|
|
||||||
else:
|
|
||||||
self.assertEqual(MemCache.read_value(cache_key), None)
|
|
||||||
time.sleep(1.0)
|
|
||||||
|
|
||||||
Currency.write(*[
|
|
||||||
[currency],
|
|
||||||
{
|
|
||||||
'rates': [
|
|
||||||
('write', [currency.rates[0].id], {
|
|
||||||
'rate': Decimal('1.06'),
|
|
||||||
})],
|
|
||||||
}])
|
|
||||||
self.assertEqual(len(currency.rates), 1)
|
|
||||||
|
|
||||||
value = '%d-w%s' % (
|
|
||||||
currency.rates[0].id,
|
|
||||||
str(currency.rates[0].write_date.timestamp()))
|
|
||||||
if ENABLE_CACHE is True:
|
|
||||||
self.assertEqual(MemCache.read_value(cache_key), value)
|
|
||||||
else:
|
|
||||||
self.assertEqual(MemCache.read_value(cache_key), None)
|
|
||||||
|
|
||||||
Currency.write(*[
|
|
||||||
[currency],
|
|
||||||
{
|
|
||||||
'rates': [('delete', [currency.rates[0].id])],
|
|
||||||
}])
|
|
||||||
self.assertEqual(MemCache.read_value(cache_key), None)
|
|
||||||
|
|
||||||
# end CurrencyTestCase
|
|
|
@ -291,6 +291,8 @@ class LineTestCase(object):
|
||||||
self.assertEqual(books[0].lines[0].reference, None)
|
self.assertEqual(books[0].lines[0].reference, None)
|
||||||
self.assertEqual(len(books[0].lines[0].references), 1)
|
self.assertEqual(len(books[0].lines[0].references), 1)
|
||||||
|
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
books[0].lines[0].rec_name,
|
books[0].lines[0].rec_name,
|
||||||
'05/05/2022|to|-10.00 usd|Transfer USD --> ' +
|
'05/05/2022|to|-10.00 usd|Transfer USD --> ' +
|
||||||
|
@ -366,6 +368,8 @@ class LineTestCase(object):
|
||||||
self.assertEqual(books[0].lines[0].reference, None)
|
self.assertEqual(books[0].lines[0].reference, None)
|
||||||
self.assertEqual(len(books[0].lines[0].references), 1)
|
self.assertEqual(len(books[0].lines[0].references), 1)
|
||||||
|
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
books[0].lines[0].rec_name,
|
books[0].lines[0].rec_name,
|
||||||
'05/05/2022|from|10.00 usd|Transfer USD <-- ' +
|
'05/05/2022|from|10.00 usd|Transfer USD <-- ' +
|
||||||
|
@ -458,6 +462,8 @@ class LineTestCase(object):
|
||||||
self.assertEqual(books[0].lines[0].reference, None)
|
self.assertEqual(books[0].lines[0].reference, None)
|
||||||
self.assertEqual(len(books[0].lines[0].references), 1)
|
self.assertEqual(len(books[0].lines[0].references), 1)
|
||||||
|
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
|
||||||
# 10 CHF --> USD: USD = CHF * 1.05 / 1.04
|
# 10 CHF --> USD: USD = CHF * 1.05 / 1.04
|
||||||
# 10 CHF = 10.0961538 USD
|
# 10 CHF = 10.0961538 USD
|
||||||
# EUR | USD | CHF
|
# EUR | USD | CHF
|
||||||
|
@ -1147,6 +1153,8 @@ class LineTestCase(object):
|
||||||
# set line to 'checked', this creates the counterpart
|
# set line to 'checked', this creates the counterpart
|
||||||
Line.wfcheck(list(book.lines))
|
Line.wfcheck(list(book.lines))
|
||||||
|
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
|
||||||
self.assertEqual(len(book.lines), 1)
|
self.assertEqual(len(book.lines), 1)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
book.lines[0].rec_name,
|
book.lines[0].rec_name,
|
||||||
|
@ -1216,6 +1224,8 @@ class LineTestCase(object):
|
||||||
# set line to 'checked', this creates the counterpart
|
# set line to 'checked', this creates the counterpart
|
||||||
Line.wfcheck(list(book.lines))
|
Line.wfcheck(list(book.lines))
|
||||||
|
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
|
||||||
self.assertEqual(len(book.lines), 1)
|
self.assertEqual(len(book.lines), 1)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
book.lines[0].rec_name,
|
book.lines[0].rec_name,
|
||||||
|
|
|
@ -73,6 +73,26 @@ class SplitLineTestCase(object):
|
||||||
book.lines[0].splitlines[1].rec_name,
|
book.lines[0].splitlines[1].rec_name,
|
||||||
'Rev/Sp|6.00 usd|from cashbook [Cat1]')
|
'Rev/Sp|6.00 usd|from cashbook [Cat1]')
|
||||||
|
|
||||||
|
# check function fields
|
||||||
|
self.assertEqual(
|
||||||
|
book.lines[0].splitlines[0].category_view,
|
||||||
|
'Cat1')
|
||||||
|
self.assertEqual(book.lines[0].splitlines[0].date, date(2022, 5, 1))
|
||||||
|
self.assertEqual(book.lines[0].splitlines[0].target.rec_name, 'Cat1')
|
||||||
|
self.assertEqual(book.lines[0].splitlines[0].currency.rec_name, 'usd')
|
||||||
|
self.assertEqual(book.lines[0].splitlines[0].currency_digits, 2)
|
||||||
|
self.assertEqual(book.lines[0].splitlines[0].bookingtype, 'spin')
|
||||||
|
self.assertEqual(book.lines[0].splitlines[0].state, 'edit')
|
||||||
|
self.assertEqual(
|
||||||
|
book.lines[0].splitlines[0].cashbook.rec_name,
|
||||||
|
'Book 1 | 11.00 usd | Open')
|
||||||
|
self.assertEqual(book.lines[0].splitlines[0].feature, 'gen')
|
||||||
|
self.assertEqual(book.lines[0].splitlines[0].booktransf_feature, None)
|
||||||
|
self.assertEqual(book.lines[0].splitlines[0].state_cashbook, 'open')
|
||||||
|
self.assertEqual(
|
||||||
|
book.lines[0].splitlines[0].owner_cashbook.rec_name,
|
||||||
|
'Administrator')
|
||||||
|
|
||||||
@with_transaction()
|
@with_transaction()
|
||||||
def test_splitline_category_and_transfer(self):
|
def test_splitline_category_and_transfer(self):
|
||||||
""" add book, line, two split-lines,
|
""" add book, line, two split-lines,
|
||||||
|
|
|
@ -14,11 +14,11 @@ from .config import ConfigTestCase
|
||||||
from .category import CategoryTestCase
|
from .category import CategoryTestCase
|
||||||
from .reconciliation import ReconTestCase
|
from .reconciliation import ReconTestCase
|
||||||
from .bookingwiz import BookingWizardTestCase
|
from .bookingwiz import BookingWizardTestCase
|
||||||
from .currency import CurrencyTestCase
|
from .valuestore import ValuestoreTestCase
|
||||||
|
|
||||||
|
|
||||||
class CashbookTestCase(
|
class CashbookTestCase(
|
||||||
CurrencyTestCase,
|
ValuestoreTestCase,
|
||||||
BookingWizardTestCase,
|
BookingWizardTestCase,
|
||||||
ReconTestCase,
|
ReconTestCase,
|
||||||
CategoryTestCase,
|
CategoryTestCase,
|
||||||
|
|
840
tests/valuestore.py
Normal file
840
tests/valuestore.py
Normal file
|
@ -0,0 +1,840 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# This file is part of the cashbook-module from m-ds for Tryton.
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
from datetime import date, timedelta
|
||||||
|
from decimal import Decimal
|
||||||
|
from trytond.tests.test_tryton import with_transaction
|
||||||
|
from trytond.pool import Pool
|
||||||
|
from trytond.exceptions import UserError
|
||||||
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
|
|
||||||
|
class ValuestoreTestCase(object):
|
||||||
|
""" test storage of values
|
||||||
|
"""
|
||||||
|
@with_transaction()
|
||||||
|
def test_valstore_update_currency_rate(self):
|
||||||
|
""" create cashbook, check update of cashbook on
|
||||||
|
update of rates of currency
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Book = pool.get('cashbook.book')
|
||||||
|
ValueStore = pool.get('cashbook.values')
|
||||||
|
Currency = pool.get('currency.currency')
|
||||||
|
Queue = pool.get('ir.queue')
|
||||||
|
|
||||||
|
types = self.prep_type()
|
||||||
|
company = self.prep_company()
|
||||||
|
(usd, euro) = self.prep_2nd_currency(company)
|
||||||
|
self.assertEqual(company.currency.rec_name, 'Euro')
|
||||||
|
|
||||||
|
with Transaction().set_context({
|
||||||
|
'company': company.id,
|
||||||
|
'date': date(2022, 5, 20)}):
|
||||||
|
|
||||||
|
self.assertEqual(Queue.search_count([]), 0)
|
||||||
|
|
||||||
|
category = self.prep_category(cattype='in')
|
||||||
|
party = self.prep_party()
|
||||||
|
book, = Book.create([{
|
||||||
|
'name': 'Book 1',
|
||||||
|
'btype': types.id,
|
||||||
|
'company': company.id,
|
||||||
|
'currency': usd.id,
|
||||||
|
'number_sequ': self.prep_sequence().id,
|
||||||
|
'start_date': date(2022, 5, 1),
|
||||||
|
'lines': [('create', [{
|
||||||
|
'date': date(2022, 5, 1),
|
||||||
|
'description': '10 US$',
|
||||||
|
'category': category.id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('10.0'),
|
||||||
|
'party': party.id,
|
||||||
|
}, {
|
||||||
|
'date': date(2022, 5, 10),
|
||||||
|
'description': '5 US$',
|
||||||
|
'category': category.id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('5.0'),
|
||||||
|
'party': party.id,
|
||||||
|
}])],
|
||||||
|
}])
|
||||||
|
|
||||||
|
# run worker
|
||||||
|
self.assertEqual(
|
||||||
|
ValueStore.search_count([]),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
|
||||||
|
book, = Book.search([])
|
||||||
|
self.assertEqual(book.rec_name, 'Book 1 | 15.00 usd | Open')
|
||||||
|
self.assertEqual(book.balance, Decimal('15.0'))
|
||||||
|
self.assertEqual(book.balance_all, Decimal('15.0'))
|
||||||
|
self.assertEqual(book.balance_ref, Decimal('14.29'))
|
||||||
|
self.assertEqual(
|
||||||
|
len(book.value_store),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[0].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[1].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance_all|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[2].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance_ref|14.29|2')
|
||||||
|
|
||||||
|
# add rate to usd
|
||||||
|
self.assertEqual(Queue.search_count([]), 0)
|
||||||
|
Currency.write(*[
|
||||||
|
[usd],
|
||||||
|
{
|
||||||
|
'rates': [('create', [{
|
||||||
|
'date': date(2022, 5, 6),
|
||||||
|
'rate': Decimal('1.08'),
|
||||||
|
}])],
|
||||||
|
}])
|
||||||
|
self.assertEqual(Queue.search_count([]), 1)
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
self.assertEqual(Queue.search_count([]), 0)
|
||||||
|
|
||||||
|
# check reference-currency
|
||||||
|
book, = Book.search([])
|
||||||
|
self.assertEqual(book.rec_name, 'Book 1 | 15.00 usd | Open')
|
||||||
|
self.assertEqual(book.balance, Decimal('15.0'))
|
||||||
|
self.assertEqual(book.balance_all, Decimal('15.0'))
|
||||||
|
self.assertEqual(book.balance_ref, Decimal('13.89'))
|
||||||
|
self.assertEqual(
|
||||||
|
len(book.value_store),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[0].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[1].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance_all|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[2].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance_ref|13.89|2')
|
||||||
|
|
||||||
|
# find rate
|
||||||
|
self.assertEqual(len(usd.rates), 2)
|
||||||
|
self.assertEqual(usd.rates[0].date, date(2022, 5, 6))
|
||||||
|
self.assertEqual(usd.rates[0].rate, Decimal('1.08'))
|
||||||
|
|
||||||
|
# update rate
|
||||||
|
self.assertEqual(Queue.search_count([]), 0)
|
||||||
|
Currency.write(*[
|
||||||
|
[usd],
|
||||||
|
{
|
||||||
|
'rates': [(
|
||||||
|
'write',
|
||||||
|
[usd.rates[0]],
|
||||||
|
{'rate': Decimal('1.12')})],
|
||||||
|
}])
|
||||||
|
self.assertEqual(Queue.search_count([]), 1)
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
self.assertEqual(Queue.search_count([]), 0)
|
||||||
|
|
||||||
|
book, = Book.search([])
|
||||||
|
self.assertEqual(book.rec_name, 'Book 1 | 15.00 usd | Open')
|
||||||
|
self.assertEqual(book.balance_ref, Decimal('13.39'))
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[2].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance_ref|13.39|2')
|
||||||
|
|
||||||
|
# delete rate
|
||||||
|
self.assertEqual(Queue.search_count([]), 0)
|
||||||
|
Currency.write(*[
|
||||||
|
[usd],
|
||||||
|
{
|
||||||
|
'rates': [('delete', [usd.rates[0]])],
|
||||||
|
}])
|
||||||
|
self.assertEqual(Queue.search_count([]), 1)
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
self.assertEqual(Queue.search_count([]), 0)
|
||||||
|
|
||||||
|
book, = Book.search([])
|
||||||
|
self.assertEqual(book.rec_name, 'Book 1 | 15.00 usd | Open')
|
||||||
|
self.assertEqual(book.balance_ref, Decimal('14.29'))
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[2].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance_ref|14.29|2')
|
||||||
|
|
||||||
|
def prep_valstore_run_worker(self):
|
||||||
|
""" run tasks from queue
|
||||||
|
"""
|
||||||
|
Queue = Pool().get('ir.queue')
|
||||||
|
|
||||||
|
tasks = Queue.search([])
|
||||||
|
for task in tasks:
|
||||||
|
task.run()
|
||||||
|
Queue.delete(tasks)
|
||||||
|
|
||||||
|
@with_transaction()
|
||||||
|
def test_valstore_update_store_values(self):
|
||||||
|
""" create cashbook, store value
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Book = pool.get('cashbook.book')
|
||||||
|
ValueStore = pool.get('cashbook.values')
|
||||||
|
Queue = pool.get('ir.queue')
|
||||||
|
|
||||||
|
types = self.prep_type()
|
||||||
|
company = self.prep_company()
|
||||||
|
(usd, euro) = self.prep_2nd_currency(company)
|
||||||
|
self.assertEqual(company.currency.rec_name, 'Euro')
|
||||||
|
|
||||||
|
with Transaction().set_context({'company': company.id}):
|
||||||
|
|
||||||
|
self.assertEqual(Queue.search_count([]), 0)
|
||||||
|
|
||||||
|
category = self.prep_category(cattype='in')
|
||||||
|
party = self.prep_party()
|
||||||
|
book, = Book.create([{
|
||||||
|
'name': 'Book 1',
|
||||||
|
'btype': types.id,
|
||||||
|
'company': company.id,
|
||||||
|
'currency': usd.id,
|
||||||
|
'number_sequ': self.prep_sequence().id,
|
||||||
|
'start_date': date(2022, 5, 1),
|
||||||
|
'lines': [('create', [{
|
||||||
|
'date': date(2022, 5, 1),
|
||||||
|
'description': '10 US$',
|
||||||
|
'category': category.id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('10.0'),
|
||||||
|
'party': party.id,
|
||||||
|
}, {
|
||||||
|
'date': date(2022, 5, 10),
|
||||||
|
'description': '5 US$',
|
||||||
|
'category': category.id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('5.0'),
|
||||||
|
'party': party.id,
|
||||||
|
}])],
|
||||||
|
}])
|
||||||
|
|
||||||
|
# run worker
|
||||||
|
self.assertEqual(
|
||||||
|
ValueStore.search_count([]),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
|
||||||
|
# check values until 2022-05-05
|
||||||
|
with Transaction().set_context({
|
||||||
|
'date': date(2022, 5, 5)}):
|
||||||
|
|
||||||
|
book, = Book.search([])
|
||||||
|
self.assertEqual(book.rec_name, 'Book 1 | 10.00 usd | Open')
|
||||||
|
self.assertEqual(book.balance, Decimal('10.0'))
|
||||||
|
self.assertEqual(book.balance_all, Decimal('15.0'))
|
||||||
|
self.assertEqual(book.balance_ref, Decimal('14.29'))
|
||||||
|
self.assertEqual(
|
||||||
|
len(book.value_store),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[0].rec_name,
|
||||||
|
'[Book 1 | 10.00 usd | Open]|balance|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[1].rec_name,
|
||||||
|
'[Book 1 | 10.00 usd | Open]|balance_all|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
book.value_store[2].rec_name,
|
||||||
|
'[Book 1 | 10.00 usd | Open]|balance_ref|14.29|2')
|
||||||
|
|
||||||
|
# values created by book-create, without context
|
||||||
|
self.assertEqual(
|
||||||
|
ValueStore.search_count([]),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
|
||||||
|
values = ValueStore.search([], order=[('field_name', 'ASC')])
|
||||||
|
self.assertEqual(
|
||||||
|
len(values),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
self.assertEqual(
|
||||||
|
values[0].rec_name,
|
||||||
|
'[Book 1 | 10.00 usd | Open]|balance|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[1].rec_name,
|
||||||
|
'[Book 1 | 10.00 usd | Open]|balance_all|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[2].rec_name,
|
||||||
|
'[Book 1 | 10.00 usd | Open]|balance_ref|14.29|2')
|
||||||
|
|
||||||
|
# check write of too much digits
|
||||||
|
self.assertRaisesRegex(
|
||||||
|
UserError,
|
||||||
|
r'The number of digits in the value ' +
|
||||||
|
r'"' + r"'12.345'" +
|
||||||
|
r'" for field "Value" in "[Book 1 | 10\.00 usd | ' +
|
||||||
|
r'Open]|balance|12\.35|2" of "Value Store" exceeds ' +
|
||||||
|
r'the limit of "2".',
|
||||||
|
ValueStore.write,
|
||||||
|
*[
|
||||||
|
[values[0]],
|
||||||
|
{
|
||||||
|
'numvalue': Decimal('12.345'),
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
# update with context
|
||||||
|
Book.valuestore_update_records([book])
|
||||||
|
|
||||||
|
values = ValueStore.search([], order=[('field_name', 'ASC')])
|
||||||
|
self.assertEqual(
|
||||||
|
len(values),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[0].rec_name,
|
||||||
|
'[Book 1 | 10.00 usd | Open]|balance|10.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[1].rec_name,
|
||||||
|
'[Book 1 | 10.00 usd | Open]|balance_all|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[2].rec_name,
|
||||||
|
'[Book 1 | 10.00 usd | Open]|balance_ref|14.29|2')
|
||||||
|
|
||||||
|
# check values until 2022-05-15
|
||||||
|
with Transaction().set_context({
|
||||||
|
'date': date(2022, 5, 15)}):
|
||||||
|
|
||||||
|
book, = Book.search([])
|
||||||
|
self.assertEqual(book.rec_name, 'Book 1 | 15.00 usd | Open')
|
||||||
|
self.assertEqual(book.balance, Decimal('15.0'))
|
||||||
|
self.assertEqual(book.balance_all, Decimal('15.0'))
|
||||||
|
self.assertEqual(book.balance_ref, Decimal('14.29'))
|
||||||
|
|
||||||
|
# update values
|
||||||
|
self.assertEqual(
|
||||||
|
ValueStore.search_count([]),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
Book.valuestore_update_records([book])
|
||||||
|
|
||||||
|
values = ValueStore.search(
|
||||||
|
[('field_name', 'in', [
|
||||||
|
'balance', 'balance_all', 'balance_ref'])],
|
||||||
|
order=[('field_name', 'ASC')])
|
||||||
|
self.assertEqual(len(values), 3)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[0].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[1].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance_all|15.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[2].rec_name,
|
||||||
|
'[Book 1 | 15.00 usd | Open]|balance_ref|14.29|2')
|
||||||
|
|
||||||
|
# delete book, should delete values
|
||||||
|
Book.write(*[
|
||||||
|
[book],
|
||||||
|
{'lines': [('delete', [x.id for x in book.lines])]}
|
||||||
|
])
|
||||||
|
self.assertEqual(
|
||||||
|
ValueStore.search_count([]),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
Book.delete([book])
|
||||||
|
self.assertEqual(ValueStore.search_count([]), 0)
|
||||||
|
|
||||||
|
@with_transaction()
|
||||||
|
def test_valstore_update_store_values_line(self):
|
||||||
|
""" create cashbooks hierarchical, add lines
|
||||||
|
check update of parent cashbooks
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Book = pool.get('cashbook.book')
|
||||||
|
Line = pool.get('cashbook.line')
|
||||||
|
ValueStore = pool.get('cashbook.values')
|
||||||
|
|
||||||
|
types = self.prep_type()
|
||||||
|
company = self.prep_company()
|
||||||
|
(usd, euro) = self.prep_2nd_currency(company)
|
||||||
|
self.assertEqual(company.currency.rec_name, 'Euro')
|
||||||
|
|
||||||
|
with Transaction().set_context({'company': company.id}):
|
||||||
|
category = self.prep_category(cattype='in')
|
||||||
|
party = self.prep_party()
|
||||||
|
book, = Book.create([{
|
||||||
|
'name': 'Lev 0',
|
||||||
|
'btype': types.id,
|
||||||
|
'company': company.id,
|
||||||
|
'currency': usd.id,
|
||||||
|
'number_sequ': self.prep_sequence().id,
|
||||||
|
'start_date': date(2022, 5, 1),
|
||||||
|
'lines': [('create', [{
|
||||||
|
'date': date(2022, 5, 1),
|
||||||
|
'description': '10 US$',
|
||||||
|
'category': category.id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('10.0'),
|
||||||
|
'party': party.id,
|
||||||
|
}])],
|
||||||
|
'childs': [('create', [{
|
||||||
|
'name': 'Lev 1a',
|
||||||
|
'btype': types.id,
|
||||||
|
'company': company.id,
|
||||||
|
'currency': euro.id,
|
||||||
|
'number_sequ': self.prep_sequence().id,
|
||||||
|
'start_date': date(2022, 5, 1),
|
||||||
|
}, {
|
||||||
|
'name': 'Lev 1b',
|
||||||
|
'btype': types.id,
|
||||||
|
'company': company.id,
|
||||||
|
'currency': euro.id,
|
||||||
|
'number_sequ': self.prep_sequence().id,
|
||||||
|
'start_date': date(2022, 5, 1),
|
||||||
|
}])],
|
||||||
|
}])
|
||||||
|
self.assertEqual(book.rec_name, 'Lev 0 | 10.00 usd | Open')
|
||||||
|
self.assertEqual(len(book.lines), 1)
|
||||||
|
self.assertEqual(
|
||||||
|
book.lines[0].rec_name,
|
||||||
|
'05/01/2022|Rev|10.00 usd|10 US$ [Cat1]')
|
||||||
|
self.assertEqual(len(book.childs), 2)
|
||||||
|
self.assertEqual(
|
||||||
|
book.childs[0].rec_name, 'Lev 0/Lev 1a | 0.00 € | Open')
|
||||||
|
self.assertEqual(len(book.childs[0].lines), 0)
|
||||||
|
self.assertEqual(
|
||||||
|
book.childs[1].rec_name, 'Lev 0/Lev 1b | 0.00 € | Open')
|
||||||
|
self.assertEqual(len(book.childs[1].lines), 0)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
ValueStore.search_count([]),
|
||||||
|
3 * len(Book.valuestore_fields()))
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
|
||||||
|
values = ValueStore.search(
|
||||||
|
[('field_name', 'in', [
|
||||||
|
'balance', 'balance_all', 'balance_ref'])],
|
||||||
|
order=[('cashbook', 'ASC'), ('field_name', 'ASC')])
|
||||||
|
self.assertEqual(len(values), 3 * 3)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[0].rec_name,
|
||||||
|
'[Lev 0 | 10.00 usd | Open]|balance|10.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[1].rec_name,
|
||||||
|
'[Lev 0 | 10.00 usd | Open]|balance_all|10.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[2].rec_name,
|
||||||
|
'[Lev 0 | 10.00 usd | Open]|balance_ref|9.52|2')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[3].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 0.00 € | Open]|balance|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[4].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 0.00 € | Open]|balance_all|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[5].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 0.00 € | Open]|balance_ref|0.00|2')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[6].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[7].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance_all|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[8].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance_ref|0.00|2')
|
||||||
|
|
||||||
|
# add bookings
|
||||||
|
Line.create(self.prep_valstore_line_create_data(
|
||||||
|
[{
|
||||||
|
'cashbook': values[0].cashbook.id, # Lev 0
|
||||||
|
'amount': Decimal('2.0'),
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'category': category.id,
|
||||||
|
'date': date(2022, 5, 10),
|
||||||
|
}, {
|
||||||
|
'cashbook': values[3].cashbook.id, # Lev 1a
|
||||||
|
'amount': Decimal('3.0'),
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'category': category.id,
|
||||||
|
'date': date(2022, 5, 10),
|
||||||
|
}]))
|
||||||
|
|
||||||
|
# add 'date' to context, will return computed
|
||||||
|
# (not stored) values
|
||||||
|
with Transaction().set_context({'date': date(2022, 5, 10)}):
|
||||||
|
values = ValueStore.search(
|
||||||
|
[('field_name', 'in', [
|
||||||
|
'balance', 'balance_all', 'balance_ref'])],
|
||||||
|
order=[('cashbook', 'ASC'), ('field_name', 'ASC')])
|
||||||
|
self.assertEqual(len(values), 9)
|
||||||
|
self.assertEqual(
|
||||||
|
values[0].rec_name,
|
||||||
|
'[Lev 0 | 15.15 usd | Open]|balance|10.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[1].rec_name,
|
||||||
|
'[Lev 0 | 15.15 usd | Open]|balance_all|10.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[2].rec_name,
|
||||||
|
'[Lev 0 | 15.15 usd | Open]|balance_ref|9.52|2')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[3].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 3.00 € | Open]|balance|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[4].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 3.00 € | Open]|balance_all|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[5].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 3.00 € | Open]|balance_ref|0.00|2')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[6].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[7].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance_all|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[8].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance_ref|0.00|2')
|
||||||
|
|
||||||
|
# before run of workers - w/o 'date' in context
|
||||||
|
values = ValueStore.search(
|
||||||
|
[('field_name', 'in', [
|
||||||
|
'balance', 'balance_all', 'balance_ref'])],
|
||||||
|
order=[('cashbook', 'ASC'), ('field_name', 'ASC')])
|
||||||
|
self.assertEqual(len(values), 9)
|
||||||
|
self.assertEqual(
|
||||||
|
values[0].rec_name,
|
||||||
|
'[Lev 0 | 10.00 usd | Open]|balance|10.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[1].rec_name,
|
||||||
|
'[Lev 0 | 10.00 usd | Open]|balance_all|10.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[2].rec_name,
|
||||||
|
'[Lev 0 | 10.00 usd | Open]|balance_ref|9.52|2')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[3].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 0.00 € | Open]|balance|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[4].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 0.00 € | Open]|balance_all|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[5].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 0.00 € | Open]|balance_ref|0.00|2')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[6].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[7].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance_all|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[8].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance_ref|0.00|2')
|
||||||
|
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
|
||||||
|
# after run of workers
|
||||||
|
values = ValueStore.search(
|
||||||
|
[('field_name', 'in', [
|
||||||
|
'balance', 'balance_all', 'balance_ref'])],
|
||||||
|
order=[('cashbook', 'ASC'), ('field_name', 'ASC')])
|
||||||
|
self.assertEqual(len(values), 9)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[0].rec_name,
|
||||||
|
'[Lev 0 | 15.15 usd | Open]|balance|15.15|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[1].rec_name,
|
||||||
|
'[Lev 0 | 15.15 usd | Open]|balance_all|15.15|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[2].rec_name,
|
||||||
|
'[Lev 0 | 15.15 usd | Open]|balance_ref|14.43|2')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[3].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 3.00 € | Open]|balance|3.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[4].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 3.00 € | Open]|balance_all|3.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[5].rec_name,
|
||||||
|
'[Lev 0/Lev 1a | 3.00 € | Open]|balance_ref|3.00|2')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
values[6].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[7].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance_all|0.00|2')
|
||||||
|
self.assertEqual(
|
||||||
|
values[8].rec_name,
|
||||||
|
'[Lev 0/Lev 1b | 0.00 € | Open]|balance_ref|0.00|2')
|
||||||
|
|
||||||
|
def prep_valstore_line_create_data(self, query):
|
||||||
|
""" allow add of data
|
||||||
|
"""
|
||||||
|
return query
|
||||||
|
|
||||||
|
@with_transaction()
|
||||||
|
def test_valstore_search_sort_books(self):
|
||||||
|
""" create cashbooks add lines, search/sort
|
||||||
|
with and w/o 'date' in context
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Book = pool.get('cashbook.book')
|
||||||
|
Line = pool.get('cashbook.line')
|
||||||
|
|
||||||
|
types = self.prep_type()
|
||||||
|
company = self.prep_company()
|
||||||
|
(usd, euro) = self.prep_2nd_currency(company)
|
||||||
|
self.assertEqual(company.currency.rec_name, 'Euro')
|
||||||
|
|
||||||
|
with Transaction().set_context({'company': company.id}):
|
||||||
|
category = self.prep_category(cattype='in')
|
||||||
|
party = self.prep_party()
|
||||||
|
books = Book.create([{
|
||||||
|
'name': 'Cashbook 1',
|
||||||
|
'btype': types.id,
|
||||||
|
'company': company.id,
|
||||||
|
'currency': usd.id,
|
||||||
|
'number_sequ': self.prep_sequence().id,
|
||||||
|
'start_date': date(2022, 5, 1),
|
||||||
|
'lines': [('create', [{
|
||||||
|
'date': date(2022, 5, 1),
|
||||||
|
'description': '10 US$',
|
||||||
|
'category': category.id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('10.0'),
|
||||||
|
'party': party.id,
|
||||||
|
}])]}, {
|
||||||
|
'name': 'Cashbook 2',
|
||||||
|
'btype': types.id,
|
||||||
|
'company': company.id,
|
||||||
|
'currency': euro.id,
|
||||||
|
'number_sequ': self.prep_sequence().id,
|
||||||
|
'start_date': date(2022, 5, 1),
|
||||||
|
}, {
|
||||||
|
'name': 'Cashbook 3',
|
||||||
|
'btype': types.id,
|
||||||
|
'company': company.id,
|
||||||
|
'currency': euro.id,
|
||||||
|
'number_sequ': self.prep_sequence().id,
|
||||||
|
'start_date': date(2022, 5, 1),
|
||||||
|
}])
|
||||||
|
self.assertEqual(len(books), 3)
|
||||||
|
self.assertEqual(books[0].rec_name, 'Cashbook 1 | 10.00 usd | Open')
|
||||||
|
self.assertEqual(books[1].rec_name, 'Cashbook 2 | 0.00 € | Open')
|
||||||
|
self.assertEqual(books[2].rec_name, 'Cashbook 3 | 0.00 € | Open')
|
||||||
|
|
||||||
|
Line.create(self.prep_valstore_line_create_data(
|
||||||
|
[{
|
||||||
|
'cashbook': books[1].id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('5.0'),
|
||||||
|
'date': date(2022, 5, 6),
|
||||||
|
'description': '5€ in',
|
||||||
|
'category': category.id,
|
||||||
|
}, {
|
||||||
|
'cashbook': books[2].id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('6.0'),
|
||||||
|
'date': date(2022, 5, 7),
|
||||||
|
'description': '6€ in',
|
||||||
|
'category': category.id,
|
||||||
|
}]))
|
||||||
|
|
||||||
|
# no 'date' in context, using stored values
|
||||||
|
# workers not yet processed
|
||||||
|
books = Book.search([], order=[('name', 'ASC')])
|
||||||
|
self.assertEqual(len(books), 3)
|
||||||
|
self.assertEqual(books[0].rec_name, 'Cashbook 1 | 10.00 usd | Open')
|
||||||
|
self.assertEqual(books[1].rec_name, 'Cashbook 2 | 0.00 € | Open')
|
||||||
|
self.assertEqual(books[2].rec_name, 'Cashbook 3 | 0.00 € | Open')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([('balance', '=', Decimal('0.0'))]),
|
||||||
|
2)
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([('balance_all', '=', Decimal('0.0'))]),
|
||||||
|
2)
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([('balance_ref', '=', Decimal('0.0'))]),
|
||||||
|
2)
|
||||||
|
|
||||||
|
# check sorting - using stored values
|
||||||
|
books = Book.search([], order=[
|
||||||
|
('balance_all', 'DESC'), ('name', 'ASC')])
|
||||||
|
self.assertEqual(len(books), 3)
|
||||||
|
self.assertEqual(books[0].rec_name, 'Cashbook 1 | 10.00 usd | Open')
|
||||||
|
self.assertEqual(books[1].rec_name, 'Cashbook 2 | 0.00 € | Open')
|
||||||
|
self.assertEqual(books[2].rec_name, 'Cashbook 3 | 0.00 € | Open')
|
||||||
|
|
||||||
|
# search again with 'date' - using computed values
|
||||||
|
with Transaction().set_context({'date': date(2022, 5, 6)}):
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([('balance', '=', Decimal('5.0'))]),
|
||||||
|
1)
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([
|
||||||
|
('balance', '>=', Decimal('5.0')),
|
||||||
|
('balance', '<', Decimal('9.0')),
|
||||||
|
]),
|
||||||
|
1)
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([
|
||||||
|
('balance_all', '>=', Decimal('5.0'))]),
|
||||||
|
3)
|
||||||
|
self.assertRaisesRegex(
|
||||||
|
UserError,
|
||||||
|
"Search with 'date' no allowed for field " +
|
||||||
|
"'balance_ref' on model 'cashbook.book'.",
|
||||||
|
Book.search_count,
|
||||||
|
[('balance_ref', '=', Decimal('0.0'))])
|
||||||
|
|
||||||
|
self.assertRaisesRegex(
|
||||||
|
UserError,
|
||||||
|
"Search with 'date' no allowed for field " +
|
||||||
|
"'balance_ref' on model 'cashbook.book'.",
|
||||||
|
Book.search,
|
||||||
|
[], order=[('balance_ref', 'ASC')])
|
||||||
|
|
||||||
|
# check sorting - using computed values
|
||||||
|
books = Book.search([], order=[
|
||||||
|
('balance_all', 'DESC'),
|
||||||
|
('name', 'ASC'),
|
||||||
|
('balance', 'ASC')])
|
||||||
|
self.assertEqual(len(books), 3)
|
||||||
|
self.assertEqual(
|
||||||
|
books[0].rec_name, 'Cashbook 1 | 10.00 usd | Open')
|
||||||
|
self.assertEqual(
|
||||||
|
books[1].rec_name, 'Cashbook 3 | 0.00 € | Open')
|
||||||
|
self.assertEqual(books[1].balance_all, Decimal('6.0'))
|
||||||
|
self.assertEqual(
|
||||||
|
books[2].rec_name, 'Cashbook 2 | 5.00 € | Open')
|
||||||
|
|
||||||
|
with Transaction().set_context({'date': date(2022, 5, 7)}):
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([('balance', '=', Decimal('5.0'))]),
|
||||||
|
1)
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([
|
||||||
|
('balance', '>=', Decimal('5.0')),
|
||||||
|
('balance', '<', Decimal('9.0')),
|
||||||
|
]),
|
||||||
|
2)
|
||||||
|
|
||||||
|
# run workers
|
||||||
|
self.prep_valstore_run_worker()
|
||||||
|
|
||||||
|
# check stored values - no 'date' in context
|
||||||
|
books = Book.search([], order=[('name', 'ASC')])
|
||||||
|
self.assertEqual(len(books), 3)
|
||||||
|
self.assertEqual(books[0].rec_name, 'Cashbook 1 | 10.00 usd | Open')
|
||||||
|
self.assertEqual(books[1].rec_name, 'Cashbook 2 | 5.00 € | Open')
|
||||||
|
self.assertEqual(books[2].rec_name, 'Cashbook 3 | 6.00 € | Open')
|
||||||
|
|
||||||
|
# check sorting - using stored values
|
||||||
|
# run most sorters
|
||||||
|
books = Book.search([], order=[
|
||||||
|
('balance_all', 'DESC'),
|
||||||
|
('name', 'ASC'),
|
||||||
|
('balance', 'ASC'),
|
||||||
|
('balance_ref', 'ASC')])
|
||||||
|
self.assertEqual(len(books), 3)
|
||||||
|
self.assertEqual(books[0].rec_name, 'Cashbook 1 | 10.00 usd | Open')
|
||||||
|
self.assertEqual(books[1].rec_name, 'Cashbook 3 | 6.00 € | Open')
|
||||||
|
self.assertEqual(books[2].rec_name, 'Cashbook 2 | 5.00 € | Open')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([('balance', '=', Decimal('0.0'))]),
|
||||||
|
0)
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([('balance', '=', Decimal('5.0'))]),
|
||||||
|
1)
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([('balance', '=', Decimal('6.0'))]),
|
||||||
|
1)
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([
|
||||||
|
('balance', '>=', Decimal('5.0')),
|
||||||
|
('balance', '<', Decimal('9.0')),
|
||||||
|
]),
|
||||||
|
2)
|
||||||
|
self.assertEqual(
|
||||||
|
Book.search_count([('balance_ref', '=', Decimal('6.0'))]),
|
||||||
|
1)
|
||||||
|
|
||||||
|
@with_transaction()
|
||||||
|
def test_valstore_maintain_values(self):
|
||||||
|
""" create cashbook, check maintenance -
|
||||||
|
update records by cron, delete lost records
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Book = pool.get('cashbook.book')
|
||||||
|
ValueStore = pool.get('cashbook.values')
|
||||||
|
tab_book = Book.__table__()
|
||||||
|
cursor = Transaction().connection.cursor()
|
||||||
|
|
||||||
|
types = self.prep_type()
|
||||||
|
company = self.prep_company()
|
||||||
|
(usd, euro) = self.prep_2nd_currency(company)
|
||||||
|
self.assertEqual(company.currency.rec_name, 'Euro')
|
||||||
|
|
||||||
|
category = self.prep_category(cattype='in')
|
||||||
|
party = self.prep_party()
|
||||||
|
book, = Book.create([{
|
||||||
|
'name': 'Book 1',
|
||||||
|
'btype': types.id,
|
||||||
|
'company': company.id,
|
||||||
|
'currency': usd.id,
|
||||||
|
'number_sequ': self.prep_sequence().id,
|
||||||
|
'start_date': date(2022, 5, 1),
|
||||||
|
'lines': [('create', [{
|
||||||
|
'date': date(2022, 5, 1),
|
||||||
|
'description': '10 US$',
|
||||||
|
'category': category.id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('10.0'),
|
||||||
|
'party': party.id,
|
||||||
|
}, {
|
||||||
|
'date': date(2022, 5, 10),
|
||||||
|
'description': '5 US$',
|
||||||
|
'category': category.id,
|
||||||
|
'bookingtype': 'in',
|
||||||
|
'amount': Decimal('5.0'),
|
||||||
|
'party': party.id,
|
||||||
|
}])],
|
||||||
|
}])
|
||||||
|
|
||||||
|
# clean 'numvalue'
|
||||||
|
# maintenance_values() will restore it
|
||||||
|
val1, = ValueStore.search([('field_name', '=', 'balance')])
|
||||||
|
ValueStore.write(*[[val1], {'numvalue': None}])
|
||||||
|
|
||||||
|
self.assertTrue(val1.write_date is not None)
|
||||||
|
self.assertTrue(val1.create_date is not None)
|
||||||
|
self.assertEqual(val1.numvalue, None)
|
||||||
|
|
||||||
|
# update outdated records
|
||||||
|
with Transaction().set_context({
|
||||||
|
'maintenance_date': val1.write_date.date() +
|
||||||
|
timedelta(days=2)}):
|
||||||
|
ValueStore.maintenance_values()
|
||||||
|
|
||||||
|
val1, = ValueStore.search([('field_name', '=', 'balance')])
|
||||||
|
self.assertEqual(val1.numvalue, Decimal('15.0'))
|
||||||
|
|
||||||
|
# delete book
|
||||||
|
self.assertEqual(Book.search_count([]), 1)
|
||||||
|
self.assertEqual(
|
||||||
|
ValueStore.search_count([]),
|
||||||
|
len(Book.valuestore_fields()))
|
||||||
|
query = tab_book.delete(where=tab_book.id == book.id)
|
||||||
|
cursor.execute(*query)
|
||||||
|
self.assertEqual(Book.search_count([]), 0)
|
||||||
|
self.assertEqual(ValueStore.search_count([]), 0)
|
||||||
|
|
||||||
|
# end ValuestoreTestCase
|
|
@ -1,10 +1,11 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=6.0.0
|
version=7.0.0
|
||||||
depends:
|
depends:
|
||||||
res
|
res
|
||||||
currency
|
currency
|
||||||
party
|
party
|
||||||
company
|
company
|
||||||
|
irrulecontext
|
||||||
xml:
|
xml:
|
||||||
icon.xml
|
icon.xml
|
||||||
group.xml
|
group.xml
|
||||||
|
@ -21,3 +22,4 @@ xml:
|
||||||
wizard_runreport.xml
|
wizard_runreport.xml
|
||||||
wizard_booking.xml
|
wizard_booking.xml
|
||||||
menu.xml
|
menu.xml
|
||||||
|
cron.xml
|
||||||
|
|
17
types.py
17
types.py
|
@ -3,7 +3,7 @@
|
||||||
# The COPYRIGHT file at the top level of this repository contains the
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
# full copyright notices and license terms.
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.model import ModelView, ModelSQL, fields, Unique
|
from trytond.model import ModelView, ModelSQL, fields, Unique, Index
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.i18n import gettext
|
from trytond.i18n import gettext
|
||||||
|
|
||||||
|
@ -28,8 +28,15 @@ class Type(ModelSQL, ModelView):
|
||||||
cls._order.insert(0, ('name', 'ASC'))
|
cls._order.insert(0, ('name', 'ASC'))
|
||||||
t = cls.__table__()
|
t = cls.__table__()
|
||||||
cls._sql_constraints.extend([
|
cls._sql_constraints.extend([
|
||||||
('code_uniq', Unique(t, t.short), 'cashbook.msg_type_short_unique'),
|
('code_uniq',
|
||||||
|
Unique(t, t.short),
|
||||||
|
'cashbook.msg_type_short_unique'),
|
||||||
])
|
])
|
||||||
|
cls._sql_indexes.update({
|
||||||
|
Index(
|
||||||
|
t,
|
||||||
|
(t.feature, Index.Equality())),
|
||||||
|
})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_feature(cls):
|
def default_feature(cls):
|
||||||
|
@ -48,8 +55,7 @@ class Type(ModelSQL, ModelView):
|
||||||
"""
|
"""
|
||||||
return '%(short)s - %(name)s' % {
|
return '%(short)s - %(name)s' % {
|
||||||
'short': self.short or '-',
|
'short': self.short or '-',
|
||||||
'name': self.name or '-',
|
'name': self.name or '-'}
|
||||||
}
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def search_rec_name(cls, name, clause):
|
def search_rec_name(cls, name, clause):
|
||||||
|
@ -58,8 +64,7 @@ class Type(ModelSQL, ModelView):
|
||||||
return [
|
return [
|
||||||
'OR',
|
'OR',
|
||||||
('name',) + tuple(clause[1:]),
|
('name',) + tuple(clause[1:]),
|
||||||
('short',) + tuple(clause[1:]),
|
('short',) + tuple(clause[1:])]
|
||||||
]
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_company():
|
def default_company():
|
||||||
|
|
217
valuestore.py
Normal file
217
valuestore.py
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# This file is part of the cashbook-module from m-ds for Tryton.
|
||||||
|
# The COPYRIGHT file at the top level of this repository contains the
|
||||||
|
# full copyright notices and license terms.
|
||||||
|
|
||||||
|
|
||||||
|
from sql.functions import CurrentTimestamp, DateTrunc
|
||||||
|
from sql.aggregate import Count
|
||||||
|
from sql.conditionals import Coalesce
|
||||||
|
from trytond.model import ModelSQL, fields, Unique, Index
|
||||||
|
from trytond.pool import Pool
|
||||||
|
from trytond.transaction import Transaction
|
||||||
|
from trytond.pyson import Eval, PYSON, PYSONEncoder, PYSONDecoder
|
||||||
|
from trytond.model.modelstorage import EvalEnvironment
|
||||||
|
from trytond.report import Report
|
||||||
|
|
||||||
|
|
||||||
|
class ValueStore(ModelSQL):
|
||||||
|
'Value Store'
|
||||||
|
__name__ = 'cashbook.values'
|
||||||
|
|
||||||
|
cashbook = fields.Many2One(
|
||||||
|
string='Cashbook', required=True, model_name='cashbook.book',
|
||||||
|
ondelete='CASCADE')
|
||||||
|
field_name = fields.Char(string='Field Name', required=True)
|
||||||
|
numvalue = fields.Numeric(
|
||||||
|
string='Value', digits=(16, Eval('valuedigits', 6)),
|
||||||
|
depends=['valuedigits'])
|
||||||
|
valuedigits = fields.Function(fields.Integer(
|
||||||
|
string='Digits', readonly=True),
|
||||||
|
'on_change_with_valuedigits')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def __register__(cls, module_name):
|
||||||
|
super(ValueStore, cls).__register__(module_name)
|
||||||
|
|
||||||
|
# clear value-store, re-calc
|
||||||
|
records = cls.search([])
|
||||||
|
if records:
|
||||||
|
cls.delete(records)
|
||||||
|
cls.maintenance_values()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def __setup__(cls):
|
||||||
|
super(ValueStore, cls).__setup__()
|
||||||
|
t = cls.__table__()
|
||||||
|
cls._sql_constraints.extend([
|
||||||
|
('uniqu_field',
|
||||||
|
Unique(t, t.cashbook, t.field_name),
|
||||||
|
'cashbook.msg_value_exists_in_store'),
|
||||||
|
])
|
||||||
|
cls._sql_indexes.update({
|
||||||
|
Index(
|
||||||
|
t,
|
||||||
|
(t.field_name, Index.Equality())),
|
||||||
|
})
|
||||||
|
|
||||||
|
def get_rec_name(self, name):
|
||||||
|
""" name, balance, state
|
||||||
|
"""
|
||||||
|
return '|'.join([
|
||||||
|
'[' + getattr(self.cashbook, 'rec_name', '-') + ']',
|
||||||
|
self.field_name or '-',
|
||||||
|
Report.format_number(
|
||||||
|
self.numvalue,
|
||||||
|
None,
|
||||||
|
digits=self.valuedigits or 2)
|
||||||
|
if self.numvalue is not None else '-',
|
||||||
|
str(self.valuedigits) if self.valuedigits is not None else '-'])
|
||||||
|
|
||||||
|
@fields.depends('cashbook', 'field_name')
|
||||||
|
def on_change_with_valuedigits(self, name=None):
|
||||||
|
""" get digits by field name
|
||||||
|
"""
|
||||||
|
Cashbook = Pool().get('cashbook.book')
|
||||||
|
|
||||||
|
if self.cashbook and self.field_name:
|
||||||
|
fieldobj = Cashbook._fields.get(self.field_name, None)
|
||||||
|
if fieldobj:
|
||||||
|
digit = getattr(fieldobj, 'digits', (16, 6))[1]
|
||||||
|
if isinstance(digit, PYSON):
|
||||||
|
# execute pyson on linked record
|
||||||
|
digit = PYSONDecoder(
|
||||||
|
EvalEnvironment(self.cashbook, Cashbook)
|
||||||
|
).decode(PYSONEncoder().encode(digit))
|
||||||
|
return digit
|
||||||
|
return 6
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _maintenance_fields(cls):
|
||||||
|
""" list of model and fieldnames,
|
||||||
|
to daily update
|
||||||
|
"""
|
||||||
|
return ['balance']
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def maintenance_values(cls):
|
||||||
|
""" update values by cron
|
||||||
|
"""
|
||||||
|
pool = Pool()
|
||||||
|
Cashbook = pool.get('cashbook.book')
|
||||||
|
tab_val = cls.__table__()
|
||||||
|
tab_book = Cashbook.__table__()
|
||||||
|
cursor = Transaction().connection.cursor()
|
||||||
|
context = Transaction().context
|
||||||
|
|
||||||
|
# select records older than 'check_dt'
|
||||||
|
check_dt = context.get('maintenance_date', None)
|
||||||
|
if not check_dt:
|
||||||
|
check_dt = DateTrunc('day', CurrentTimestamp())
|
||||||
|
|
||||||
|
# select records to update
|
||||||
|
query = tab_val.select(
|
||||||
|
tab_val.id,
|
||||||
|
where=tab_val.field_name.in_(cls._maintenance_fields()) &
|
||||||
|
(DateTrunc('day', Coalesce(
|
||||||
|
tab_val.write_date,
|
||||||
|
tab_val.create_date,
|
||||||
|
'1990-01-01 00:00:00')) < check_dt))
|
||||||
|
cursor.execute(*query)
|
||||||
|
records = []
|
||||||
|
for x in cursor.fetchall():
|
||||||
|
cb = cls(x[0]).cashbook
|
||||||
|
if cb not in records:
|
||||||
|
records.append(cb)
|
||||||
|
|
||||||
|
# add records with missing fields in value-store
|
||||||
|
num_fields = len(Cashbook.valuestore_fields())
|
||||||
|
query = tab_book.join(
|
||||||
|
tab_val,
|
||||||
|
condition=tab_book.id == tab_val.cashbook,
|
||||||
|
type_='LEFT OUTER',
|
||||||
|
).select(
|
||||||
|
tab_book.id,
|
||||||
|
Count(tab_val.id).as_('num'),
|
||||||
|
group_by=[tab_book.id],
|
||||||
|
having=Count(tab_val.id) < num_fields)
|
||||||
|
cursor.execute(*query)
|
||||||
|
records.extend([Cashbook(x[0]) for x in cursor.fetchall()])
|
||||||
|
|
||||||
|
if records:
|
||||||
|
Cashbook.valuestore_update_records([x for x in records])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_book_by_line(cls, records):
|
||||||
|
""" select books above current record to update
|
||||||
|
records: cashbook.line
|
||||||
|
"""
|
||||||
|
Book = Pool().get('cashbook.book')
|
||||||
|
|
||||||
|
to_update = []
|
||||||
|
if records:
|
||||||
|
books = Book.search([
|
||||||
|
('parent', 'parent_of', [x.cashbook.id for x in records])
|
||||||
|
])
|
||||||
|
to_update.extend([
|
||||||
|
x for x in books
|
||||||
|
if x not in to_update])
|
||||||
|
return to_update
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_book_by_books(cls, records):
|
||||||
|
""" select books above current record to update
|
||||||
|
records: cashbook.book
|
||||||
|
"""
|
||||||
|
Book = Pool().get('cashbook.book')
|
||||||
|
|
||||||
|
to_update = []
|
||||||
|
if records:
|
||||||
|
books = Book.search([
|
||||||
|
('parent', 'parent_of', [x.id for x in records])
|
||||||
|
])
|
||||||
|
to_update.extend([
|
||||||
|
x for x in books
|
||||||
|
if x not in to_update])
|
||||||
|
return to_update
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def update_books(cls, books):
|
||||||
|
""" get cashbooks to update, queue it
|
||||||
|
"""
|
||||||
|
Book = Pool().get('cashbook.book')
|
||||||
|
|
||||||
|
if books:
|
||||||
|
Book.__queue__.valuestore_update_records(books)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def update_values(cls, data):
|
||||||
|
""" data: {'fieldname': {id1: value, id2: value, ...}, ...}
|
||||||
|
"""
|
||||||
|
to_write = []
|
||||||
|
to_create = []
|
||||||
|
|
||||||
|
for name in data.keys():
|
||||||
|
for record_id in data[name].keys():
|
||||||
|
# get existing record
|
||||||
|
records = cls.search([
|
||||||
|
('cashbook', '=', record_id),
|
||||||
|
('field_name', '=', name)])
|
||||||
|
|
||||||
|
if records:
|
||||||
|
for record in records:
|
||||||
|
to_write.extend([
|
||||||
|
[record],
|
||||||
|
{'numvalue': data[name][record_id]}])
|
||||||
|
else:
|
||||||
|
to_create.append({
|
||||||
|
'cashbook': record_id,
|
||||||
|
'field_name': name,
|
||||||
|
'numvalue': data[name][record_id]})
|
||||||
|
|
||||||
|
if to_create:
|
||||||
|
cls.create(to_create)
|
||||||
|
if to_write:
|
||||||
|
cls.write(*to_write)
|
||||||
|
|
||||||
|
# end ValueStore
|
|
@ -1 +1 @@
|
||||||
|
irrulecontext;7.0.1;7.0.999;mds
|
||||||
|
|
|
@ -4,6 +4,8 @@ The COPYRIGHT file at the top level of this repository contains the
|
||||||
full copyright notices and license terms. -->
|
full copyright notices and license terms. -->
|
||||||
<tree keyword_open="1">
|
<tree keyword_open="1">
|
||||||
<field name="rec_name" expand="1"/>
|
<field name="rec_name" expand="1"/>
|
||||||
<field name="balance" sum="Balance" symbol="currency"/>
|
<field name="balance" sum="1" symbol="currency"/>
|
||||||
<field name="state"/>
|
<field name="balance_all" symbol="currency" optional="1"/>
|
||||||
|
<field name="balance_ref" symbol="company_currency" optional="1"/>
|
||||||
|
<field name="state" optional="0"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
|
@ -5,7 +5,9 @@ full copyright notices and license terms. -->
|
||||||
<tree keyword_open="1" tree_state="1">
|
<tree keyword_open="1" tree_state="1">
|
||||||
<field name="name" expand="1"/>
|
<field name="name" expand="1"/>
|
||||||
<field name="balance" symbol="currency"/>
|
<field name="balance" symbol="currency"/>
|
||||||
<field name="state"/>
|
<field name="balance_all" symbol="currency" optional="1"/>
|
||||||
|
<field name="balance_ref" symbol="company_currency" optional="1"/>
|
||||||
|
<field name="state" optional="0"/>
|
||||||
<field name="parent" tree_invisible="1"/>
|
<field name="parent" tree_invisible="1"/>
|
||||||
<field name="childs" tree_invisible="1"/>
|
<field name="childs" tree_invisible="1"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
|
@ -28,6 +28,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<label name="book5"/>
|
<label name="book5"/>
|
||||||
<field name="book5"/>
|
<field name="book5"/>
|
||||||
|
|
||||||
|
<label name="fixate"/>
|
||||||
|
<field name="fixate"/>
|
||||||
|
<newline/>
|
||||||
|
|
||||||
<separator id="sepcb" colspan="4" string="Cashbook"/>
|
<separator id="sepcb" colspan="4" string="Cashbook"/>
|
||||||
<label name="catnamelong"/>
|
<label name="catnamelong"/>
|
||||||
<field name="catnamelong"/>
|
<field name="catnamelong"/>
|
||||||
|
|
|
@ -22,6 +22,10 @@ full copyright notices and license terms. -->
|
||||||
<page id="descr" string="Description" col="1">
|
<page id="descr" string="Description" col="1">
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
</page>
|
</page>
|
||||||
|
<page name="fixate" col="2">
|
||||||
|
<label name="fixate"/>
|
||||||
|
<field name="fixate"/>
|
||||||
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
|
|
||||||
<field name="cashbooks"/>
|
<field name="cashbooks"/>
|
||||||
|
@ -29,4 +33,3 @@ full copyright notices and license terms. -->
|
||||||
<field name="currency"/>
|
<field name="currency"/>
|
||||||
<field name="owner_cashbook"/>
|
<field name="owner_cashbook"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,14 @@ The COPYRIGHT file at the top level of this repository contains the
|
||||||
full copyright notices and license terms. -->
|
full copyright notices and license terms. -->
|
||||||
<tree>
|
<tree>
|
||||||
<field name="cashbook" tree_invisible="1"/>
|
<field name="cashbook" tree_invisible="1"/>
|
||||||
<field name="number"/>
|
<field name="number" optional="0"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="payee"/>
|
<field name="payee"/>
|
||||||
<field name="category_view"/>
|
<field name="category_view"/>
|
||||||
<field name="descr_short" expand="1"/>
|
<field name="descr_short" expand="1"/>
|
||||||
<field name="credit" sum="Credit"/>
|
<field name="credit" sum="1" optional="0"/>
|
||||||
<field name="debit" sum="Debit"/>
|
<field name="debit" sum="1" optional="0"/>
|
||||||
<field name="balance"/>
|
<field name="balance" optional="0"/>
|
||||||
<field name="state"/>
|
<field name="state" optional="0"/>
|
||||||
<button name="wfcheck"/>
|
<button name="wfcheck"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
|
@ -4,13 +4,13 @@ The COPYRIGHT file at the top level of this repository contains the
|
||||||
full copyright notices and license terms. -->
|
full copyright notices and license terms. -->
|
||||||
<tree>
|
<tree>
|
||||||
<field name="cashbook" tree_invisible="1"/>
|
<field name="cashbook" tree_invisible="1"/>
|
||||||
<field name="number"/>
|
<field name="number" optional="0"/>
|
||||||
<field name="date"/>
|
<field name="date" optional="0"/>
|
||||||
<field name="payee"/>
|
<field name="payee" optional="0"/>
|
||||||
<field name="category_view"/>
|
<field name="category_view" optional="0"/>
|
||||||
<field name="descr_short" expand="1"/>
|
<field name="descr_short" expand="1" optional="0"/>
|
||||||
<field name="credit" sum="Credit"/>
|
<field name="credit" sum="1" optional="0"/>
|
||||||
<field name="debit" sum="Debit"/>
|
<field name="debit" sum="1" optional="0"/>
|
||||||
<field name="state"/>
|
<field name="state" optional="0"/>
|
||||||
<button name="wfrecon"/>
|
<button name="wfrecon"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
|
@ -4,11 +4,11 @@ The COPYRIGHT file at the top level of this repository contains the
|
||||||
full copyright notices and license terms. -->
|
full copyright notices and license terms. -->
|
||||||
<tree>
|
<tree>
|
||||||
<field name="cashbook"/>
|
<field name="cashbook"/>
|
||||||
<field name="date"/>
|
<field name="date" optional="0"/>
|
||||||
<field name="date_from"/>
|
<field name="date_from" optional="0"/>
|
||||||
<field name="date_to"/>
|
<field name="date_to" optional="0"/>
|
||||||
<field name="start_amount"/>
|
<field name="start_amount" optional="0"/>
|
||||||
<field name="end_amount"/>
|
<field name="end_amount" optional="0"/>
|
||||||
<field name="lines"/>
|
<field name="lines" optional="0"/>
|
||||||
<field name="state"/>
|
<field name="state" optional="0"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
|
@ -8,7 +8,7 @@ full copyright notices and license terms. -->
|
||||||
<field name="splittype"/>
|
<field name="splittype"/>
|
||||||
<field name="category"/>
|
<field name="category"/>
|
||||||
<field name="booktransf"/>
|
<field name="booktransf"/>
|
||||||
<field name="description" expand="1"/>
|
<field name="description" expand="1" optional="0"/>
|
||||||
<field name="amount" sum="Amount" symbol="currency"/>
|
<field name="amount" sum="1" symbol="currency" optional="0"/>
|
||||||
<field name="amount_2nd_currency" symbol="currency2nd"/>
|
<field name="amount_2nd_currency" symbol="currency2nd" optional="0"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
|
@ -7,7 +7,7 @@ from trytond.model import ModelView, fields
|
||||||
from trytond.wizard import Wizard, StateView, StateTransition, Button
|
from trytond.wizard import Wizard, StateView, StateTransition, Button
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.pyson import Eval, Bool, If
|
from trytond.pyson import Eval, Bool, If, And
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from .line import sel_bookingtype
|
from .line import sel_bookingtype
|
||||||
|
|
||||||
|
@ -45,12 +45,14 @@ class EnterBookingStart(ModelView):
|
||||||
depends=['currency_digits', 'bookingtype'],
|
depends=['currency_digits', 'bookingtype'],
|
||||||
digits=(16, Eval('currency_digits', 2)), required=True,
|
digits=(16, Eval('currency_digits', 2)), required=True,
|
||||||
domain=[('amount', '>=', Decimal('0.0'))])
|
domain=[('amount', '>=', Decimal('0.0'))])
|
||||||
description = fields.Text(string='Description')
|
description = fields.Text(
|
||||||
|
string='Description', states={'required': Bool(Eval('fixate'))},
|
||||||
|
depends=['fixate'])
|
||||||
category = fields.Many2One(
|
category = fields.Many2One(
|
||||||
string='Category',
|
string='Category',
|
||||||
model_name='cashbook.category', depends=['bookingtype'],
|
model_name='cashbook.category', depends=['bookingtype'],
|
||||||
states={
|
states={
|
||||||
'readonly': Bool(Eval('bookingtype')) == False,
|
'readonly': ~Bool(Eval('bookingtype')),
|
||||||
'required': Eval('bookingtype', '').in_(['in', 'out']),
|
'required': Eval('bookingtype', '').in_(['in', 'out']),
|
||||||
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
|
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
|
||||||
},
|
},
|
||||||
|
@ -60,6 +62,8 @@ class EnterBookingStart(ModelView):
|
||||||
('cattype', '=', 'in'),
|
('cattype', '=', 'in'),
|
||||||
('cattype', '=', 'out'),
|
('cattype', '=', 'out'),
|
||||||
)])
|
)])
|
||||||
|
fixate = fields.Boolean(
|
||||||
|
string='Fixate', help='The booking is fixed immediately.')
|
||||||
|
|
||||||
# party or cashbook as counterpart
|
# party or cashbook as counterpart
|
||||||
booktransf = fields.Many2One(
|
booktransf = fields.Many2One(
|
||||||
|
@ -77,7 +81,10 @@ class EnterBookingStart(ModelView):
|
||||||
string='Party', model_name='party.party',
|
string='Party', model_name='party.party',
|
||||||
states={
|
states={
|
||||||
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
|
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
|
||||||
}, depends=['bookingtype'])
|
'required': And(
|
||||||
|
Bool(Eval('fixate')),
|
||||||
|
Eval('bookingtype', '').in_(['in', 'out']))},
|
||||||
|
depends=['bookingtype', 'fixate'])
|
||||||
|
|
||||||
@fields.depends('bookingtype', 'category')
|
@fields.depends('bookingtype', 'category')
|
||||||
def on_change_bookingtype(self):
|
def on_change_bookingtype(self):
|
||||||
|
@ -90,7 +97,8 @@ class EnterBookingStart(ModelView):
|
||||||
|
|
||||||
if self.bookingtype:
|
if self.bookingtype:
|
||||||
if self.category:
|
if self.category:
|
||||||
if self.bookingtype not in types.get(self.category.cattype, ''):
|
if self.bookingtype not in types.get(
|
||||||
|
self.category.cattype, ''):
|
||||||
self.category = None
|
self.category = None
|
||||||
|
|
||||||
@fields.depends('cashbook', '_parent_cashbook.owner')
|
@fields.depends('cashbook', '_parent_cashbook.owner')
|
||||||
|
@ -149,10 +157,12 @@ class EnterBookingWizard(Wizard):
|
||||||
book_ids.append(getattr(cfg1, x, None).id)
|
book_ids.append(getattr(cfg1, x, None).id)
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
|
'fixate': cfg1.fixate
|
||||||
|
if cfg1 and cfg1.fixate is not None else False,
|
||||||
'cashbooks': [x.id for x in Cashbook.search([
|
'cashbooks': [x.id for x in Cashbook.search([
|
||||||
('state', '=', 'open'),
|
('state', '=', 'open'),
|
||||||
('btype', '!=', None),
|
('btype', '!=', None),
|
||||||
('owner.id', '=', Transaction().user),
|
('owner', '=', Transaction().user),
|
||||||
('id', 'in', book_ids),
|
('id', 'in', book_ids),
|
||||||
])],
|
])],
|
||||||
'bookingtype': getattr(self.start, 'bookingtype', 'out'),
|
'bookingtype': getattr(self.start, 'bookingtype', 'out'),
|
||||||
|
@ -186,7 +196,9 @@ class EnterBookingWizard(Wizard):
|
||||||
elif self.start.bookingtype in ['mvin', 'mvout']:
|
elif self.start.bookingtype in ['mvin', 'mvout']:
|
||||||
query['booktransf'] = self.start.booktransf.id
|
query['booktransf'] = self.start.booktransf.id
|
||||||
|
|
||||||
Line.create([query])
|
lines = Line.create([query])
|
||||||
|
if self.start.fixate:
|
||||||
|
Line.wfcheck(lines)
|
||||||
return 'end'
|
return 'end'
|
||||||
|
|
||||||
def transition_savenext_(self):
|
def transition_savenext_(self):
|
||||||
|
|
|
@ -55,7 +55,7 @@ class RunCbReportStart(ModelView):
|
||||||
|
|
||||||
if self.cashbook:
|
if self.cashbook:
|
||||||
recons = Recon2.search([
|
recons = Recon2.search([
|
||||||
('cashbook.id', '=', self.cashbook.id),
|
('cashbook', '=', self.cashbook.id),
|
||||||
], order=[('date_from', 'DESC')])
|
], order=[('date_from', 'DESC')])
|
||||||
return [x.id for x in recons]
|
return [x.id for x in recons]
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class RunCbReport(Wizard):
|
||||||
result['cashbook'] = result['cashbooks'][0]
|
result['cashbook'] = result['cashbooks'][0]
|
||||||
|
|
||||||
recons = Recon2.search([
|
recons = Recon2.search([
|
||||||
('cashbook.id', '=', result['cashbook']),
|
('cashbook', '=', result['cashbook']),
|
||||||
], order=[('date_from', 'DESC')])
|
], order=[('date_from', 'DESC')])
|
||||||
if len(recons) > 0:
|
if len(recons) > 0:
|
||||||
result['reconciliations'] = [x.id for x in recons]
|
result['reconciliations'] = [x.id for x in recons]
|
||||||
|
|
Loading…
Reference in a new issue