Compare commits
130 commits
main
...
ver_6.0.25
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ea737d61d2 | ||
![]() |
204a0a2623 | ||
![]() |
08e99bb84b | ||
![]() |
553e58371b | ||
![]() |
1a63415034 | ||
![]() |
b2e5890512 | ||
![]() |
f105e8bd6c | ||
![]() |
9d33086ff2 | ||
![]() |
3f487d2953 | ||
![]() |
34f647b7c9 | ||
![]() |
46e5fff805 | ||
![]() |
a5df1eefdd | ||
![]() |
5d6dcb6b12 | ||
![]() |
9398076ec8 | ||
![]() |
a8122666d6 | ||
![]() |
bd3e63753f | ||
![]() |
b6d9d06c4f | ||
![]() |
4daeadce2b | ||
![]() |
c758375075 | ||
![]() |
5449d452e9 | ||
![]() |
1c14b0134b | ||
![]() |
d12b0a4c7b | ||
![]() |
9d710183d1 | ||
![]() |
2d6a363fbe | ||
![]() |
3b77439635 | ||
![]() |
28595a0df3 | ||
![]() |
3ded493d11 | ||
![]() |
cbeb4d1993 | ||
![]() |
e6baaa92f0 | ||
![]() |
5f20001f72 | ||
![]() |
af0c825607 | ||
![]() |
7c1fb44cae | ||
![]() |
197de3213d | ||
![]() |
6a0f0fa9f7 | ||
![]() |
54a1b79710 | ||
![]() |
b923384a65 | ||
![]() |
cec1e9d3bd | ||
![]() |
54587cf93e | ||
![]() |
23ee20f277 | ||
![]() |
fa6a6324d7 | ||
![]() |
53f2c4249d | ||
![]() |
70fd1a83fb | ||
![]() |
403729d75f | ||
![]() |
77cb9d770e | ||
![]() |
124c109eea | ||
![]() |
b9a08d7bd9 | ||
![]() |
e4e06000d3 | ||
![]() |
636c1c2654 | ||
![]() |
b81d5fc0f4 | ||
![]() |
56b4099fb3 | ||
![]() |
48d803ce78 | ||
![]() |
e4423be23e | ||
![]() |
a1784abed6 | ||
![]() |
200bcf7737 | ||
![]() |
b260fa7e24 | ||
![]() |
859a7f6225 | ||
![]() |
51c74cb42e | ||
![]() |
de168a8476 | ||
![]() |
233619d034 | ||
![]() |
559882b332 | ||
![]() |
8992cfd64c | ||
![]() |
4c12d8723a | ||
![]() |
b325035a90 | ||
![]() |
f217d70e61 | ||
![]() |
47fc4abd58 | ||
![]() |
4b8f5f279a | ||
![]() |
aa6cc97dcf | ||
![]() |
32bf33fb23 | ||
![]() |
62188ebfd2 | ||
![]() |
d5fd206bf5 | ||
![]() |
f11fdfefcd | ||
![]() |
9e612d63b1 | ||
![]() |
f21eb9f9c7 | ||
![]() |
1e552cca4a | ||
![]() |
53c898e0a4 | ||
![]() |
7604feacf3 | ||
![]() |
17f666dc0c | ||
![]() |
7f1b826590 | ||
![]() |
0572e18b64 | ||
![]() |
47de6304b2 | ||
![]() |
aab73ff871 | ||
![]() |
3f317d80b2 | ||
![]() |
fdd7290cfc | ||
![]() |
785ec8f9a9 | ||
![]() |
e024044ccc | ||
![]() |
8421db2221 | ||
![]() |
57ade40eb8 | ||
![]() |
96cfe3a32c | ||
![]() |
ec4466176e | ||
![]() |
843ade71e9 | ||
![]() |
b2147f56b3 | ||
![]() |
1fee218ee6 | ||
![]() |
fe8a6bbed6 | ||
![]() |
5fd4bb9093 | ||
![]() |
dca9732fce | ||
![]() |
7d97128f24 | ||
![]() |
48d6246611 | ||
![]() |
638524a2c3 | ||
![]() |
9103f828dc | ||
![]() |
e14dd92c36 | ||
![]() |
c24fdef4cf | ||
![]() |
f2b228aba6 | ||
![]() |
46515aaf26 | ||
![]() |
a2cb2b308b | ||
![]() |
25db274d2d | ||
![]() |
11b3f7d004 | ||
![]() |
75a873e25d | ||
![]() |
de0de8a85f | ||
![]() |
0fcc997f28 | ||
![]() |
5797f42489 | ||
![]() |
4afd9f835d | ||
![]() |
70ef448beb | ||
![]() |
34a4958936 | ||
![]() |
f661f5ed38 | ||
![]() |
19389b3865 | ||
![]() |
b4e7cface3 | ||
![]() |
bb24a94cd1 | ||
![]() |
f76f91b35a | ||
![]() |
8abeb63441 | ||
![]() |
8b0a2a6ccd | ||
![]() |
613f4e9767 | ||
![]() |
a84e3ed8ba | ||
![]() |
4876b06421 | ||
![]() |
619a4e9ed6 | ||
![]() |
559a5d0656 | ||
![]() |
2fdee39611 | ||
![]() |
4df6284257 | ||
![]() |
0aa9df2f1d | ||
![]() |
dadcfb618f | ||
![]() |
603a9d7477 |
56 changed files with 1222 additions and 3925 deletions
|
@ -1,8 +1,6 @@
|
|||
*.pyc
|
||||
syntax: glob
|
||||
build/*
|
||||
dist/*
|
||||
mds_cashbook.egg-info/*
|
||||
locale/convert_de2en.py
|
||||
__pycache__/*
|
||||
.pytest_cache/*
|
||||
.env
|
16
COPYRIGHT
16
COPYRIGHT
|
@ -1,16 +0,0 @@
|
|||
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
674
LICENSE
|
@ -1,674 +0,0 @@
|
|||
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>.
|
|
@ -1,4 +0,0 @@
|
|||
include LICENSE
|
||||
include COPYRIGHT
|
||||
include README.rst
|
||||
include versiondep.txt
|
113
README.rst
113
README.rst
|
@ -9,7 +9,7 @@ pip install mds-cashbook
|
|||
|
||||
Requires
|
||||
========
|
||||
- Tryton 7.0
|
||||
- Tryton 6.0
|
||||
|
||||
How to
|
||||
======
|
||||
|
@ -153,6 +153,113 @@ currency are converted into the display currency of the parent cash book.
|
|||
Changes
|
||||
=======
|
||||
|
||||
*7.0.0 - 30.11.2023*
|
||||
*6.0.25 - 14.02.2023*
|
||||
|
||||
- compatibility to Tryton 7.0
|
||||
- fix: possible exception by invalid date in context
|
||||
- updt: optimize table + icon
|
||||
|
||||
*6.0.24 - 05.02.2023*
|
||||
|
||||
- fix: rewrite of line-values
|
||||
|
||||
*6.0.23 - 28.01.2023*
|
||||
|
||||
- fix: selection of subordinate cash books for calculations
|
||||
|
||||
*6.0.22 - 21.01.2023*
|
||||
|
||||
- add: enable extension by investment-module
|
||||
- updt: optimize form/list-views
|
||||
|
||||
*6.0.21 - 29.11.2022*
|
||||
|
||||
- updt: remove 'reconcile' button from line-form
|
||||
- add: how to
|
||||
|
||||
*6.0.20 - 16.11.2022*
|
||||
|
||||
- add: new state 'reconciled' at line
|
||||
|
||||
*6.0.19 - 19.10.2022*
|
||||
|
||||
- fix: delete()
|
||||
|
||||
*6.0.18 - 11.10.2022*
|
||||
|
||||
- updt: optimized open/view of cashbook
|
||||
|
||||
*6.0.17 - 10.10.2022*
|
||||
|
||||
- add: colors for cashbook-lines
|
||||
- add: client stores tree-state of cashbook
|
||||
|
||||
*6.0.16 - 07.10.2022*
|
||||
|
||||
- add: open cashbook-lines from cashbook
|
||||
|
||||
*6.0.15 - 04.10.2022*
|
||||
|
||||
- updt: second-currency support optimized
|
||||
|
||||
*6.0.14 - 30.09.2022*
|
||||
|
||||
- fix: parameter
|
||||
|
||||
*6.0.13 - 28.09.2022*
|
||||
|
||||
- hierarchical ordering for cashbook
|
||||
- forms optimzed
|
||||
|
||||
*6.0.12 - 18.09.2022*
|
||||
|
||||
- add: selected cashbooks in 'enter-booking-dialog'
|
||||
|
||||
*6.0.11 - 16.09.2022*
|
||||
|
||||
- add: hierarchy for cashbooks
|
||||
|
||||
*6.0.10 - 13.09.2022*
|
||||
|
||||
- add: split-booking with transfer
|
||||
|
||||
*6.0.9 - 08.09.2022*
|
||||
|
||||
- updt: allow negative amounts
|
||||
|
||||
*6.0.8 - 07.09.2022*
|
||||
|
||||
- updt: enter-booking form optimized
|
||||
|
||||
*6.0.7 - 07.09.2022*
|
||||
|
||||
- add: enter-booking-wizard
|
||||
|
||||
*6.0.6 - 06.09.2022*
|
||||
|
||||
- updt: optimized form - line, line-context
|
||||
- updt: extended search in cashbook-lines
|
||||
|
||||
*6.0.5 - 05.09.2022*
|
||||
|
||||
- updt: view of book + line optimized
|
||||
|
||||
*6.0.4 - 05.09.2022*
|
||||
|
||||
- fix: write number at state-change 'check' -> 'done'
|
||||
- updt: speedup transaction view
|
||||
|
||||
*6.0.3 - 31.08.2022*
|
||||
|
||||
- updt: checks, sorting
|
||||
|
||||
*6.0.2 - 25.08.2022*
|
||||
|
||||
- add: split-booking
|
||||
|
||||
*6.0.1 - 23.08.2022*
|
||||
|
||||
- works
|
||||
|
||||
*6.0.0 - 05.08.2022*
|
||||
|
||||
- init
|
||||
|
|
|
@ -15,17 +15,11 @@ from .configuration import Configuration, UserConfiguration
|
|||
from .category import Category
|
||||
from .reconciliation import Reconciliation
|
||||
from .cbreport import ReconciliationReport
|
||||
from .currency import CurrencyRate
|
||||
from .valuestore import ValueStore
|
||||
from .ir import Rule
|
||||
from .cron import Cron
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Configuration,
|
||||
UserConfiguration,
|
||||
CurrencyRate,
|
||||
Type,
|
||||
Category,
|
||||
Book,
|
||||
|
@ -36,9 +30,6 @@ def register():
|
|||
OpenCashBookStart,
|
||||
RunCbReportStart,
|
||||
EnterBookingStart,
|
||||
ValueStore,
|
||||
Rule,
|
||||
Cron,
|
||||
module='cashbook', type_='model')
|
||||
Pool.register(
|
||||
ReconciliationReport,
|
||||
|
|
371
book.py
371
book.py
|
@ -3,9 +3,8 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.model import (
|
||||
Workflow, ModelView, ModelSQL, fields, Check, tree, Index)
|
||||
from trytond.pyson import Eval, Or, Bool, Id
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields, Check, tree
|
||||
from trytond.pyson import Eval, Or, Bool, Id, Len
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
from trytond.transaction import Transaction
|
||||
|
@ -14,9 +13,9 @@ from trytond.report import Report
|
|||
from decimal import Decimal
|
||||
from datetime import date
|
||||
from sql.aggregate import Sum
|
||||
from sql.conditionals import Case
|
||||
from .model import (
|
||||
order_name_hierarchical, sub_ids_hierarchical, AnyInArray)
|
||||
from sql.conditionals import Case, Coalesce
|
||||
from sql.functions import CurrentDate
|
||||
from .model import order_name_hierarchical, sub_ids_hierarchical, AnyInArray
|
||||
|
||||
|
||||
STATES = {
|
||||
|
@ -48,103 +47,82 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
'Cashbook'
|
||||
__name__ = 'cashbook.book'
|
||||
|
||||
company = fields.Many2One(
|
||||
string='Company', model_name='company.company',
|
||||
company = fields.Many2One(string='Company', model_name='company.company',
|
||||
required=True, ondelete="RESTRICT")
|
||||
name = fields.Char(
|
||||
string='Name', required=True, states=STATES, depends=DEPENDS)
|
||||
description = fields.Text(
|
||||
string='Description', states=STATES, depends=DEPENDS)
|
||||
btype = fields.Many2One(
|
||||
string='Type',
|
||||
help='A cash book with type can contain postings. ' +
|
||||
'Without type is a view.',
|
||||
name = fields.Char(string='Name', required=True,
|
||||
states=STATES, depends=DEPENDS)
|
||||
description = fields.Text(string='Description',
|
||||
states=STATES, depends=DEPENDS)
|
||||
btype = fields.Many2One(string='Type',
|
||||
help='A cash book with type can contain postings. Without type is a view.',
|
||||
model_name='cashbook.type', ondelete='RESTRICT',
|
||||
states={
|
||||
'readonly': Or(
|
||||
STATES['readonly'],
|
||||
Eval('has_lines', False))},
|
||||
depends=DEPENDS+['has_lines'])
|
||||
feature = fields.Function(fields.Char(
|
||||
string='Feature', readonly=True,
|
||||
Len(Eval('lines')) > 0,
|
||||
),
|
||||
}, depends=DEPENDS+['lines'])
|
||||
feature = fields.Function(fields.Char(string='Feature', readonly=True,
|
||||
states={'invisible': True}), 'on_change_with_feature')
|
||||
owner = fields.Many2One(
|
||||
string='Owner', required=True,
|
||||
owner = fields.Many2One(string='Owner', required=True, select=True,
|
||||
model_name='res.user', ondelete='SET NULL',
|
||||
states=STATES, depends=DEPENDS)
|
||||
reviewer = fields.Many2One(
|
||||
string='Reviewer',
|
||||
reviewer = fields.Many2One(string='Reviewer', select=True,
|
||||
help='Group of users who have write access to the cashbook.',
|
||||
model_name='res.group', ondelete='SET NULL',
|
||||
states=STATES, depends=DEPENDS)
|
||||
observer = fields.Many2One(
|
||||
string='Observer',
|
||||
observer = fields.Many2One(string='Observer', select=True,
|
||||
help='Group of users who have read-only access to the cashbook.',
|
||||
model_name='res.group', ondelete='SET NULL',
|
||||
states=STATES, depends=DEPENDS)
|
||||
lines = fields.One2Many(
|
||||
string='Lines', field='cashbook',
|
||||
lines = fields.One2Many(string='Lines', field='cashbook',
|
||||
model_name='cashbook.line',
|
||||
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(
|
||||
string='Reconciliations',
|
||||
reconciliations = fields.One2Many(string='Reconciliations',
|
||||
field='cashbook', model_name='cashbook.recon',
|
||||
states=STATES2, depends=DEPENDS2)
|
||||
number_sequ = fields.Many2One(
|
||||
string='Line numbering',
|
||||
number_sequ = fields.Many2One(string='Line numbering',
|
||||
help='Number sequence for numbering of the cash book lines.',
|
||||
model_name='ir.sequence',
|
||||
domain=[
|
||||
('sequence_type', '=',
|
||||
Id('cashbook', 'sequence_type_cashbook_line')),
|
||||
('sequence_type', '=', Id('cashbook', 'sequence_type_cashbook_line')),
|
||||
['OR',
|
||||
('company', '=', None),
|
||||
('company', '=', Eval('company', -1))],
|
||||
('company', '=', Eval('company', -1)),
|
||||
],
|
||||
],
|
||||
states=STATES3, depends=DEPENDS2+['company'])
|
||||
number_atcheck = fields.Boolean(
|
||||
string="number when 'Checking'",
|
||||
help="The numbering of the lines is done in the step Check. " +
|
||||
"If the check mark is inactive, this happens with Done.",
|
||||
number_atcheck = fields.Boolean(string="number when 'Checking'",
|
||||
help="The numbering of the lines is done in the step Check. If the check mark is inactive, this happens with Done.",
|
||||
states=STATES2, depends=DEPENDS2)
|
||||
start_date = fields.Date(
|
||||
string='Initial Date',
|
||||
start_date = fields.Date(string='Initial Date',
|
||||
states={
|
||||
'readonly': Or(
|
||||
STATES2['readonly'],
|
||||
Eval('has_lines', False)),
|
||||
Len(Eval('lines')) > 0,
|
||||
),
|
||||
'invisible': STATES2['invisible'],
|
||||
'required': ~STATES2['invisible'],
|
||||
}, depends=DEPENDS2+['has_lines'])
|
||||
|
||||
value_store = fields.One2Many(
|
||||
string='Values', model_name='cashbook.values', field='cashbook',
|
||||
readonly=True)
|
||||
balance = fields.Function(fields.Numeric(
|
||||
string='Balance',
|
||||
}, depends=DEPENDS2+['lines'])
|
||||
balance = fields.Function(fields.Numeric(string='Balance',
|
||||
readonly=True, depends=['currency_digits'],
|
||||
help='Balance of bookings to date',
|
||||
digits=(16, Eval('currency_digits', 2))),
|
||||
'get_balance_cashbook', searcher='search_balance')
|
||||
balance_all = fields.Function(fields.Numeric(
|
||||
string='Total balance',
|
||||
balance_all = fields.Function(fields.Numeric(string='Total balance',
|
||||
readonly=True, depends=['currency_digits'],
|
||||
help='Balance of all bookings',
|
||||
digits=(16, Eval('currency_digits', 2))),
|
||||
'get_balance_cashbook', searcher='search_balance')
|
||||
balance_ref = fields.Function(fields.Numeric(
|
||||
string='Balance (Ref.)',
|
||||
|
||||
balance_ref = fields.Function(fields.Numeric(string='Balance (Ref.)',
|
||||
help='Balance in company currency',
|
||||
readonly=True, digits=(16, Eval('company_currency_digits', 2)),
|
||||
states={
|
||||
'invisible': ~Bool(Eval('company_currency')),
|
||||
}, depends=['company_currency_digits', 'company_currency']),
|
||||
'get_balance_cashbook', searcher='search_balance')
|
||||
company_currency = fields.Function(fields.Many2One(
|
||||
readonly=True,
|
||||
'get_balance_cashbook')
|
||||
company_currency = fields.Function(fields.Many2One(readonly=True,
|
||||
string='Company Currency', states={'invisible': True},
|
||||
model_name='currency.currency'),
|
||||
'on_change_with_company_currency')
|
||||
|
@ -152,27 +130,23 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
string='Currency Digits (Ref.)', readonly=True),
|
||||
'on_change_with_currency_digits')
|
||||
|
||||
currency = fields.Many2One(
|
||||
string='Currency',
|
||||
currency = fields.Many2One(string='Currency', select=True,
|
||||
model_name='currency.currency',
|
||||
states={
|
||||
'readonly': Or(
|
||||
STATES2['readonly'],
|
||||
Eval('has_lines', False))},
|
||||
depends=DEPENDS2+['has_lines'])
|
||||
currency_digits = fields.Function(fields.Integer(
|
||||
string='Currency Digits',
|
||||
Len(Eval('lines', [])) > 0,
|
||||
),
|
||||
}, depends=DEPENDS2+['lines'])
|
||||
currency_digits = fields.Function(fields.Integer(string='Currency Digits',
|
||||
readonly=True), 'on_change_with_currency_digits')
|
||||
state = fields.Selection(
|
||||
string='State', required=True,
|
||||
state = fields.Selection(string='State', required=True,
|
||||
readonly=True, selection=sel_state_book)
|
||||
state_string = state.translated('state')
|
||||
|
||||
parent = fields.Many2One(
|
||||
string="Parent",
|
||||
parent = fields.Many2One(string="Parent",
|
||||
model_name='cashbook.book', ondelete='RESTRICT')
|
||||
childs = fields.One2Many(
|
||||
string='Children', field='parent',
|
||||
childs = fields.One2Many(string='Children', field='parent',
|
||||
model_name='cashbook.book')
|
||||
|
||||
@classmethod
|
||||
|
@ -190,29 +164,6 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
cls._order.insert(0, ('rec_name', 'ASC'))
|
||||
cls._order.insert(0, ('state', 'ASC'))
|
||||
t = cls.__table__()
|
||||
cls._sql_indexes.update({
|
||||
Index(
|
||||
t,
|
||||
(t.btype, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.company, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.currency, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.state, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.owner, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.reviewer, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.observer, Index.Equality())),
|
||||
})
|
||||
cls._sql_constraints.extend([
|
||||
('state_val',
|
||||
Check(t, t.state.in_(['open', 'closed', 'archive'])),
|
||||
|
@ -287,7 +238,8 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
Case(
|
||||
(tab_book.state == 'open', 0),
|
||||
else_ = 1),
|
||||
where=tab_book.id == table.id)
|
||||
where=tab_book.id==table.id
|
||||
)
|
||||
return [query]
|
||||
|
||||
@staticmethod
|
||||
|
@ -304,9 +256,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
if self.btype:
|
||||
return '%(name)s | %(balance)s %(symbol)s | %(state)s' % {
|
||||
'name': recname or '-',
|
||||
'balance': Report.format_number(
|
||||
self.balance or 0.0, None,
|
||||
digits=getattr(self.currency, 'digits', 2)),
|
||||
'balance': Report.format_number(self.balance or 0.0, None),
|
||||
'symbol': getattr(self.currency, 'symbol', '-'),
|
||||
'state': self.state_string,
|
||||
}
|
||||
|
@ -329,19 +279,17 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
# deny invalid date in context
|
||||
if isinstance(query_date, str):
|
||||
try :
|
||||
date.fromisoformat(query_date)
|
||||
except Exception:
|
||||
dt1 = date.fromisoformat(query_date)
|
||||
except :
|
||||
query_date = IrDate.today()
|
||||
|
||||
query = tab_book.join(
|
||||
tab_line,
|
||||
query = tab_book.join(tab_line,
|
||||
condition=tab_book.id==tab_line.cashbook,
|
||||
).select(
|
||||
tab_line.cashbook,
|
||||
tab_book.currency,
|
||||
Sum(Case(
|
||||
(tab_line.date <= query_date,
|
||||
tab_line.credit - tab_line.debit),
|
||||
(tab_line.date <= query_date, tab_line.credit - tab_line.debit),
|
||||
else_ = Decimal('0.0'),
|
||||
)).as_('balance'),
|
||||
Sum(tab_line.credit - tab_line.debit).as_('balance_all'),
|
||||
|
@ -349,141 +297,48 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
)
|
||||
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
|
||||
def order_balance(tables):
|
||||
""" order by balance
|
||||
"""
|
||||
Book2 = Pool().get('cashbook.book')
|
||||
return Book2.work_order_balance(tables, 'balance')
|
||||
(tab_book, tab2) = Book2.get_balance_of_cashbook_sql()
|
||||
table, _ = tables[None]
|
||||
|
||||
query = tab_book.select(tab_book.balance,
|
||||
where=tab_book.cashbook==table.id,
|
||||
)
|
||||
return [query]
|
||||
|
||||
@staticmethod
|
||||
def order_balance_all(tables):
|
||||
""" order by balance-all
|
||||
"""
|
||||
Book2 = Pool().get('cashbook.book')
|
||||
return Book2.work_order_balance(tables, 'balance_all')
|
||||
(tab_book, tab2) = Book2.get_balance_of_cashbook_sql()
|
||||
table, _ = tables[None]
|
||||
|
||||
@staticmethod
|
||||
def order_balance_ref(tables):
|
||||
""" order by balance-all
|
||||
"""
|
||||
Book2 = Pool().get('cashbook.book')
|
||||
return Book2.work_order_balance(tables, 'balance_ref')
|
||||
query = tab_book.select(tab_book.balance_all,
|
||||
where=tab_book.cashbook==table.id,
|
||||
)
|
||||
return [query]
|
||||
|
||||
@classmethod
|
||||
def search_balance(cls, name, clause):
|
||||
""" search in 'balance'
|
||||
"""
|
||||
ValueStore = Pool().get('cashbook.values')
|
||||
Operator = fields.SQL_OPERATORS[clause[1]]
|
||||
context = Transaction().context
|
||||
|
||||
query_date = context.get('date', None)
|
||||
if query_date is not None:
|
||||
|
||||
if name == 'balance_ref':
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_nosearch_with_date',
|
||||
fname=name, model=cls.__name__))
|
||||
|
||||
(tab_line, tab2) = cls.get_balance_of_cashbook_sql()
|
||||
Operator = fields.SQL_OPERATORS[clause[1]]
|
||||
|
||||
query = tab_line.select(
|
||||
tab_line.cashbook,
|
||||
where=Operator(
|
||||
getattr(tab_line, name), clause[2]))
|
||||
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
|
||||
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
|
||||
"""
|
||||
pool = Pool()
|
||||
|
@ -496,33 +351,28 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
cursor = Transaction().connection.cursor()
|
||||
context = Transaction().context
|
||||
|
||||
result = {
|
||||
x: {y.id: Decimal('0.0') for y in cashbooks}
|
||||
for x in ['balance', 'balance_all', 'balance_ref']}
|
||||
result = {x:{y.id: Decimal('0.0') for y in cashbooks} for x in names}
|
||||
|
||||
# deny invalid date in context
|
||||
query_date = context.get('date', IrDate.today())
|
||||
if isinstance(query_date, str):
|
||||
try :
|
||||
date.fromisoformat(query_date)
|
||||
except Exception:
|
||||
dt1 = date.fromisoformat(query_date)
|
||||
except :
|
||||
query_date = IrDate.today()
|
||||
|
||||
# query balances of cashbooks and sub-cashbooks
|
||||
with Transaction().set_context({
|
||||
'date': query_date}):
|
||||
'date': query_date,
|
||||
}):
|
||||
(tab_line, tab2) = cls.get_balance_of_cashbook_sql()
|
||||
tab_subids = sub_ids_hierarchical('cashbook.book')
|
||||
query = tab_book.join(
|
||||
tab_subids,
|
||||
query = tab_book.join(tab_subids,
|
||||
condition=tab_book.id==tab_subids.parent,
|
||||
).join(
|
||||
tab_comp,
|
||||
).join(tab_comp,
|
||||
condition=tab_book.company==tab_comp.id,
|
||||
).join(
|
||||
tab_line,
|
||||
condition=tab_line.cashbook == AnyInArray(
|
||||
tab_subids.subids),
|
||||
).join(tab_line,
|
||||
condition=tab_line.cashbook==AnyInArray(tab_subids.subids),
|
||||
).select(
|
||||
tab_book.id,
|
||||
tab_book.currency.as_('to_currency'),
|
||||
|
@ -530,33 +380,29 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
tab_comp.currency.as_('company_currency'),
|
||||
Sum(tab_line.balance).as_('balance'),
|
||||
Sum(tab_line.balance_all).as_('balance_all'),
|
||||
group_by=[
|
||||
tab_book.id, tab_line.currency, tab_comp.currency],
|
||||
group_by=[tab_book.id, tab_line.currency, tab_comp.currency],
|
||||
where=tab_book.id.in_([x.id for x in cashbooks]),
|
||||
)
|
||||
cursor.execute(*query)
|
||||
records = cursor.fetchall()
|
||||
|
||||
for record in records:
|
||||
result['balance'][record[0]] += Currency.compute(
|
||||
record[2], record[4], record[1])
|
||||
result['balance_all'][record[0]] += Currency.compute(
|
||||
record[2], record[5], record[1])
|
||||
result['balance_ref'][record[0]] += Currency.compute(
|
||||
record[2], record[5], record[3])
|
||||
values = {
|
||||
'balance': Currency.compute(
|
||||
record[2], record[4], record[1],
|
||||
),
|
||||
'balance_all': Currency.compute(
|
||||
record[2], record[5], record[1],
|
||||
),
|
||||
'balance_ref': Currency.compute(
|
||||
record[2], record[5], record[3],
|
||||
),
|
||||
}
|
||||
|
||||
for name in names:
|
||||
result[name][record[0]] += values[name]
|
||||
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')
|
||||
def on_change_with_feature(self, name=None):
|
||||
""" get feature-set
|
||||
|
@ -608,14 +454,6 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
"""
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
""" update values
|
||||
"""
|
||||
records = super(Book, cls).create(vlist)
|
||||
cls.valuestore_update_records(records)
|
||||
return records
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
""" deny update if book is not 'open'
|
||||
|
@ -624,9 +462,7 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
|
||||
actions = iter(args)
|
||||
to_write_config = []
|
||||
to_update = []
|
||||
for books, values in zip(actions, actions):
|
||||
to_update.extend(books)
|
||||
for book in books:
|
||||
# deny btype-->None if lines not empty
|
||||
if 'btype' in values.keys():
|
||||
|
@ -634,33 +470,33 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
raise UserError(gettext(
|
||||
'cashbook.msg_book_btype_with_lines',
|
||||
cbname = book.rec_name,
|
||||
numlines=len(book.lines)))
|
||||
numlines = len(book.lines),
|
||||
))
|
||||
|
||||
if book.state != 'open':
|
||||
# allow state-update, if its the only action
|
||||
if not (('state' in values.keys()) and
|
||||
(len(values.keys()) == 1)):
|
||||
if not (('state' in values.keys()) and (len(values.keys()) == 1)):
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_book_deny_write',
|
||||
bookname = book.rec_name,
|
||||
state_txt=book.state_string))
|
||||
state_txt = book.state_string,
|
||||
))
|
||||
|
||||
# if owner changes, remove book from user-config
|
||||
if 'owner' in values.keys():
|
||||
if book.owner.id != values['owner']:
|
||||
for x in [
|
||||
'defbook', 'book1', 'book2', 'book3',
|
||||
for x in ['defbook', 'book1', 'book2', 'book3',
|
||||
'book4', 'book5']:
|
||||
cfg1 = ConfigUser.search([
|
||||
('iduser', '=', book.owner.id),
|
||||
('%s.id' % x, '=', book.id)])
|
||||
('iduser.id', '=', book.owner.id),
|
||||
('%s.id' % x, '=', book.id),
|
||||
])
|
||||
if len(cfg1) > 0:
|
||||
to_write_config.extend([ cfg1, {x: None} ])
|
||||
super(Book, cls).write(*args)
|
||||
|
||||
if len(to_write_config) > 0:
|
||||
ConfigUser.write(*to_write_config)
|
||||
cls.valuestore_update_records(to_update)
|
||||
|
||||
@classmethod
|
||||
def delete(cls, books):
|
||||
|
@ -671,7 +507,8 @@ class Book(tree(separator='/'), Workflow, ModelSQL, ModelView):
|
|||
raise UserError(gettext(
|
||||
'cashbook.msg_book_deny_delete',
|
||||
bookname = book.rec_name,
|
||||
booklines=len(book.lines)))
|
||||
booklines = len(book.lines),
|
||||
))
|
||||
super(Book, cls).delete(books)
|
||||
|
||||
# end Book
|
||||
|
|
6
book.xml
6
book.xml
|
@ -121,7 +121,7 @@ full copyright notices and license terms. -->
|
|||
</record>
|
||||
<record model="ir.rule" id="rg_book_rw_owner-1">
|
||||
<field name="domain" eval="[
|
||||
('owner.id', '=', Eval('user_id', -1)),
|
||||
('owner.id', '=', Eval('user', {}).get('id', -1)),
|
||||
]" pyson="1"/>
|
||||
<field name="rule_group" ref="rg_book_rw_owner"/>
|
||||
</record>
|
||||
|
@ -143,8 +143,8 @@ full copyright notices and license terms. -->
|
|||
</record>
|
||||
<record model="ir.rule" id="rg_book_read_nonowner-1">
|
||||
<field name="domain" eval="['OR',
|
||||
('observer.id', 'in', Eval('groups', [])),
|
||||
('reviewer.id', 'in', Eval('groups', [])),
|
||||
('observer.id', 'in', Eval('user', {}).get('groups', [])),
|
||||
('reviewer.id', 'in', Eval('user', {}).get('groups', [])),
|
||||
]" pyson="1"/>
|
||||
<field name="rule_group" ref="rg_book_read_nonowner"/>
|
||||
</record>
|
||||
|
|
24
category.py
24
category.py
|
@ -11,7 +11,6 @@ from trytond.exceptions import UserError
|
|||
from trytond.i18n import gettext
|
||||
from sql.operators import Equal
|
||||
from .model import order_name_hierarchical
|
||||
from .const import DEF_NONE
|
||||
|
||||
|
||||
sel_categorytype = [
|
||||
|
@ -26,27 +25,22 @@ class Category(tree(separator='/'), ModelSQL, ModelView):
|
|||
|
||||
name = fields.Char(string='Name', required=True, translate=True)
|
||||
description = fields.Char(string='Description', translate=True)
|
||||
cattype = fields.Selection(
|
||||
string='Type', required=True,
|
||||
cattype = fields.Selection(string='Type', required=True,
|
||||
help='Type of Category', selection=sel_categorytype,
|
||||
states={'readonly': Bool(Eval('parent_cattype'))},
|
||||
domain=[If(Bool(Eval('parent_cattype')),
|
||||
('cattype', '=', Eval('parent_cattype', '')),
|
||||
())],
|
||||
depends=['parent_cattype'])
|
||||
parent_cattype = fields.Function(fields.Char(
|
||||
string='Parent Category Type',
|
||||
parent_cattype = fields.Function(fields.Char(string='Parent Category Type',
|
||||
readonly=True, states={'invisible': True}),
|
||||
'on_change_with_parent_cattype')
|
||||
|
||||
company = fields.Many2One(
|
||||
string='Company', model_name='company.company',
|
||||
company = fields.Many2One(string='Company', model_name='company.company',
|
||||
required=True, ondelete="RESTRICT")
|
||||
parent = fields.Many2One(
|
||||
string="Parent",
|
||||
parent = fields.Many2One(string="Parent",
|
||||
model_name='cashbook.category', ondelete='RESTRICT')
|
||||
childs = fields.One2Many(
|
||||
string='Children', field='parent',
|
||||
childs = fields.One2Many(string='Children', field='parent',
|
||||
model_name='cashbook.category')
|
||||
|
||||
@classmethod
|
||||
|
@ -67,11 +61,10 @@ class Category(tree(separator='/'), ModelSQL, ModelView):
|
|||
Unique(t, t.name, t.company, t.parent),
|
||||
'cashbook.msg_category_name_unique'),
|
||||
('name2_uniq',
|
||||
Exclude(
|
||||
t,
|
||||
Exclude(t,
|
||||
(t.name, Equal),
|
||||
(t.cattype, Equal),
|
||||
where=(t.parent == DEF_NONE)),
|
||||
where=(t.parent == None)),
|
||||
'cashbook.msg_category_name_unique'),
|
||||
])
|
||||
|
||||
|
@ -114,7 +107,8 @@ class Category(tree(separator='/'), ModelSQL, ModelView):
|
|||
raise UserError(gettext(
|
||||
'cashbook.msg_category_type_not_like_parent',
|
||||
parentname = category.parent.rec_name,
|
||||
catname=category.rec_name,))
|
||||
catname = category.rec_name,
|
||||
))
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
|
|
11
cbreport.py
11
cbreport.py
|
@ -20,8 +20,7 @@ class ReconciliationReport(Report):
|
|||
Company = Pool().get('company.company')
|
||||
context2 = Transaction().context
|
||||
|
||||
context = super(
|
||||
ReconciliationReport, cls).get_context(records, header, data)
|
||||
context = super(ReconciliationReport, cls).get_context(records, header, data)
|
||||
context['company'] = Company(context2['company'])
|
||||
return context
|
||||
|
||||
|
@ -44,12 +43,12 @@ class ReconciliationReport(Report):
|
|||
'cashbook.msg_rep_reconciliation_fname',
|
||||
recname = recon_obj.cashbook.rec_name[:50],
|
||||
date_from = recon_obj.date_from.isoformat(),
|
||||
date_to=recon_obj.date_to.isoformat())
|
||||
date_to = recon_obj.date_to.isoformat(),
|
||||
)
|
||||
else :
|
||||
raise ValueError('invalid model')
|
||||
|
||||
(ext1, cont1, dirprint, title) = super(
|
||||
ReconciliationReport, cls).execute(ids, data)
|
||||
(ext1, cont1, dirprint, title) = super(ReconciliationReport, cls).execute(ids, data)
|
||||
|
||||
return (
|
||||
ext1,
|
||||
|
@ -64,3 +63,5 @@ class ReconciliationReport(Report):
|
|||
)
|
||||
|
||||
# end ReconciliationReport
|
||||
|
||||
|
||||
|
|
120
configuration.py
120
configuration.py
|
@ -9,70 +9,69 @@ from trytond.pyson import Eval, If
|
|||
from trytond.pool import Pool
|
||||
|
||||
|
||||
field_checked = fields.Boolean(
|
||||
string='Checked',
|
||||
field_checked = fields.Boolean(string='Checked',
|
||||
help='Show cashbook lines in Checked-state.')
|
||||
field_done = fields.Boolean(
|
||||
string='Done',
|
||||
field_done = fields.Boolean(string='Done',
|
||||
help='Show cashbook lines in Done-state.')
|
||||
field_catnamelong = fields.Boolean(
|
||||
string='Category: Show long name',
|
||||
help='Shows the long name of the category in the Category ' +
|
||||
'field of a cash book line.')
|
||||
field_catnamelong = fields.Boolean(string='Category: Show long name',
|
||||
help='Shows the long name of the category in the Category field of a cash book line.')
|
||||
|
||||
|
||||
class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
|
||||
'Configuration'
|
||||
__name__ = 'cashbook.configuration'
|
||||
|
||||
date_from = fields.MultiValue(fields.Date(
|
||||
string='Start Date', depends=['date_to'],
|
||||
date_from = fields.MultiValue(fields.Date(string='Start Date', depends=['date_to'],
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
())]))
|
||||
date_to = fields.MultiValue(fields.Date(
|
||||
string='End Date', depends=['date_from'],
|
||||
()),
|
||||
]))
|
||||
date_to = fields.MultiValue(fields.Date(string='End Date', depends=['date_from'],
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
())]))
|
||||
()),
|
||||
]))
|
||||
checked = fields.MultiValue(field_checked)
|
||||
done = fields.MultiValue(field_done)
|
||||
catnamelong = fields.MultiValue(field_catnamelong)
|
||||
defbook = fields.MultiValue(fields.Many2One(
|
||||
string='Default Cashbook',
|
||||
help='The default cashbook is selected when you open ' +
|
||||
'the booking wizard.',
|
||||
defbook = fields.MultiValue(fields.Many2One(string='Default Cashbook',
|
||||
help='The default cashbook is selected when you open the booking wizard.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||
book1 = fields.MultiValue(fields.Many2One(
|
||||
string='Cashbook 1',
|
||||
domain=[
|
||||
('btype', '!=', None), ('state', '=', 'open'),
|
||||
]))
|
||||
book1 = fields.MultiValue(fields.Many2One(string='Cashbook 1',
|
||||
help='Cash book available in selection dialog.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||
book2 = fields.MultiValue(fields.Many2One(
|
||||
string='Cashbook 2',
|
||||
domain=[
|
||||
('btype', '!=', None), ('state', '=', 'open'),
|
||||
]))
|
||||
book2 = fields.MultiValue(fields.Many2One(string='Cashbook 2',
|
||||
help='Cash book available in selection dialog.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||
book3 = fields.MultiValue(fields.Many2One(
|
||||
string='Cashbook 3',
|
||||
domain=[
|
||||
('btype', '!=', None), ('state', '=', 'open'),
|
||||
]))
|
||||
book3 = fields.MultiValue(fields.Many2One(string='Cashbook 3',
|
||||
help='Cash book available in selection dialog.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||
book4 = fields.MultiValue(fields.Many2One(
|
||||
string='Cashbook 4',
|
||||
domain=[
|
||||
('btype', '!=', None), ('state', '=', 'open'),
|
||||
]))
|
||||
book4 = fields.MultiValue(fields.Many2One(string='Cashbook 4',
|
||||
help='Cash book available in selection dialog.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||
book5 = fields.MultiValue(fields.Many2One(
|
||||
string='Cashbook 5',
|
||||
domain=[
|
||||
('btype', '!=', None), ('state', '=', 'open'),
|
||||
]))
|
||||
book5 = fields.MultiValue(fields.Many2One(string='Cashbook 5',
|
||||
help='Cash book available in selection dialog.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[('btype', '!=', None), ('state', '=', 'open')]))
|
||||
fixate = fields.MultiValue(fields.Boolean(
|
||||
string='Fixate', help='Fixating of the booking is activated.'))
|
||||
domain=[
|
||||
('btype', '!=', None), ('state', '=', 'open'),
|
||||
]))
|
||||
|
||||
@classmethod
|
||||
def multivalue_model(cls, field):
|
||||
|
@ -80,10 +79,9 @@ class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
|
|||
"""
|
||||
pool = Pool()
|
||||
|
||||
if field in [
|
||||
'date_from', 'date_to', 'checked', 'done',
|
||||
if field in ['date_from', 'date_to', 'checked', 'done',
|
||||
'catnamelong', 'defbook', 'book1', 'book2',
|
||||
'book3', 'book4', 'book5', 'fixate']:
|
||||
'book3', 'book4', 'book5']:
|
||||
return pool.get('cashbook.configuration_user')
|
||||
return super(Configuration, cls).multivalue_model(field)
|
||||
|
||||
|
@ -99,10 +97,6 @@ class Configuration(ModelSingleton, ModelSQL, ModelView, UserMultiValueMixin):
|
|||
def default_catnamelong(cls, **pattern):
|
||||
return cls.multivalue_model('catnamelong').default_catnamelong()
|
||||
|
||||
@classmethod
|
||||
def default_fixate(cls, **pattern):
|
||||
return cls.multivalue_model('fixate').default_fixate()
|
||||
|
||||
# end Configuration
|
||||
|
||||
|
||||
|
@ -110,33 +104,30 @@ class UserConfiguration(ModelSQL, UserValueMixin):
|
|||
'User Configuration'
|
||||
__name__ = 'cashbook.configuration_user'
|
||||
|
||||
date_from = fields.Date(
|
||||
string='Start Date', depends=['date_to'],
|
||||
date_from = fields.Date(string='Start Date', depends=['date_to'],
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
())])
|
||||
date_to = fields.Date(
|
||||
string='End Date', depends=['date_from'],
|
||||
()),
|
||||
])
|
||||
date_to = fields.Date(string='End Date', depends=['date_from'],
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
())])
|
||||
()),
|
||||
])
|
||||
checked = field_checked
|
||||
done = field_done
|
||||
catnamelong = field_catnamelong
|
||||
defbook = fields.Many2One(
|
||||
string='Default Cashbook',
|
||||
help='The default cashbook is selected when you open ' +
|
||||
'the booking wizard.',
|
||||
defbook = fields.Many2One(string='Default Cashbook',
|
||||
help='The default cashbook is selected when you open the booking wizard.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[
|
||||
('btype', '!=', None),
|
||||
('state', '=', 'open'),
|
||||
('owner.id', '=', Eval('iduser', -1))
|
||||
], depends=['iduser'])
|
||||
book1 = fields.Many2One(
|
||||
string='Cashbook 1',
|
||||
book1 = fields.Many2One(string='Cashbook 1',
|
||||
help='Cash book available in selection dialog.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[
|
||||
|
@ -144,8 +135,7 @@ class UserConfiguration(ModelSQL, UserValueMixin):
|
|||
('state', '=', 'open'),
|
||||
('owner.id', '=', Eval('iduser', -1))
|
||||
], depends=['iduser'])
|
||||
book2 = fields.Many2One(
|
||||
string='Cashbook 2',
|
||||
book2 = fields.Many2One(string='Cashbook 2',
|
||||
help='Cash book available in selection dialog.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[
|
||||
|
@ -153,8 +143,7 @@ class UserConfiguration(ModelSQL, UserValueMixin):
|
|||
('state', '=', 'open'),
|
||||
('owner.id', '=', Eval('iduser', -1))
|
||||
], depends=['iduser'])
|
||||
book3 = fields.Many2One(
|
||||
string='Cashbook 3',
|
||||
book3 = fields.Many2One(string='Cashbook 3',
|
||||
help='Cash book available in selection dialog.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[
|
||||
|
@ -162,8 +151,7 @@ class UserConfiguration(ModelSQL, UserValueMixin):
|
|||
('state', '=', 'open'),
|
||||
('owner.id', '=', Eval('iduser', -1))
|
||||
], depends=['iduser'])
|
||||
book4 = fields.Many2One(
|
||||
string='Cashbook 4',
|
||||
book4 = fields.Many2One(string='Cashbook 4',
|
||||
help='Cash book available in selection dialog.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[
|
||||
|
@ -171,8 +159,7 @@ class UserConfiguration(ModelSQL, UserValueMixin):
|
|||
('state', '=', 'open'),
|
||||
('owner.id', '=', Eval('iduser', -1))
|
||||
], depends=['iduser'])
|
||||
book5 = fields.Many2One(
|
||||
string='Cashbook 5',
|
||||
book5 = fields.Many2One(string='Cashbook 5',
|
||||
help='Cash book available in selection dialog.',
|
||||
model_name='cashbook.book', ondelete='SET NULL',
|
||||
domain=[
|
||||
|
@ -181,9 +168,6 @@ class UserConfiguration(ModelSQL, UserValueMixin):
|
|||
('owner.id', '=', Eval('iduser', -1))
|
||||
], depends=['iduser'])
|
||||
|
||||
fixate = fields.Boolean(
|
||||
string='Fixate', help='Fixating of the booking is activated.')
|
||||
|
||||
@classmethod
|
||||
def default_checked(cls):
|
||||
return True
|
||||
|
@ -196,8 +180,4 @@ class UserConfiguration(ModelSQL, UserValueMixin):
|
|||
def default_done(cls):
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def default_fixate(cls):
|
||||
return False
|
||||
|
||||
# end UserConfiguration
|
||||
|
|
8
const.py
8
const.py
|
@ -1,8 +0,0 @@
|
|||
# -*- 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
18
cron.py
|
@ -1,18 +0,0 @@
|
|||
# -*- 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
15
cron.xml
|
@ -1,15 +0,0 @@
|
|||
<?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>
|
63
currency.py
63
currency.py
|
@ -1,63 +0,0 @@
|
|||
# -*- 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, Pool
|
||||
|
||||
|
||||
class CurrencyRate(metaclass=PoolMeta):
|
||||
__name__ = 'currency.currency.rate'
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
""" update cache-value
|
||||
"""
|
||||
pool = Pool()
|
||||
Cashbook = pool.get('cashbook.book')
|
||||
ValueStore = pool.get('cashbook.values')
|
||||
|
||||
records = super(CurrencyRate, cls).create(vlist)
|
||||
|
||||
ValueStore.update_books(
|
||||
ValueStore.get_book_by_books(
|
||||
Cashbook.search([
|
||||
('currency', 'in', [
|
||||
x.currency.id for x in records])])))
|
||||
return records
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
""" update cache-value
|
||||
"""
|
||||
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)
|
||||
|
||||
ValueStore.update_books(
|
||||
ValueStore.get_book_by_books(
|
||||
Cashbook.search([
|
||||
('currency', 'in', [
|
||||
x.currency.id for x in all_rates])])))
|
||||
|
||||
@classmethod
|
||||
def delete(cls, records):
|
||||
""" set cache to None
|
||||
"""
|
||||
pool = Pool()
|
||||
Cashbook = pool.get('cashbook.book')
|
||||
ValueStore = pool.get('cashbook.values')
|
||||
|
||||
books = ValueStore.get_book_by_books(Cashbook.search([
|
||||
('currency', 'in', [x.currency.id for x in records])]))
|
||||
super(CurrencyRate, cls).delete(records)
|
||||
ValueStore.update_books(books)
|
||||
|
||||
# end
|
|
@ -1,21 +0,0 @@
|
|||
settings in tytond.conf
|
||||
|
||||
[cashbook]
|
||||
# enable caching of values, stores values between
|
||||
# browser requests, speeds up the retrieval of data.
|
||||
# default: yes
|
||||
memcache = yes
|
||||
|
||||
# Enables synchronization of the cache between multiple
|
||||
# server instances.
|
||||
# default: yes
|
||||
# Requires the setting :
|
||||
# [cache]
|
||||
# clean_timeout=0
|
||||
sync = yes
|
||||
|
||||
# Enables caching of the cache key for currency rates.
|
||||
# Reduces the time required to determine the cache
|
||||
# key for currency values.
|
||||
# default: yes
|
||||
cache_currency = yes
|
24
ir.py
24
ir.py
|
@ -1,24 +0,0 @@
|
|||
# -*- 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
|
404
line.py
404
line.py
|
@ -3,7 +3,7 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.model import ModelView, ModelSQL, Workflow, fields, Check, Index
|
||||
from trytond.model import ModelView, ModelSQL, Workflow, fields, Check
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Eval, If, Or, Bool, Date
|
||||
from trytond.transaction import Transaction
|
||||
|
@ -16,7 +16,6 @@ from sql.functions import DatePart
|
|||
from sql.conditionals import Case
|
||||
from .book import sel_state_book
|
||||
from .mixin import SecondCurrencyMixin
|
||||
from .const import DEF_NONE
|
||||
|
||||
|
||||
sel_payee = [
|
||||
|
@ -24,7 +23,7 @@ sel_payee = [
|
|||
('party.party', 'Party')
|
||||
]
|
||||
|
||||
sel_linestate = [
|
||||
sel_linetype = [
|
||||
('edit', 'Edit'),
|
||||
('check', 'Checked'),
|
||||
('recon', 'Reconciled'),
|
||||
|
@ -53,30 +52,25 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
'Cashbook Line'
|
||||
__name__ = 'cashbook.line'
|
||||
|
||||
cashbook = fields.Many2One(
|
||||
string='Cashbook', required=True,
|
||||
cashbook = fields.Many2One(string='Cashbook', required=True, select=True,
|
||||
model_name='cashbook.book', ondelete='CASCADE', readonly=True,
|
||||
domain=[('btype', '!=', None)])
|
||||
date = fields.Date(
|
||||
string='Date', required=True,
|
||||
date = fields.Date(string='Date', required=True, select=True,
|
||||
states=STATES, depends=DEPENDS)
|
||||
month = fields.Function(fields.Integer(
|
||||
string='Month', readonly=True),
|
||||
month = fields.Function(fields.Integer(string='Month', readonly=True),
|
||||
'on_change_with_month', searcher='search_month')
|
||||
number = fields.Char(string='Number', readonly=True)
|
||||
description = fields.Text(
|
||||
string='Description',
|
||||
description = fields.Text(string='Description', select=True,
|
||||
states=STATES, depends=DEPENDS)
|
||||
descr_short = fields.Function(fields.Char(
|
||||
string='Description', readonly=True),
|
||||
descr_short = fields.Function(fields.Char(string='Description', readonly=True),
|
||||
'on_change_with_descr_short', searcher='search_descr_short')
|
||||
category = fields.Many2One(
|
||||
string='Category',
|
||||
category = fields.Many2One(string='Category',
|
||||
model_name='cashbook.category', ondelete='RESTRICT',
|
||||
states={
|
||||
'readonly': Or(
|
||||
STATES['readonly'],
|
||||
~Bool(Eval('bookingtype'))),
|
||||
Bool(Eval('bookingtype')) == False,
|
||||
),
|
||||
'required': Eval('bookingtype', '').in_(['in', 'out']),
|
||||
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
|
||||
}, depends=DEPENDS+['bookingtype'],
|
||||
|
@ -86,23 +80,18 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
('cattype', '=', 'in'),
|
||||
('cattype', '=', 'out'),
|
||||
)])
|
||||
category_view = fields.Function(fields.Char(
|
||||
string='Category', readonly=True),
|
||||
category_view = fields.Function(fields.Char(string='Category', readonly=True),
|
||||
'on_change_with_category_view', searcher='search_category_view')
|
||||
feature = fields.Function(fields.Char(
|
||||
string='Feature', readonly=True,
|
||||
feature = fields.Function(fields.Char(string='Feature', readonly=True,
|
||||
states={'invisible': True}), 'on_change_with_feature')
|
||||
booktransf_feature = fields.Function(fields.Char(
|
||||
string='Feature', readonly=True,
|
||||
booktransf_feature = fields.Function(fields.Char(string='Feature', readonly=True,
|
||||
states={'invisible': True}), 'on_change_with_booktransf_feature')
|
||||
|
||||
bookingtype = fields.Selection(
|
||||
string='Type', required=True,
|
||||
bookingtype = fields.Selection(string='Type', required=True,
|
||||
help='Type of Booking', selection=sel_bookingtype,
|
||||
states=STATES, depends=DEPENDS)
|
||||
bookingtype_string = bookingtype.translated('bookingtype')
|
||||
amount = fields.Numeric(
|
||||
string='Amount', digits=(16, Eval('currency_digits', 2)),
|
||||
amount = fields.Numeric(string='Amount', digits=(16, Eval('currency_digits', 2)),
|
||||
required=True,
|
||||
states={
|
||||
'readonly': Or(
|
||||
|
@ -110,16 +99,13 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
Eval('bookingtype', '').in_(['spin', 'spout']),
|
||||
),
|
||||
}, depends=DEPENDS+['currency_digits', 'bookingtype'])
|
||||
debit = fields.Numeric(
|
||||
string='Debit', digits=(16, Eval('currency_digits', 2)),
|
||||
debit = fields.Numeric(string='Debit', digits=(16, Eval('currency_digits', 2)),
|
||||
required=True, readonly=True, depends=['currency_digits'])
|
||||
credit = fields.Numeric(
|
||||
string='Credit', digits=(16, Eval('currency_digits', 2)),
|
||||
credit = fields.Numeric(string='Credit', digits=(16, Eval('currency_digits', 2)),
|
||||
required=True, readonly=True, depends=['currency_digits'])
|
||||
|
||||
# party or cashbook as counterpart
|
||||
booktransf = fields.Many2One(
|
||||
string='Source/Dest',
|
||||
booktransf = fields.Many2One(string='Source/Dest',
|
||||
ondelete='RESTRICT', model_name='cashbook.book',
|
||||
domain=[
|
||||
('owner.id', '=', Eval('owner_cashbook', -1)),
|
||||
|
@ -131,38 +117,30 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
'invisible': ~Eval('bookingtype', '').in_(['mvin', 'mvout']),
|
||||
'required': Eval('bookingtype', '').in_(['mvin', 'mvout']),
|
||||
}, depends=DEPENDS+['bookingtype', 'owner_cashbook', 'cashbook'])
|
||||
party = fields.Many2One(
|
||||
string='Party', model_name='party.party',
|
||||
party = fields.Many2One(string='Party', model_name='party.party',
|
||||
ondelete='RESTRICT',
|
||||
states={
|
||||
'readonly': STATES['readonly'],
|
||||
'invisible': ~Eval('bookingtype', '').in_(
|
||||
['in', 'out', 'spin', 'spout']),
|
||||
'invisible': ~Eval('bookingtype', '').in_(['in', 'out', 'spin', 'spout']),
|
||||
}, depends=DEPENDS+['bookingtype'])
|
||||
payee = fields.Function(fields.Reference(
|
||||
string='Payee', readonly=True,
|
||||
payee = fields.Function(fields.Reference(string='Payee', readonly=True,
|
||||
selection=sel_payee), 'on_change_with_payee', searcher='search_payee')
|
||||
|
||||
# link to lines created by this record
|
||||
reference = fields.Many2One(
|
||||
string='Reference', readonly=True,
|
||||
reference = fields.Many2One(string='Reference', readonly=True, select=True,
|
||||
states={
|
||||
'invisible': ~Bool(Eval('reference')),
|
||||
}, model_name='cashbook.line', ondelete='CASCADE',
|
||||
help='The current row was created by and is controlled ' +
|
||||
'by the reference row.')
|
||||
references = fields.One2Many(
|
||||
string='References',
|
||||
help='The current row was created by and is controlled by the reference row.')
|
||||
references = fields.One2Many(string='References',
|
||||
model_name='cashbook.line',
|
||||
help='The rows are created and managed by the current record.',
|
||||
states={
|
||||
'invisible': ~Bool(Eval('references')),
|
||||
}, field='reference', readonly=True)
|
||||
splitlines = fields.One2Many(
|
||||
string='Split booking lines',
|
||||
splitlines = fields.One2Many(string='Split booking lines',
|
||||
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={
|
||||
'invisible': ~Eval('bookingtype' '').in_(['spin', 'spout']),
|
||||
'readonly': Or(
|
||||
|
@ -172,43 +150,37 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
'required': Eval('bookingtype' '').in_(['spin', 'spout']),
|
||||
}, field='line', depends=DEPENDS+['bookingtype'])
|
||||
|
||||
reconciliation = fields.Many2One(
|
||||
string='Reconciliation', readonly=True,
|
||||
reconciliation = fields.Many2One(string='Reconciliation', readonly=True,
|
||||
model_name='cashbook.recon', ondelete='SET NULL',
|
||||
domain=[('cashbook.id', '=', Eval('cashbook', -1))],
|
||||
domain=[('cashbook.id', '=', Eval('cashbook'))],
|
||||
depends=['cashbook'],
|
||||
states={
|
||||
'invisible': ~Bool(Eval('reconciliation')),
|
||||
})
|
||||
|
||||
balance = fields.Function(fields.Numeric(
|
||||
string='Balance',
|
||||
balance = fields.Function(fields.Numeric(string='Balance',
|
||||
digits=(16, Eval('currency_digits', 2)),
|
||||
help='Balance of the cash book up to the current line, ' +
|
||||
'if the default sorting applies.',
|
||||
help='Balance of the cash book up to the current line, if the default sorting applies.',
|
||||
readonly=True, depends=['currency_digits']),
|
||||
'on_change_with_balance')
|
||||
|
||||
currency = fields.Function(fields.Many2One(
|
||||
model_name='currency.currency',
|
||||
currency = fields.Function(fields.Many2One(model_name='currency.currency',
|
||||
string="Currency", readonly=True), 'on_change_with_currency')
|
||||
currency_digits = fields.Function(fields.Integer(
|
||||
string='Currency Digits',
|
||||
currency_digits = fields.Function(fields.Integer(string='Currency Digits',
|
||||
readonly=True), 'on_change_with_currency_digits')
|
||||
|
||||
state = fields.Selection(
|
||||
string='State', required=True, readonly=True,
|
||||
selection=sel_linestate)
|
||||
state = fields.Selection(string='State', required=True, readonly=True,
|
||||
select=True, selection=sel_linetype)
|
||||
state_string = state.translated('state')
|
||||
state_cashbook = fields.Function(fields.Selection(
|
||||
string='State of Cashbook',
|
||||
state_cashbook = fields.Function(fields.Selection(string='State of Cashbook',
|
||||
readonly=True, states={'invisible': True}, selection=sel_state_book),
|
||||
'on_change_with_state_cashbook', searcher='search_state_cashbook')
|
||||
owner_cashbook = fields.Function(fields.Many2One(
|
||||
string='Owner', readonly=True,
|
||||
owner_cashbook = fields.Function(fields.Many2One(string='Owner', readonly=True,
|
||||
states={'invisible': True}, model_name='res.user'),
|
||||
'on_change_with_owner_cashbook')
|
||||
|
||||
#image = fields.Binary...
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
super(Line, cls).__register__(module_name)
|
||||
|
@ -224,27 +196,6 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
cls._order.insert(0, ('date', 'ASC'))
|
||||
cls._order.insert(0, ('state', 'ASC'))
|
||||
t = cls.__table__()
|
||||
|
||||
cls._sql_indexes.update({
|
||||
Index(
|
||||
t,
|
||||
(t.date, Index.Range(order='ASC'))),
|
||||
Index(
|
||||
t,
|
||||
(t.description, Index.Similarity())),
|
||||
Index(
|
||||
t,
|
||||
(t.category, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.bookingtype, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.state, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.reference, Index.Equality())),
|
||||
})
|
||||
cls._sql_constraints.extend([
|
||||
('state_val2',
|
||||
Check(t, t.state.in_(['edit', 'check', 'done', 'recon'])),
|
||||
|
@ -281,7 +232,8 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
return super().view_attributes() + [
|
||||
('/tree', 'visual',
|
||||
If(Eval('balance', 0) < 0, 'warning',
|
||||
If(Eval('date', Date()) > Date(), 'muted', ''))),
|
||||
If(Eval('date', Date()) > Date(), 'muted', '')
|
||||
)),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
|
@ -297,16 +249,13 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
tab_book2 = Book2.__table__() # transfer-target
|
||||
cursor = Transaction().connection.cursor()
|
||||
|
||||
query = tab_line.join(
|
||||
tab_book,
|
||||
query = tab_line.join(tab_book,
|
||||
condition=tab_line.cashbook == tab_book.id,
|
||||
).join(
|
||||
tab_book2,
|
||||
).join(tab_book2,
|
||||
condition=tab_line.booktransf== tab_book2.id,
|
||||
).select(
|
||||
tab_line.id,
|
||||
where=tab_line.bookingtype.in_(['mvin', 'mvout']) &
|
||||
(tab_line.amount_2nd_currency == DEF_NONE) &
|
||||
).select(tab_line.id,
|
||||
where=tab_line.bookingtype.in_(['mvin', 'mvout']) & \
|
||||
(tab_line.amount_2nd_currency == None) & \
|
||||
(tab_book.currency != tab_book2.currency)
|
||||
)
|
||||
lines = Line2.search([('id', 'in', query)])
|
||||
|
@ -341,18 +290,19 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
to_delete_line = []
|
||||
for line in lines:
|
||||
if line.reference:
|
||||
if Transaction().context.get(
|
||||
'line.allow.wfedit', False) is False:
|
||||
if Transaction().context.get('line.allow.wfedit', False) == False:
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_line_denywf_by_reference',
|
||||
recname = line.reference.rec_name,
|
||||
cbook=line.reference.cashbook.rec_name))
|
||||
cbook = line.reference.cashbook.rec_name,
|
||||
))
|
||||
# delete references
|
||||
to_delete_line.extend(list(line.references))
|
||||
|
||||
if len(to_delete_line) > 0:
|
||||
with Transaction().set_context({
|
||||
'line.allow.wfedit': True}):
|
||||
'line.allow.wfedit': True,
|
||||
}):
|
||||
Line2.wfedit(to_delete_line)
|
||||
Line2.delete(to_delete_line)
|
||||
|
||||
|
@ -373,9 +323,10 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
# allow cashbook-line at range-limits
|
||||
if Recon.search_count([
|
||||
('state', 'in', ['check', 'done']),
|
||||
('cashbook', '=', line.cashbook.id),
|
||||
('cashbook.id', '=', line.cashbook.id),
|
||||
('date_from', '<', line.date),
|
||||
('date_to', '>', line.date)]) > 0:
|
||||
('date_to', '>', line.date),
|
||||
]) > 0:
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_line_err_write_to_reconciled',
|
||||
datetxt = Report.format_date(line.date),
|
||||
|
@ -384,10 +335,12 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
# reconciliations exist
|
||||
if Recon.search_count([
|
||||
('state', 'in', ['check', 'done']),
|
||||
('cashbook', '=', line.cashbook.id),
|
||||
('cashbook.id', '=', line.cashbook.id),
|
||||
['OR',
|
||||
('date_from', '=', line.date),
|
||||
('date_to', '=', line.date)]]) > 1:
|
||||
('date_to', '=', line.date),
|
||||
]
|
||||
]) > 1:
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_line_err_write_to_reconciled',
|
||||
datetxt = Report.format_date(line.date),
|
||||
|
@ -405,28 +358,25 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
if sp_line.splittype != 'tr':
|
||||
continue
|
||||
|
||||
values = cls.get_counterpart_values(
|
||||
line, splitline=sp_line,
|
||||
values = cls.get_counterpart_values(line,
|
||||
splitline = sp_line,
|
||||
values = {
|
||||
'cashbook': sp_line.booktransf.id,
|
||||
'description': sp_line.description,
|
||||
'amount': sp_line.amount
|
||||
if sp_line.currency.id == sp_line.
|
||||
booktransf.currency.id
|
||||
'amount': sp_line.amount \
|
||||
if sp_line.currency.id == sp_line.booktransf.currency.id \
|
||||
else sp_line.amount_2nd_currency,
|
||||
'amount_2nd_currency': sp_line.amount
|
||||
if sp_line.currency.id != sp_line.
|
||||
booktransf.currency.id
|
||||
'amount_2nd_currency': sp_line.amount \
|
||||
if sp_line.currency.id != sp_line.booktransf.currency.id \
|
||||
else None,
|
||||
'bookingtype': 'mvin'
|
||||
if line.bookingtype.endswith('out')
|
||||
else 'mvout',
|
||||
'bookingtype': 'mvin' \
|
||||
if line.bookingtype.endswith('out') else 'mvout',
|
||||
})
|
||||
values.update(cls.get_debit_credit(values))
|
||||
to_create_line.append(values)
|
||||
|
||||
# add number to line
|
||||
if line.cashbook.number_atcheck is True:
|
||||
if line.cashbook.number_atcheck == True:
|
||||
if len(line.number or '') == 0:
|
||||
to_write_line.extend([
|
||||
[line],
|
||||
|
@ -506,20 +456,16 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
"""
|
||||
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')
|
||||
return '|'.join([
|
||||
Report.format_date(self.date),
|
||||
gettext('cashbook.msg_line_bookingtype_%s' % self.bookingtype),
|
||||
'%(amount)s %(symbol)s' % {
|
||||
'amount': Report.format_number(
|
||||
credit - debit, None,
|
||||
digits=getattr(self.currency, 'digits', 2)),
|
||||
'symbol': getattr(self.currency, 'symbol', '-')},
|
||||
'%(desc)s [%(category)s]' % {
|
||||
return '%(date)s|%(type)s|%(amount)s %(symbol)s|%(desc)s [%(category)s]' % {
|
||||
'date': Report.format_date(self.date),
|
||||
'desc': (self.description or '-')[:40],
|
||||
'category': self.category_view
|
||||
if self.bookingtype in ['in', 'out']
|
||||
else getattr(self.booktransf, 'rec_name', '-')},
|
||||
])
|
||||
'amount': Report.format_number(credit - debit, None),
|
||||
'symbol': getattr(self.currency, 'symbol', '-'),
|
||||
'category': self.category_view \
|
||||
if self.bookingtype in ['in', 'out'] \
|
||||
else getattr(self.booktransf, 'rec_name', '-'),
|
||||
'type': gettext('cashbook.msg_line_bookingtype_%s' % self.bookingtype),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def order_state(tables):
|
||||
|
@ -534,7 +480,8 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
(tab_line.state == 'edit', 1),
|
||||
(tab_line.state.in_(['check', 'recon', 'done']), 0),
|
||||
else_ = 2),
|
||||
where=tab_line.id == table.id)
|
||||
where=tab_line.id==table.id
|
||||
)
|
||||
return [query]
|
||||
|
||||
@staticmethod
|
||||
|
@ -545,9 +492,10 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
Category = Pool().get('cashbook.category')
|
||||
tab_cat = Category.__table__()
|
||||
|
||||
tab2 = tab_cat.select(
|
||||
tab_cat.name,
|
||||
where=tab_cat.id == table.category)
|
||||
tab2 = tab_cat.select(tab_cat.name,
|
||||
where=tab_cat.id==table.category
|
||||
)
|
||||
|
||||
return [tab2]
|
||||
|
||||
@staticmethod
|
||||
|
@ -563,7 +511,8 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
"""
|
||||
return ['OR',
|
||||
('party.rec_name',) + tuple(clause[1:]),
|
||||
('booktransf.rec_name',) + tuple(clause[1:])]
|
||||
('booktransf.rec_name',) + tuple(clause[1:]),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def search_category_view(cls, name, clause):
|
||||
|
@ -582,12 +531,10 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
Operator = fields.SQL_OPERATORS[clause[1]]
|
||||
|
||||
dt1 = IrDate.today()
|
||||
query = tab_line.select(
|
||||
tab_line.id,
|
||||
query = tab_line.select(tab_line.id,
|
||||
where=Operator(
|
||||
Literal(12 * dt1.year + dt1.month) -
|
||||
(Literal(12) * DatePart('year', tab_line.date) +
|
||||
DatePart('month', tab_line.date)),
|
||||
Literal(12 * dt1.year + dt1.month) - \
|
||||
(Literal(12) * DatePart('year', tab_line.date) + DatePart('month', tab_line.date)),
|
||||
clause[2]),
|
||||
)
|
||||
return [('id', 'in', query)]
|
||||
|
@ -608,11 +555,9 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
def on_change_splitlines(self):
|
||||
""" update amount if splitlines change
|
||||
"""
|
||||
self.amount = sum([
|
||||
x.amount for x in self.splitlines if x.amount is not None])
|
||||
self.amount = sum([x.amount for x in self.splitlines if x.amount is not None])
|
||||
|
||||
@fields.depends(
|
||||
'bookingtype', 'category', 'splitlines', 'booktransf',
|
||||
@fields.depends('bookingtype', 'category', 'splitlines', 'booktransf',\
|
||||
'currency2nd')
|
||||
def on_change_bookingtype(self):
|
||||
""" clear category if not valid type
|
||||
|
@ -624,16 +569,14 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
|
||||
if self.bookingtype:
|
||||
if self.category:
|
||||
if self.bookingtype not in types.get(
|
||||
self.category.cattype, ''):
|
||||
if not self.bookingtype in types.get(self.category.cattype, ''):
|
||||
self.category = None
|
||||
|
||||
if self.bookingtype.startswith('sp'): # split booking
|
||||
self.category = None
|
||||
self.booktransf = None
|
||||
for spline in self.splitlines:
|
||||
if self.bookingtype not in types.get(
|
||||
getattr(spline.category, 'cattype', '-'), ''):
|
||||
if not self.bookingtype in types.get(getattr(spline.category, 'cattype', '-'), ''):
|
||||
spline.category = None
|
||||
elif self.bookingtype.startswith('mv'): # transfer
|
||||
self.splitlines = []
|
||||
|
@ -679,14 +622,14 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
|
||||
@fields.depends('category')
|
||||
def on_change_with_category_view(self, name=None):
|
||||
""" show optimized form of category for list-view
|
||||
""" show optimizef form of category for list-view
|
||||
"""
|
||||
Configuration = Pool().get('cashbook.configuration')
|
||||
|
||||
if self.category:
|
||||
cfg1 = Configuration.get_singleton()
|
||||
|
||||
if getattr(cfg1, 'catnamelong', True) is True:
|
||||
if getattr(cfg1, 'catnamelong', True) == True:
|
||||
return self.category.rec_name
|
||||
else :
|
||||
return self.category.name
|
||||
|
@ -732,9 +675,7 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
return 2
|
||||
|
||||
@classmethod
|
||||
def get_balance_of_line(
|
||||
cls, line, field_name='amount', credit_name='credit',
|
||||
debit_name='debit'):
|
||||
def get_balance_of_line(cls, line, field_name='amount', credit_name='credit', debit_name='debit'):
|
||||
""" get balance of current line,
|
||||
try to speed up by usage of last reconcilitaion
|
||||
"""
|
||||
|
@ -750,7 +691,7 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
end_value = None
|
||||
|
||||
recons = Reconciliation.search([
|
||||
('cashbook', '=', line.cashbook.id),
|
||||
('cashbook.id', '=', line.cashbook.id),
|
||||
('date_to', '<=', line2.date),
|
||||
('state', '=', 'done'),
|
||||
], order=[('date_from', 'DESC')], limit=1)
|
||||
|
@ -760,14 +701,15 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
('date', '<=', line2.date),
|
||||
['OR',
|
||||
('reconciliation', '=', None),
|
||||
('reconciliation', '!=', recons[0])],
|
||||
('reconciliation.id', '!=', recons[0]),
|
||||
],
|
||||
])
|
||||
end_value = getattr(recons[0], 'end_%s' % field_name)
|
||||
return (query2, end_value)
|
||||
|
||||
if line.cashbook:
|
||||
query = [
|
||||
('cashbook', '=', line.cashbook.id),
|
||||
('cashbook.id', '=', line.cashbook.id),
|
||||
]
|
||||
balance = Decimal('0.0')
|
||||
|
||||
|
@ -777,10 +719,9 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
if line.reconciliation:
|
||||
if line.reconciliation.state == 'done':
|
||||
query.append(
|
||||
('reconciliation', '=', line.reconciliation.id),
|
||||
('reconciliation.id', '=', line.reconciliation.id),
|
||||
)
|
||||
balance = getattr(
|
||||
line.reconciliation, 'start_%s' % field_name)
|
||||
balance = getattr(line.reconciliation, 'start_%s' % field_name)
|
||||
else :
|
||||
(query2, balance2) = get_from_last_recon(line)
|
||||
query.extend(query2)
|
||||
|
@ -804,16 +745,18 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
break
|
||||
return balance
|
||||
|
||||
@fields.depends(
|
||||
'id', 'date', 'cashbook', '_parent_cashbook.id', 'reconciliation',
|
||||
'_parent_reconciliation.start_amount', '_parent_reconciliation.state')
|
||||
@fields.depends('id', 'date', 'cashbook', \
|
||||
'_parent_cashbook.id', 'reconciliation', \
|
||||
'_parent_reconciliation.start_amount',\
|
||||
'_parent_reconciliation.state')
|
||||
def on_change_with_balance(self, name=None):
|
||||
""" compute balance until current line, with current sort order,
|
||||
try to use a reconciliation as start to speed up calculation
|
||||
"""
|
||||
Line2 = Pool().get('cashbook.line')
|
||||
return Line2.get_balance_of_line(
|
||||
self, field_name='amount', credit_name='credit',
|
||||
return Line2.get_balance_of_line(self,
|
||||
field_name='amount',
|
||||
credit_name='credit',
|
||||
debit_name='debit')
|
||||
|
||||
@classmethod
|
||||
|
@ -823,14 +766,12 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
values2 = {}
|
||||
values2.update(values)
|
||||
|
||||
bookingtype = values2.get(
|
||||
'bookingtype', getattr(line, 'bookingtype', None))
|
||||
bookingtype = values2.get('bookingtype', getattr(line, 'bookingtype', None))
|
||||
if (bookingtype in ['in', 'out', 'mvin', 'mvout']) and \
|
||||
('splitlines' not in values2.keys()):
|
||||
if line:
|
||||
if len(line.splitlines) > 0:
|
||||
values2['splitlines'] = [
|
||||
('delete', [x.id for x in line.splitlines])]
|
||||
values2['splitlines'] = [('delete', [x.id for x in line.splitlines])]
|
||||
|
||||
if bookingtype in ['in', 'out']:
|
||||
values2['booktransf'] = None
|
||||
|
@ -849,8 +790,7 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
transfer booking
|
||||
"""
|
||||
line_currency = getattr(line.currency, 'id', None)
|
||||
booktransf_currency = getattr(getattr(
|
||||
line.booktransf, 'currency', {}), 'id', None)
|
||||
booktransf_currency = getattr(getattr(line.booktransf, 'currency', {}), 'id', None)
|
||||
|
||||
result = {
|
||||
'cashbook': getattr(line.booktransf, 'id', None),
|
||||
|
@ -859,11 +799,13 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
'description': line.description,
|
||||
'booktransf': line.cashbook.id,
|
||||
'reference': line.id,
|
||||
'amount': line.amount
|
||||
if line_currency == booktransf_currency
|
||||
'amount': line.amount \
|
||||
if line_currency == booktransf_currency \
|
||||
else line.amount_2nd_currency,
|
||||
'amount_2nd_currency': line.amount
|
||||
if line_currency != booktransf_currency else None}
|
||||
'amount_2nd_currency': line.amount \
|
||||
if line_currency != booktransf_currency \
|
||||
else None,
|
||||
}
|
||||
# update values from 'values'
|
||||
result.update(values)
|
||||
return result
|
||||
|
@ -873,12 +815,10 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
""" compute debit/credit from amount
|
||||
"""
|
||||
if isinstance(values, dict):
|
||||
type_ = values.get(
|
||||
'bookingtype', getattr(line, 'bookingtype', None))
|
||||
type_ = values.get('bookingtype', getattr(line, 'bookingtype', None))
|
||||
amount = values.get('amount', None)
|
||||
else :
|
||||
type_ = getattr(
|
||||
values, 'bookingtype', getattr(line, 'bookingtype', None))
|
||||
type_ = getattr(values, 'bookingtype', getattr(line, 'bookingtype', None))
|
||||
amount = getattr(values, 'amount', None)
|
||||
|
||||
result = {}
|
||||
|
@ -886,10 +826,14 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
if amount is not None:
|
||||
if type_ in ['in', 'mvin', 'spin']:
|
||||
result.update({
|
||||
'debit': Decimal('0.0'), 'credit': amount})
|
||||
'debit': Decimal('0.0'),
|
||||
'credit': amount,
|
||||
})
|
||||
elif type_ in ['out', 'mvout', 'spout']:
|
||||
result.update({
|
||||
'debit': amount, 'credit': Decimal('0.0')})
|
||||
'debit': amount,
|
||||
'credit': Decimal('0.0'),
|
||||
})
|
||||
else :
|
||||
raise ValueError('invalid "bookingtype"')
|
||||
return result
|
||||
|
@ -910,26 +854,29 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
raise UserError(gettext(
|
||||
'cashbook.msg_line_date_before_book',
|
||||
datebook = Report.format_date(line.cashbook.start_date),
|
||||
recname=line.rec_name))
|
||||
recname = line.rec_name,
|
||||
))
|
||||
|
||||
# line: category <--> bookingtype?
|
||||
if line.category:
|
||||
if line.bookingtype not in types[line.category.cattype]:
|
||||
if not line.bookingtype in types[line.category.cattype]:
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_line_invalid_category',
|
||||
recname = line.rec_name,
|
||||
booktype=line.bookingtype_string))
|
||||
booktype = line.bookingtype_string,
|
||||
))
|
||||
|
||||
# splitline: category <--> bookingtype?
|
||||
for spline in line.splitlines:
|
||||
if spline.splittype != 'cat':
|
||||
continue
|
||||
if line.bookingtype not in types[spline.category.cattype]:
|
||||
if not line.bookingtype in types[spline.category.cattype]:
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_line_split_invalid_category',
|
||||
recname = line.rec_name,
|
||||
splitrecname = spline.rec_name,
|
||||
booktype=line.bookingtype_string))
|
||||
booktype = line.bookingtype_string,
|
||||
))
|
||||
|
||||
@classmethod
|
||||
def check_permission_write(cls, lines, values={}):
|
||||
|
@ -941,7 +888,8 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
raise UserError(gettext(
|
||||
'cashbook.msg_book_deny_write',
|
||||
bookname = line.cashbook.rec_name,
|
||||
state_txt=line.cashbook.state_string))
|
||||
state_txt = line.cashbook.state_string,
|
||||
))
|
||||
|
||||
# deny write if reconciliation is 'check' or 'done'
|
||||
if line.reconciliation:
|
||||
|
@ -949,19 +897,19 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
raise UserError(gettext(
|
||||
'cashbook.msg_line_deny_write_by_reconciliation',
|
||||
recname = line.rec_name,
|
||||
reconame=line.reconciliation.rec_name))
|
||||
reconame = line.reconciliation.rec_name,
|
||||
))
|
||||
|
||||
# deny write if line is not 'Edit'
|
||||
if line.state != 'edit':
|
||||
# allow state-update, if its the only action
|
||||
if not ((len(set({
|
||||
'state', 'reconciliation', 'number'
|
||||
}).intersection(values.keys())) > 0)
|
||||
if not ((len(set({'state', 'reconciliation', 'number'}).intersection(values.keys())) > 0) \
|
||||
and (len(values.keys()) == 1)):
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_line_deny_write',
|
||||
recname = line.rec_name,
|
||||
state_txt=line.state_string))
|
||||
state_txt = line.state_string,
|
||||
))
|
||||
|
||||
@classmethod
|
||||
def check_permission_delete(cls, lines):
|
||||
|
@ -973,12 +921,14 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
'cashbook.msg_line_deny_delete1',
|
||||
linetxt = line.rec_name,
|
||||
bookname = line.cashbook.rec_name,
|
||||
bookstate=line.cashbook.state_string))
|
||||
bookstate = line.cashbook.state_string,
|
||||
))
|
||||
if line.state != 'edit':
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_line_deny_delete2',
|
||||
linetxt = line.rec_name,
|
||||
linestate=line.state_string))
|
||||
linestate = line.state_string,
|
||||
))
|
||||
|
||||
@classmethod
|
||||
def update_values_by_splitlines(cls, lines):
|
||||
|
@ -988,7 +938,7 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
for line in lines:
|
||||
amount = sum([x.amount for x in line.splitlines])
|
||||
if amount != line.amount:
|
||||
to_write.extend([[line], {'amount': amount}])
|
||||
to_write.extend([ [line], {'amount': amount,} ])
|
||||
return to_write
|
||||
|
||||
@classmethod
|
||||
|
@ -998,8 +948,7 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
if ('splitlines' in values.keys()) and ('amount' not in values.keys()):
|
||||
for action in values['splitlines']:
|
||||
if action[0] == 'create':
|
||||
values['amount'] = sum([
|
||||
x.get('amount', None) for x in action[1]])
|
||||
values['amount'] = sum([x.get('amount', None) for x in action[1]])
|
||||
return values
|
||||
|
||||
@classmethod
|
||||
|
@ -1009,8 +958,7 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
Cashbook = Pool().get('cashbook.book')
|
||||
cashbook = values.get('cashbook', None)
|
||||
if cashbook:
|
||||
values.update(cls.add_2nd_currency(
|
||||
values, Cashbook(cashbook).currency))
|
||||
values.update(cls.add_2nd_currency(values, Cashbook(cashbook).currency))
|
||||
return values
|
||||
|
||||
@classmethod
|
||||
|
@ -1029,14 +977,12 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
default = default.copy()
|
||||
default.setdefault('number', None)
|
||||
default.setdefault('state', cls.default_state())
|
||||
return super(Line, cls).copy(lines, default=default)
|
||||
return super(Line, cls).copy(moves, default=default)
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
""" add debit/credit
|
||||
"""
|
||||
ValueStore = Pool().get('cashbook.values')
|
||||
|
||||
vlist = [x.copy() for x in vlist]
|
||||
for values in vlist:
|
||||
values.update(cls.add_values_from_splitlines(values))
|
||||
|
@ -1044,8 +990,7 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
values.update(cls.clear_by_bookingtype(values))
|
||||
values.update(cls.add_2nd_unit_values(values))
|
||||
|
||||
# deny add to reconciliation if state is
|
||||
# not 'check', 'recon' or 'done'
|
||||
# deny add to reconciliation if state is not 'check', 'recon' or 'done'
|
||||
if values.get('reconciliation', None):
|
||||
if not values.get('state', '-') in ['check', 'done', 'recon']:
|
||||
date_txt = '-'
|
||||
|
@ -1055,44 +1000,38 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
'cashbook.msg_line_deny_recon_by_state',
|
||||
recname = '%(date)s|%(descr)s' % {
|
||||
'date': date_txt,
|
||||
'descr': values.get('description', '-')}))
|
||||
records = super(Line, cls).create(vlist)
|
||||
|
||||
if records:
|
||||
ValueStore.update_books(ValueStore.get_book_by_line(records))
|
||||
return records
|
||||
'descr': values.get('description', '-'),
|
||||
},
|
||||
))
|
||||
return super(Line, cls).create(vlist)
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
""" deny update if cashbook.line!='open',
|
||||
add or update debit/credit
|
||||
"""
|
||||
ValueStore = Pool().get('cashbook.values')
|
||||
|
||||
actions = iter(args)
|
||||
to_write = []
|
||||
to_update = []
|
||||
for lines, values in zip(actions, actions):
|
||||
cls.check_permission_write(lines, values)
|
||||
|
||||
to_update.extend(lines)
|
||||
for line in lines:
|
||||
if line.reconciliation:
|
||||
# deny state-change to 'edit' if line is
|
||||
# linked to reconciliation
|
||||
# deny state-change to 'edit' if line is linked to reconciliation
|
||||
if values.get('state', '-') == 'edit':
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_line_deny_stateedit_with_recon',
|
||||
recname=line.rec_name))
|
||||
recname = line.rec_name,
|
||||
))
|
||||
|
||||
# deny add to reconciliation if state is
|
||||
# not 'check', 'recon' or 'done'
|
||||
# deny add to reconciliation if state is not 'check', 'recon' or 'done'
|
||||
if values.get('reconciliation', None):
|
||||
for line in lines:
|
||||
if line.state not in ['check', 'done', 'recon']:
|
||||
if not line.state in ['check', 'done', 'recon']:
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_line_deny_recon_by_state',
|
||||
recname=line.rec_name))
|
||||
recname = line.rec_name
|
||||
))
|
||||
|
||||
# update debit / credit
|
||||
fields_update = cls.get_fields_write_update()
|
||||
|
@ -1106,32 +1045,23 @@ class Line(SecondCurrencyMixin, Workflow, ModelSQL, ModelView):
|
|||
updt_fields = []
|
||||
updt_fields.extend(values.keys())
|
||||
if 'bookingtype' in values.keys():
|
||||
updt_fields.extend([
|
||||
x for x in fields_update
|
||||
if x not in values.keys()])
|
||||
updt_fields.extend([x for x in fields_update if x not in values.keys()])
|
||||
|
||||
values2.update(cls.get_debit_credit({
|
||||
x: values.get(x, getattr(line, x))
|
||||
for x in updt_fields}, line=line))
|
||||
x:values.get(x, getattr(line, x)) for x in updt_fields
|
||||
}, line=line))
|
||||
to_write.extend([lines, values2])
|
||||
else :
|
||||
to_write.extend([lines, values])
|
||||
|
||||
super(Line, cls).write(*to_write)
|
||||
|
||||
if to_update:
|
||||
ValueStore.update_books(ValueStore.get_book_by_line(to_update))
|
||||
|
||||
@classmethod
|
||||
def delete(cls, lines):
|
||||
""" deny delete if book is not 'open' or wf is not 'edit'
|
||||
"""
|
||||
ValueStore = Pool().get('cashbook.values')
|
||||
|
||||
cls.check_permission_delete(lines)
|
||||
to_update = ValueStore.get_book_by_line(lines)
|
||||
super(Line, cls).delete(lines)
|
||||
ValueStore.update_books(to_update)
|
||||
|
||||
# end Line
|
||||
|
||||
|
@ -1140,27 +1070,23 @@ class LineContext(ModelView):
|
|||
'Line Context'
|
||||
__name__ = 'cashbook.line.context'
|
||||
|
||||
date_from = fields.Date(
|
||||
string='Start Date', depends=['date_to'],
|
||||
date_from = fields.Date(string='Start Date', depends=['date_to'],
|
||||
help='Limits the date range for the displayed entries.',
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
()),
|
||||
])
|
||||
date_to = fields.Date(
|
||||
string='End Date', depends=['date_from'],
|
||||
date_to = fields.Date(string='End Date', depends=['date_from'],
|
||||
help='Limits the date range for the displayed entries.',
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
('date_from', '<=', Eval('date_to')),
|
||||
()),
|
||||
])
|
||||
checked = fields.Boolean(
|
||||
string='Checked',
|
||||
checked = fields.Boolean(string='Checked',
|
||||
help='Show account lines in Checked-state.')
|
||||
done = fields.Boolean(
|
||||
string='Done',
|
||||
done = fields.Boolean(string='Done',
|
||||
help='Show account lines in Done-state.')
|
||||
|
||||
@classmethod
|
||||
|
|
6
line.xml
6
line.xml
|
@ -145,8 +145,8 @@ full copyright notices and license terms. -->
|
|||
</record>
|
||||
<record model="ir.rule" id="rg_line_write-1">
|
||||
<field name="domain" eval="['OR',
|
||||
('cashbook.owner.id', '=', Eval('user_id', -1)),
|
||||
('cashbook.reviewer.id', 'in', Eval('groups', [])),
|
||||
('cashbook.owner.id', '=', Eval('user', {}).get('id', -1)),
|
||||
('cashbook.reviewer.id', 'in', Eval('user', {}).get('groups', [])),
|
||||
]" pyson="1"/>
|
||||
<field name="rule_group" ref="rg_line_write"/>
|
||||
</record>
|
||||
|
@ -168,7 +168,7 @@ full copyright notices and license terms. -->
|
|||
</record>
|
||||
<record model="ir.rule" id="rg_line_read-1">
|
||||
<field name="domain" eval="[
|
||||
('cashbook.observer.id', 'in', Eval('groups', [])),
|
||||
('cashbook.observer.id', 'in', Eval('user', {}).get('groups', [])),
|
||||
]" pyson="1"/>
|
||||
<field name="rule_group" ref="rg_line_read"/>
|
||||
</record>
|
||||
|
|
84
locale/de.po
84
locale/de.po
|
@ -3,14 +3,6 @@ msgid ""
|
|||
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 #
|
||||
##############
|
||||
|
@ -166,14 +158,6 @@ msgctxt "model:ir.message,text:msg_btype_general"
|
|||
msgid "General"
|
||||
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 #
|
||||
|
@ -466,6 +450,10 @@ msgctxt "view:cashbook.book:"
|
|||
msgid "Amount and Numbering"
|
||||
msgstr "Betrag und Nummerierung"
|
||||
|
||||
msgctxt "view:cashbook.book:"
|
||||
msgid "Balance"
|
||||
msgstr "Saldo"
|
||||
|
||||
msgctxt "view:cashbook.book:"
|
||||
msgid "Reconciliations"
|
||||
msgstr "Abstimmungen"
|
||||
|
@ -614,10 +602,6 @@ msgctxt "field:cashbook.book,booktransf_feature:"
|
|||
msgid "Feature"
|
||||
msgstr "Merkmal"
|
||||
|
||||
msgctxt "field:cashbook.book,value_store:"
|
||||
msgid "Values"
|
||||
msgstr "Werte"
|
||||
|
||||
|
||||
##################
|
||||
# cashbook.split #
|
||||
|
@ -790,6 +774,14 @@ msgctxt "model:cashbook.line,name:"
|
|||
msgid "Cashbook Line"
|
||||
msgstr "Kassenbuchzeile"
|
||||
|
||||
msgctxt "view:cashbook.line:"
|
||||
msgid "Credit"
|
||||
msgstr "Einnahme"
|
||||
|
||||
msgctxt "view:cashbook.line:"
|
||||
msgid "Debit"
|
||||
msgstr "Ausgabe"
|
||||
|
||||
msgctxt "view:cashbook.line:"
|
||||
msgid "Cashbook Line"
|
||||
msgstr "Kassenbuchzeile"
|
||||
|
@ -1258,14 +1250,6 @@ msgctxt "help:cashbook.configuration,book5:"
|
|||
msgid "Cash book available in selection dialog."
|
||||
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:"
|
||||
msgid "Start Date"
|
||||
msgstr "Beginndatum"
|
||||
|
@ -1386,14 +1370,6 @@ msgctxt "help:cashbook.configuration_user,book5:"
|
|||
msgid "Cash book available in selection dialog."
|
||||
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 #
|
||||
|
@ -1662,18 +1638,6 @@ msgctxt "field:cashbook.enterbooking.start,party:"
|
|||
msgid "Party"
|
||||
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 #
|
||||
|
@ -1693,27 +1657,3 @@ msgstr "Speichern"
|
|||
msgctxt "wizard_button:cashbook.enterbooking,start,savenext_:"
|
||||
msgid "Save & Next"
|
||||
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,10 +2,6 @@
|
|||
msgid ""
|
||||
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"
|
||||
msgid "The Abbreviation must be unique."
|
||||
msgstr "The Abbreviation must be unique."
|
||||
|
@ -158,14 +154,6 @@ msgctxt "model:ir.message,text:msg_btype_general"
|
|||
msgid "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"
|
||||
msgid "Cashbook"
|
||||
msgstr "Cashbook"
|
||||
|
@ -426,6 +414,10 @@ msgctxt "view:cashbook.book:"
|
|||
msgid "Amount and Numbering"
|
||||
msgstr "Amount and Numbering"
|
||||
|
||||
msgctxt "view:cashbook.book:"
|
||||
msgid "Balance"
|
||||
msgstr "Balance"
|
||||
|
||||
msgctxt "view:cashbook.book:"
|
||||
msgid "Reconciliations"
|
||||
msgstr "Reconciliations"
|
||||
|
@ -574,10 +566,6 @@ msgctxt "field:cashbook.book,booktransf_feature:"
|
|||
msgid "Feature"
|
||||
msgstr "Feature"
|
||||
|
||||
msgctxt "field:cashbook.book,value_store:"
|
||||
msgid "Values"
|
||||
msgstr "Values"
|
||||
|
||||
msgctxt "model:cashbook.split,name:"
|
||||
msgid "Split booking line"
|
||||
msgstr "Split booking line"
|
||||
|
@ -742,6 +730,14 @@ msgctxt "model:cashbook.line,name:"
|
|||
msgid "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:"
|
||||
msgid "Cashbook Line"
|
||||
msgstr "Cashbook Line"
|
||||
|
@ -1186,14 +1182,6 @@ msgctxt "help:cashbook.configuration,book5:"
|
|||
msgid "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:"
|
||||
msgid "Start Date"
|
||||
msgstr "Start Date"
|
||||
|
@ -1310,14 +1298,6 @@ msgctxt "help:cashbook.configuration_user,book5:"
|
|||
msgid "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:"
|
||||
msgid "Cashbook Reconciliation"
|
||||
msgstr "Cashbook Reconciliation"
|
||||
|
@ -1570,18 +1550,6 @@ msgctxt "field:cashbook.enterbooking.start,party:"
|
|||
msgid "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:"
|
||||
msgid "Enter Booking"
|
||||
msgstr "Enter Booking"
|
||||
|
@ -1594,23 +1562,3 @@ msgctxt "wizard_button:cashbook.enterbooking,start,save_:"
|
|||
msgid "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,12 +119,6 @@ full copyright notices and license terms. -->
|
|||
<record model="ir.message" id="msg_btype_general">
|
||||
<field name="text">General</field>
|
||||
</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>
|
||||
</tryton>
|
||||
|
|
57
mixin.py
57
mixin.py
|
@ -10,7 +10,6 @@ from trytond.modules.currency.ir import rate_decimal
|
|||
from trytond.transaction import Transaction
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
STATES = {
|
||||
'readonly': Or(
|
||||
Eval('state', '') != 'edit',
|
||||
|
@ -23,37 +22,32 @@ DEPENDS = ['state', 'state_cashbook']
|
|||
class SecondCurrencyMixin:
|
||||
""" two fields for 2nd currency: amount + rate
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
amount_2nd_currency = fields.Numeric(
|
||||
string='Amount Second Currency',
|
||||
amount_2nd_currency = fields.Numeric(string='Amount Second Currency',
|
||||
digits=(16, Eval('currency2nd_digits', 2)),
|
||||
states={
|
||||
'readonly': Or(
|
||||
STATES['readonly'],
|
||||
~Bool(Eval('currency2nd'))),
|
||||
~Bool(Eval('currency2nd'))
|
||||
),
|
||||
'required': Bool(Eval('currency2nd')),
|
||||
'invisible': ~Bool(Eval('currency2nd')),
|
||||
}, depends=DEPENDS+['currency2nd_digits', 'currency2nd'])
|
||||
rate_2nd_currency = fields.Function(fields.Numeric(
|
||||
string='Rate',
|
||||
help='Exchange rate between the currencies of the ' +
|
||||
'participating cashbooks.',
|
||||
rate_2nd_currency = fields.Function(fields.Numeric(string='Rate',
|
||||
help='Exchange rate between the currencies of the participating cashbooks.',
|
||||
digits=(rate_decimal * 2, rate_decimal),
|
||||
states={
|
||||
'readonly': Or(
|
||||
STATES['readonly'],
|
||||
~Bool(Eval('currency2nd'))),
|
||||
~Bool(Eval('currency2nd'))
|
||||
),
|
||||
'required': Bool(Eval('currency2nd')),
|
||||
'invisible': ~Bool(Eval('currency2nd')),
|
||||
}, depends=DEPENDS+['currency2nd_digits', 'currency2nd']),
|
||||
'on_change_with_rate_2nd_currency', setter='set_rate_2nd_currency')
|
||||
|
||||
currency2nd = fields.Function(fields.Many2One(
|
||||
model_name='currency.currency',
|
||||
currency2nd = fields.Function(fields.Many2One(model_name='currency.currency',
|
||||
string="2nd Currency", readonly=True), 'on_change_with_currency2nd')
|
||||
currency2nd_digits = fields.Function(fields.Integer(
|
||||
string='2nd Currency Digits',
|
||||
currency2nd_digits = fields.Function(fields.Integer(string='2nd Currency Digits',
|
||||
readonly=True), 'on_change_with_currency2nd_digits')
|
||||
|
||||
@classmethod
|
||||
|
@ -74,7 +68,8 @@ class SecondCurrencyMixin:
|
|||
booktransf = Cashbook(booktransf)
|
||||
if from_currency.id != booktransf.currency.id:
|
||||
with Transaction().set_context({
|
||||
'date': values.get('date', IrDate.today())}):
|
||||
'date': values.get('date', IrDate.today()),
|
||||
}):
|
||||
values['amount_2nd_currency'] = Currency.compute(
|
||||
from_currency,
|
||||
amount,
|
||||
|
@ -82,28 +77,22 @@ class SecondCurrencyMixin:
|
|||
)
|
||||
return values
|
||||
|
||||
@fields.depends(
|
||||
'booktransf', '_parent_booktransf.currency',
|
||||
'currency', 'amount', 'date', 'amount_2nd_currency',
|
||||
'rate_2nd_currency')
|
||||
@fields.depends('booktransf', '_parent_booktransf.currency', \
|
||||
'currency', 'amount', 'date', 'amount_2nd_currency', 'rate_2nd_currency')
|
||||
def on_change_booktransf(self):
|
||||
""" update amount_2nd_currency
|
||||
"""
|
||||
self.on_change_rate_2nd_currency()
|
||||
|
||||
@fields.depends(
|
||||
'booktransf', '_parent_booktransf.currency',
|
||||
'currency', 'amount', 'date', 'amount_2nd_currency',
|
||||
'rate_2nd_currency')
|
||||
@fields.depends('booktransf', '_parent_booktransf.currency', \
|
||||
'currency', 'amount', 'date', 'amount_2nd_currency', 'rate_2nd_currency')
|
||||
def on_change_amount(self):
|
||||
""" update amount_2nd_currency
|
||||
"""
|
||||
self.on_change_rate_2nd_currency()
|
||||
|
||||
@fields.depends(
|
||||
'booktransf', '_parent_booktransf.currency',
|
||||
'currency', 'amount', 'date', 'amount_2nd_currency',
|
||||
'rate_2nd_currency')
|
||||
@fields.depends('booktransf', '_parent_booktransf.currency', \
|
||||
'currency', 'amount', 'date', 'amount_2nd_currency', 'rate_2nd_currency')
|
||||
def on_change_rate_2nd_currency(self):
|
||||
""" update amount_2nd_currency + rate_2nd_currency
|
||||
"""
|
||||
|
@ -119,17 +108,19 @@ class SecondCurrencyMixin:
|
|||
if self.rate_2nd_currency is None:
|
||||
# no rate set, use current rate of target-currency
|
||||
with Transaction().set_context({
|
||||
'date': self.date or IrDate.today()}):
|
||||
'date': self.date or IrDate.today(),
|
||||
}):
|
||||
self.amount_2nd_currency = Currency.compute(
|
||||
self.currency,
|
||||
self.amount,
|
||||
self.booktransf.currency)
|
||||
self.booktransf.currency
|
||||
)
|
||||
if self.amount != Decimal('0.0'):
|
||||
self.rate_2nd_currency = \
|
||||
self.amount_2nd_currency / self.amount
|
||||
self.rate_2nd_currency = self.amount_2nd_currency / self.amount
|
||||
else :
|
||||
self.amount_2nd_currency = self.booktransf.currency.round(
|
||||
self.amount * self.rate_2nd_currency)
|
||||
self.amount * self.rate_2nd_currency
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def set_rate_2nd_currency(cls, lines, name, value):
|
||||
|
|
36
model.py
36
model.py
|
@ -3,13 +3,11 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.model import (
|
||||
MultiValueMixin, ValueMixin, fields, Unique, Index)
|
||||
from trytond.model import MultiValueMixin, ValueMixin, fields, Unique
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
from sql import With
|
||||
from sql import With, Literal
|
||||
from sql.functions import Function
|
||||
from .const import DEF_NONE
|
||||
|
||||
|
||||
class ArrayAgg(Function):
|
||||
|
@ -20,7 +18,6 @@ class ArrayAgg(Function):
|
|||
|
||||
# end ArrayAgg
|
||||
|
||||
|
||||
class ArrayAppend(Function):
|
||||
""" sql: array_append
|
||||
"""
|
||||
|
@ -75,10 +72,11 @@ def sub_ids_hierarchical(model_name):
|
|||
lines = With('parent', 'id', recursive=True)
|
||||
lines.query = tab_mod.select(
|
||||
tab_mod.id, tab_mod.id,
|
||||
) | tab_mod2.join(
|
||||
lines,
|
||||
) | tab_mod2.join(lines,
|
||||
condition=lines.id==tab_mod2.parent,
|
||||
).select(lines.parent, tab_mod2.id)
|
||||
).select(
|
||||
lines.parent, tab_mod2.id,
|
||||
)
|
||||
lines.query.all_ = True
|
||||
|
||||
query = lines.select(
|
||||
|
@ -101,15 +99,12 @@ def order_name_hierarchical(model_name, tables):
|
|||
lines = With('id', 'name', 'name_path', recursive=True)
|
||||
lines.query = tab_mod.select(
|
||||
tab_mod.id, tab_mod.name, Array(tab_mod.name),
|
||||
where=tab_mod.parent == DEF_NONE,
|
||||
where = tab_mod.parent==None,
|
||||
)
|
||||
lines.query |= tab_mod2.join(
|
||||
lines,
|
||||
lines.query |= tab_mod2.join(lines,
|
||||
condition=lines.id==tab_mod2.parent,
|
||||
).select(
|
||||
tab_mod2.id,
|
||||
tab_mod2.name,
|
||||
ArrayAppend(lines.name_path, tab_mod2.name),
|
||||
tab_mod2.id, tab_mod2.name, ArrayAppend(lines.name_path, tab_mod2.name),
|
||||
)
|
||||
lines.query.all_ = True
|
||||
|
||||
|
@ -121,19 +116,13 @@ def order_name_hierarchical(model_name, tables):
|
|||
|
||||
|
||||
class UserValueMixin(ValueMixin):
|
||||
iduser = fields.Many2One(
|
||||
model_name='res.user', string="User",
|
||||
ondelete='CASCADE', required=True)
|
||||
iduser = fields.Many2One(model_name='res.user', string="User",
|
||||
select=True, ondelete='CASCADE', required=True)
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(UserValueMixin, cls).__setup__()
|
||||
tab_val = cls.__table__()
|
||||
cls._sql_indexes.update({
|
||||
Index(
|
||||
tab_val,
|
||||
(tab_val.iduser, Index.Equality())),
|
||||
})
|
||||
cls._sql_constraints.extend([
|
||||
('val_uniq',
|
||||
Unique(tab_val, tab_val.iduser),
|
||||
|
@ -161,7 +150,6 @@ class UserMultiValueMixin(MultiValueMixin):
|
|||
Value = self.multivalue_model(name)
|
||||
if issubclass(Value, UserValueMixin):
|
||||
pattern = self.updt_multivalue_pattern(pattern)
|
||||
return super(
|
||||
UserMultiValueMixin, self).set_multivalue(name, value, **pattern)
|
||||
return super(UserMultiValueMixin, self).set_multivalue(name, value, **pattern)
|
||||
|
||||
# end UserMultiValueMixin
|
||||
|
|
|
@ -3,13 +3,16 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields, Index
|
||||
from trytond.pyson import Eval, If, Or
|
||||
from trytond.model import Workflow, ModelView, ModelSQL, fields
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pyson import Eval, If, Or, Bool
|
||||
from trytond.pool import Pool
|
||||
from trytond.report import Report
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
from decimal import Decimal
|
||||
from sql.operators import Equal, Between
|
||||
from sql import Literal, Null
|
||||
from datetime import timedelta
|
||||
from .book import sel_state_book
|
||||
|
||||
|
@ -33,18 +36,14 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
'Cashbook Reconciliation'
|
||||
__name__ = 'cashbook.recon'
|
||||
|
||||
cashbook = fields.Many2One(
|
||||
string='Cashbook', required=True,
|
||||
cashbook = fields.Many2One(string='Cashbook', required=True, select=True,
|
||||
model_name='cashbook.book', ondelete='CASCADE', readonly=True)
|
||||
date = fields.Date(
|
||||
string='Date', required=True,
|
||||
date = fields.Date(string='Date', required=True, select=True,
|
||||
states=STATES, depends=DEPENDS)
|
||||
feature = fields.Function(fields.Char(
|
||||
string='Feature', readonly=True,
|
||||
feature = fields.Function(fields.Char(string='Feature', readonly=True,
|
||||
states={'invisible': True}), 'on_change_with_feature')
|
||||
|
||||
date_from = fields.Date(
|
||||
string='Start Date',
|
||||
date_from = fields.Date(string='Start Date',
|
||||
required=True,
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
|
@ -52,8 +51,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
()),
|
||||
],
|
||||
states=STATES, depends=DEPENDS+['date_to'])
|
||||
date_to = fields.Date(
|
||||
string='End Date',
|
||||
date_to = fields.Date(string='End Date',
|
||||
required=True,
|
||||
domain=[
|
||||
If(Eval('date_to') & Eval('date_from'),
|
||||
|
@ -61,17 +59,14 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
()),
|
||||
],
|
||||
states=STATES, depends=DEPENDS+['date_from'])
|
||||
start_amount = fields.Numeric(
|
||||
string='Start Amount', required=True,
|
||||
start_amount = fields.Numeric(string='Start Amount', required=True,
|
||||
readonly=True, digits=(16, Eval('currency_digits', 2)),
|
||||
depends=['currency_digits'])
|
||||
end_amount = fields.Numeric(
|
||||
string='End Amount', required=True,
|
||||
end_amount = fields.Numeric(string='End Amount', required=True,
|
||||
readonly=True, digits=(16, Eval('currency_digits', 2)),
|
||||
depends=['currency_digits'])
|
||||
|
||||
lines = fields.One2Many(
|
||||
string='Lines', field='reconciliation',
|
||||
lines = fields.One2Many(string='Lines', field='reconciliation',
|
||||
model_name='cashbook.line', states=STATES,
|
||||
depends=DEPENDS+['date_from', 'date_to', 'cashbook'],
|
||||
add_remove=[
|
||||
|
@ -81,27 +76,22 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
('date', '<=', Eval('date_to')),
|
||||
],
|
||||
domain=[
|
||||
('date', '>=', Eval('date_from', None)),
|
||||
('date', '<=', Eval('date_to', None)),
|
||||
('date', '>=', Eval('date_from')),
|
||||
('date', '<=', Eval('date_to')),
|
||||
])
|
||||
|
||||
currency = fields.Function(fields.Many2One(
|
||||
model_name='currency.currency',
|
||||
currency = fields.Function(fields.Many2One(model_name='currency.currency',
|
||||
string="Currency"), 'on_change_with_currency')
|
||||
currency_digits = fields.Function(fields.Integer(
|
||||
string='Currency Digits'),
|
||||
currency_digits = fields.Function(fields.Integer(string='Currency Digits'),
|
||||
'on_change_with_currency_digits')
|
||||
predecessor = fields.Function(fields.Many2One(
|
||||
string='Predecessor', readonly=True,
|
||||
predecessor = fields.Function(fields.Many2One(string='Predecessor', readonly=True,
|
||||
model_name='cashbook.recon'),
|
||||
'on_change_with_predecessor')
|
||||
|
||||
state = fields.Selection(
|
||||
string='State', required=True, readonly=True,
|
||||
selection=sel_reconstate)
|
||||
state = fields.Selection(string='State', required=True, readonly=True,
|
||||
select=True, selection=sel_reconstate)
|
||||
state_string = state.translated('state')
|
||||
state_cashbook = fields.Function(fields.Selection(
|
||||
string='State of Cashbook',
|
||||
state_cashbook = fields.Function(fields.Selection(string='State of Cashbook',
|
||||
readonly=True, states={'invisible': True}, selection=sel_state_book),
|
||||
'on_change_with_state_cashbook')
|
||||
|
||||
|
@ -109,7 +99,6 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
def __setup__(cls):
|
||||
super(Reconciliation, cls).__setup__()
|
||||
cls._order.insert(0, ('date_from', 'DESC'))
|
||||
t = cls.__table__()
|
||||
cls._transitions |= set((
|
||||
('edit', 'check'),
|
||||
('check', 'done'),
|
||||
|
@ -129,23 +118,6 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
'depends': ['state'],
|
||||
},
|
||||
})
|
||||
cls._sql_indexes.update({
|
||||
Index(
|
||||
t,
|
||||
(t.cashbook, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.date, Index.Range())),
|
||||
Index(
|
||||
t,
|
||||
(t.date_to, Index.Range())),
|
||||
Index(
|
||||
t,
|
||||
(t.date_from, Index.Range(order='DESC'))),
|
||||
Index(
|
||||
t,
|
||||
(t.state, Index.Equality())),
|
||||
})
|
||||
|
||||
def check_overlap_dates(self):
|
||||
""" deny overlap of date_from/date_to between records of same cashbook
|
||||
|
@ -168,7 +140,9 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
[ # enclose other record
|
||||
('date_from', '>=', self.date_from),
|
||||
('date_to', '<=', self.date_to),
|
||||
]]]
|
||||
],
|
||||
],
|
||||
]
|
||||
|
||||
if Recon.search_count(query) > 0:
|
||||
raise UserError(gettext('cashbook.msg_recon_err_overlap'))
|
||||
|
@ -183,7 +157,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
if Line.search_count([
|
||||
('date', '>', reconciliation.date_from),
|
||||
('date', '<', reconciliation.date_to),
|
||||
('cashbook', '=', reconciliation.cashbook.id),
|
||||
('cashbook.id', '=', reconciliation.cashbook.id),
|
||||
('state', 'not in', ['check', 'recon']),
|
||||
]) > 0:
|
||||
raise UserError(gettext(
|
||||
|
@ -191,7 +165,8 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
bookname = reconciliation.cashbook.rec_name,
|
||||
reconame = reconciliation.rec_name,
|
||||
datefrom = Report.format_date(reconciliation.date_from),
|
||||
dateto=Report.format_date(reconciliation.date_to)))
|
||||
dateto = Report.format_date(reconciliation.date_to),
|
||||
))
|
||||
|
||||
@classmethod
|
||||
def get_values_wfedit(cls, reconciliation):
|
||||
|
@ -204,8 +179,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
|
||||
# unlink lines from reconciliation
|
||||
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
|
||||
|
||||
@classmethod
|
||||
|
@ -225,7 +199,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
lines = Line.search([
|
||||
('date', '>=', reconciliation.date_from),
|
||||
('date', '<=', reconciliation.date_to),
|
||||
('cashbook', '=', reconciliation.cashbook.id),
|
||||
('cashbook.id', '=', reconciliation.cashbook.id),
|
||||
('reconciliation', '=', None),
|
||||
('state', 'in', ['check', 'recon']),
|
||||
])
|
||||
|
@ -235,8 +209,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
# add amounts of new lines
|
||||
values['end_amount'] += sum([x.credit - x.debit for x in lines])
|
||||
# add amounts of already linked lines
|
||||
values['end_amount'] += sum([
|
||||
x.credit - x.debit for x in reconciliation.lines])
|
||||
values['end_amount'] += sum([x.credit - x.debit for x in reconciliation.lines])
|
||||
return values
|
||||
|
||||
@classmethod
|
||||
|
@ -276,17 +249,17 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
raise UserError(gettext(
|
||||
'cashbook.msg_recon_predecessor_not_done',
|
||||
recname_p = reconciliation.predecessor.rec_name,
|
||||
recname_c=reconciliation.rec_name))
|
||||
recname_c = reconciliation.rec_name,
|
||||
))
|
||||
|
||||
# check if current.date_from == predecessor.date_to
|
||||
if reconciliation.predecessor.date_to != \
|
||||
reconciliation.date_from:
|
||||
if reconciliation.predecessor.date_to != reconciliation.date_from:
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_recon_date_from_to_mismatch',
|
||||
datefrom = Report.format_date(reconciliation.date_from),
|
||||
dateto=Report.format_date(
|
||||
reconciliation.predecessor.date_to),
|
||||
recname=reconciliation.rec_name))
|
||||
dateto = Report.format_date(reconciliation.predecessor.date_to),
|
||||
recname = reconciliation.rec_name,
|
||||
))
|
||||
|
||||
to_write.extend([
|
||||
[reconciliation],
|
||||
|
@ -308,15 +281,17 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
to_wfrecon_line = []
|
||||
for reconciliation in reconciliations:
|
||||
to_wfrecon_line.extend([
|
||||
x for x in reconciliation.lines
|
||||
if x.state == 'check'])
|
||||
x for x in reconciliation.lines \
|
||||
if x.state == 'check'
|
||||
])
|
||||
to_wfdone_line.extend([
|
||||
x for x in reconciliation.lines
|
||||
if x.state == 'recon'])
|
||||
x for x in reconciliation.lines \
|
||||
if x.state == 'recon'
|
||||
])
|
||||
|
||||
# deny if there are lines not linked to reconciliation
|
||||
if Line.search_count([
|
||||
('cashbook', '=', reconciliation.cashbook.id),
|
||||
('cashbook.id', '=', reconciliation.cashbook.id),
|
||||
('reconciliation', '=', None),
|
||||
['OR',
|
||||
[ # lines inside of date-range
|
||||
|
@ -324,12 +299,14 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
('date', '<', reconciliation.date_to),
|
||||
],
|
||||
# lines at from-date must relate to a reconciliation
|
||||
('date', '=', reconciliation.date_from)],
|
||||
('date', '=', reconciliation.date_from),
|
||||
],
|
||||
]) > 0:
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_recon_lines_no_linked',
|
||||
date_from = Report.format_date(reconciliation.date_from),
|
||||
date_to=Report.format_date(reconciliation.date_to),))
|
||||
date_to = Report.format_date(reconciliation.date_to),
|
||||
))
|
||||
|
||||
if len(to_wfrecon_line) > 0:
|
||||
Line.wfrecon(to_wfrecon_line)
|
||||
|
@ -340,24 +317,14 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
def get_rec_name(self, name):
|
||||
""" short + name
|
||||
"""
|
||||
return ' '.join([
|
||||
Report.format_date(self.date_from, None)
|
||||
if self.date_from is not None else '-',
|
||||
'-',
|
||||
Report.format_date(self.date_to, None)
|
||||
if self.date_to is not None else '-',
|
||||
'|',
|
||||
Report.format_number(
|
||||
self.start_amount or 0.0, None,
|
||||
digits=getattr(self.currency, 'digits', 2)),
|
||||
getattr(self.currency, 'symbol', '-'),
|
||||
'-',
|
||||
Report.format_number(
|
||||
self.end_amount or 0.0, None,
|
||||
digits=getattr(self.currency, 'digits', 2)),
|
||||
getattr(self.currency, 'symbol', '-'),
|
||||
'[%(num)s]' % {'num': len(self.lines)},
|
||||
])
|
||||
return '%(from)s - %(to)s | %(start_amount)s %(symbol)s - %(end_amount)s %(symbol)s [%(num)s]' % {
|
||||
'from': Report.format_date(self.date_from, None) if self.date_from is not None else '-',
|
||||
'to': Report.format_date(self.date_to, None) if self.date_to is not None else '-',
|
||||
'start_amount': Report.format_number(self.start_amount or 0.0, None),
|
||||
'end_amount': Report.format_number(self.end_amount or 0.0, None),
|
||||
'symbol': getattr(self.currency, 'symbol', '-'),
|
||||
'num': len(self.lines),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def default_date_from(cls):
|
||||
|
@ -410,7 +377,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
if self.cashbook:
|
||||
if self.date_from is not None:
|
||||
reconciliations = Recon.search([
|
||||
('cashbook', '=', self.cashbook.id),
|
||||
('cashbook.id', '=', self.cashbook.id),
|
||||
('date_from', '<', self.date_from),
|
||||
], order=[('date_from', 'DESC')], limit=1)
|
||||
if len(reconciliations) > 0:
|
||||
|
@ -462,7 +429,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
|
||||
# set date_from to date_to of predecessor
|
||||
recons = Recon.search([
|
||||
('cashbook', '=', id_cashbook),
|
||||
('cashbook.id', '=', id_cashbook),
|
||||
], order=[('date_to', 'DESC')], limit=1)
|
||||
if len(recons) > 0:
|
||||
values['date_from'] = recons[0].date_to
|
||||
|
@ -471,7 +438,7 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
|
||||
# set date_to to day of last 'checked'-booking in selected cashbook
|
||||
lines = Line.search([
|
||||
('cashbook', '=', id_cashbook),
|
||||
('cashbook.id', '=', id_cashbook),
|
||||
('state', '=', 'check'),
|
||||
('reconciliation', '=', None),
|
||||
], order=[('date', 'DESC')], limit=1)
|
||||
|
@ -493,7 +460,8 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
raise UserError(gettext(
|
||||
'cashbook.msg_book_deny_write',
|
||||
bookname = reconciliation.cashbook.rec_name,
|
||||
state_txt=reconciliation.cashbook.state_string))
|
||||
state_txt = reconciliation.cashbook.state_string,
|
||||
))
|
||||
super(Reconciliation, cls).write(*args)
|
||||
|
||||
@classmethod
|
||||
|
@ -506,12 +474,14 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
'cashbook.msg_line_deny_delete1',
|
||||
linetxt = reconciliation.rec_name,
|
||||
bookname = reconciliation.cashbook.rec_name,
|
||||
bookstate=reconciliation.cashbook.state_string))
|
||||
bookstate = reconciliation.cashbook.state_string,
|
||||
))
|
||||
if reconciliation.state != 'edit':
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_recon_deny_delete2',
|
||||
recontxt = reconciliation.rec_name,
|
||||
reconstate=reconciliation.state_string))
|
||||
reconstate = reconciliation.state_string,
|
||||
))
|
||||
|
||||
super(Reconciliation, cls).delete(reconciliations)
|
||||
|
||||
|
|
|
@ -96,8 +96,8 @@ full copyright notices and license terms. -->
|
|||
</record>
|
||||
<record model="ir.rule" id="rg_recon_write-1">
|
||||
<field name="domain" eval="['OR',
|
||||
('cashbook.owner.id', '=', Eval('user_id', -1)),
|
||||
('cashbook.reviewer.id', 'in', Eval('groups', [])),
|
||||
('cashbook.owner.id', '=', Eval('user', {}).get('id', -1)),
|
||||
('cashbook.reviewer.id', 'in', Eval('user', {}).get('groups', [])),
|
||||
]" pyson="1"/>
|
||||
<field name="rule_group" ref="rg_recon_write"/>
|
||||
</record>
|
||||
|
@ -119,7 +119,7 @@ full copyright notices and license terms. -->
|
|||
</record>
|
||||
<record model="ir.rule" id="rg_recon_read-1">
|
||||
<field name="domain" eval="[
|
||||
('cashbook.observer.id', 'in', Eval('groups', [])),
|
||||
('cashbook.observer.id', 'in', Eval('user', {}).get('groups', [])),
|
||||
]" pyson="1"/>
|
||||
<field name="rule_group" ref="rg_recon_read"/>
|
||||
</record>
|
||||
|
|
31
setup.py
31
setup.py
|
@ -2,7 +2,7 @@
|
|||
"""
|
||||
|
||||
# Always prefer setuptools over distutils
|
||||
from setuptools import setup
|
||||
from setuptools import setup, find_packages
|
||||
# To use a consistent encoding
|
||||
from codecs import open
|
||||
from os import path
|
||||
|
@ -39,7 +39,7 @@ with open(path.join(here, 'versiondep.txt'), encoding='utf-8') as f:
|
|||
modversion[l2[0]] = {'min':l2[1], 'max':l2[2], 'prefix':l2[3]}
|
||||
|
||||
# tryton-version
|
||||
major_version = 7
|
||||
major_version = 6
|
||||
minor_version = 0
|
||||
|
||||
requires = ['python-slugify']
|
||||
|
@ -51,21 +51,19 @@ for dep in info.get('depends', []):
|
|||
prefix = modversion[dep]['prefix']
|
||||
|
||||
if len(modversion[dep]['max']) > 0:
|
||||
requires.append('%s_%s >= %s, <= %s' % (
|
||||
prefix, dep, modversion[dep]['min'],
|
||||
modversion[dep]['max']))
|
||||
requires.append('%s_%s >= %s, <= %s' %
|
||||
(prefix, dep, modversion[dep]['min'], modversion[dep]['max']))
|
||||
else :
|
||||
requires.append('%s_%s >= %s' % (
|
||||
prefix, dep, modversion[dep]['min']))
|
||||
requires.append('%s_%s >= %s' %
|
||||
(prefix, dep, modversion[dep]['min']))
|
||||
else :
|
||||
requires.append('%s_%s >= %s.%s, < %s.%s' % (
|
||||
'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))
|
||||
requires.append('trytond >= %s.%s, < %s.%s' % (
|
||||
major_version, minor_version, major_version, minor_version + 1))
|
||||
requires.append('trytond >= %s.%s, < %s.%s' %
|
||||
(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'),
|
||||
description='Tryton module to add a cashbook.',
|
||||
long_description=long_description,
|
||||
|
@ -91,7 +89,6 @@ setup(
|
|||
'License :: OSI Approved :: GNU General Public License (GPL)',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
],
|
||||
|
||||
keywords='tryton cashbook',
|
||||
|
@ -100,9 +97,9 @@ setup(
|
|||
'trytond.modules.%s' % MODULE,
|
||||
],
|
||||
package_data={
|
||||
'trytond.modules.%s' % MODULE: (info.get('xml', []) + [
|
||||
'tryton.cfg', 'locale/*.po', 'tests/*.py',
|
||||
'view/*.xml', 'icon/*.svg', 'docs/*.txt',
|
||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
||||
+ ['tryton.cfg', 'locale/*.po', 'tests/*.py',
|
||||
'view/*.xml', 'icon/*.svg',
|
||||
'report/*.fods', 'versiondep.txt', 'README.rst']),
|
||||
},
|
||||
|
||||
|
|
100
splitline.py
100
splitline.py
|
@ -4,12 +4,13 @@
|
|||
# full copyright notices and license terms.
|
||||
|
||||
|
||||
from trytond.model import ModelView, ModelSQL, fields, Index
|
||||
from trytond.model import ModelView, ModelSQL, Workflow, fields, Check
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Eval, If
|
||||
from trytond.report import Report
|
||||
from trytond.i18n import gettext
|
||||
from .line import sel_bookingtype, sel_linestate, STATES, DEPENDS
|
||||
from trytond.transaction import Transaction
|
||||
from .line import sel_linetype, sel_bookingtype, STATES, DEPENDS
|
||||
from .book import sel_state_book
|
||||
from .mixin import SecondCurrencyMixin
|
||||
|
||||
|
@ -29,18 +30,15 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
'Split booking line'
|
||||
__name__ = 'cashbook.split'
|
||||
|
||||
line = fields.Many2One(
|
||||
string='Line', required=True,
|
||||
ondelete='CASCADE', model_name='cashbook.line',
|
||||
line = fields.Many2One(string='Line', required=True,
|
||||
select=True, ondelete='CASCADE', model_name='cashbook.line',
|
||||
readonly=True)
|
||||
description = fields.Text(
|
||||
string='Description', states=STATES, depends=DEPENDS)
|
||||
splittype = fields.Selection(
|
||||
string='Type', required=True,
|
||||
description = fields.Text(string='Description',
|
||||
states=STATES, depends=DEPENDS)
|
||||
splittype = fields.Selection(string='Type', required=True,
|
||||
help='Type of split booking line', selection=sel_linetype,
|
||||
states=STATES, depends=DEPENDS)
|
||||
category = fields.Many2One(
|
||||
string='Category',
|
||||
category = fields.Many2One(string='Category',
|
||||
model_name='cashbook.category', ondelete='RESTRICT',
|
||||
states={
|
||||
'readonly': STATES['readonly'],
|
||||
|
@ -53,11 +51,9 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
('cattype', '=', 'in'),
|
||||
('cattype', '=', 'out'),
|
||||
)])
|
||||
category_view = fields.Function(fields.Char(
|
||||
string='Category', readonly=True),
|
||||
category_view = fields.Function(fields.Char(string='Category', readonly=True),
|
||||
'on_change_with_category_view')
|
||||
booktransf = fields.Many2One(
|
||||
string='Source/Dest',
|
||||
booktransf = fields.Many2One(string='Source/Dest',
|
||||
ondelete='RESTRICT', model_name='cashbook.book',
|
||||
domain=[
|
||||
('owner.id', '=', Eval('owner_cashbook', -1)),
|
||||
|
@ -70,65 +66,35 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
'required': Eval('splittype', '') == 'tr',
|
||||
}, depends=DEPENDS+['bookingtype', 'owner_cashbook', 'cashbook'])
|
||||
|
||||
amount = fields.Numeric(
|
||||
string='Amount', digits=(16, Eval('currency_digits', 2)),
|
||||
amount = fields.Numeric(string='Amount', digits=(16, Eval('currency_digits', 2)),
|
||||
required=True, states=STATES, depends=DEPENDS+['currency_digits'])
|
||||
|
||||
date = fields.Function(fields.Date(
|
||||
string='Date', readonly=True), 'on_change_with_date')
|
||||
target = fields.Function(fields.Reference(
|
||||
string='Target', readonly=True,
|
||||
date = fields.Function(fields.Date(string='Date', readonly=True),
|
||||
'on_change_with_date')
|
||||
target = fields.Function(fields.Reference(string='Target', readonly=True,
|
||||
selection=sel_target), 'on_change_with_target')
|
||||
currency = fields.Function(fields.Many2One(
|
||||
model_name='currency.currency',
|
||||
currency = fields.Function(fields.Many2One(model_name='currency.currency',
|
||||
string="Currency", readonly=True), 'on_change_with_currency')
|
||||
currency_digits = fields.Function(fields.Integer(
|
||||
string='Currency Digits',
|
||||
currency_digits = fields.Function(fields.Integer(string='Currency Digits',
|
||||
readonly=True), 'on_change_with_currency_digits')
|
||||
bookingtype = fields.Function(fields.Selection(
|
||||
string='Type', readonly=True,
|
||||
bookingtype = fields.Function(fields.Selection(string='Type', readonly=True,
|
||||
selection=sel_bookingtype), 'on_change_with_bookingtype')
|
||||
state = fields.Function(fields.Selection(
|
||||
string='State', readonly=True,
|
||||
selection=sel_linestate), 'on_change_with_state')
|
||||
cashbook = fields.Function(fields.Many2One(
|
||||
string='Cashbook',
|
||||
state = fields.Function(fields.Selection(string='State', readonly=True,
|
||||
selection=sel_linetype), 'on_change_with_state')
|
||||
cashbook = fields.Function(fields.Many2One(string='Cashbook',
|
||||
readonly=True, states={'invisible': True}, model_name='cashbook.book'),
|
||||
'on_change_with_cashbook')
|
||||
feature = fields.Function(fields.Char(
|
||||
string='Feature', readonly=True,
|
||||
feature = fields.Function(fields.Char(string='Feature', readonly=True,
|
||||
states={'invisible': True}), 'on_change_with_feature')
|
||||
booktransf_feature = fields.Function(fields.Char(
|
||||
string='Feature', readonly=True,
|
||||
booktransf_feature = fields.Function(fields.Char(string='Feature', readonly=True,
|
||||
states={'invisible': True}), 'on_change_with_booktransf_feature')
|
||||
state_cashbook = fields.Function(fields.Selection(
|
||||
string='State of Cashbook',
|
||||
state_cashbook = fields.Function(fields.Selection(string='State of Cashbook',
|
||||
readonly=True, states={'invisible': True}, selection=sel_state_book),
|
||||
'on_change_with_state_cashbook')
|
||||
owner_cashbook = fields.Function(fields.Many2One(
|
||||
string='Owner', readonly=True,
|
||||
owner_cashbook = fields.Function(fields.Many2One(string='Owner', readonly=True,
|
||||
states={'invisible': True}, model_name='res.user'),
|
||||
'on_change_with_owner_cashbook')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(SplitLine, cls).__setup__()
|
||||
t = cls.__table__()
|
||||
cls._sql_indexes.update({
|
||||
Index(
|
||||
t,
|
||||
(t.line, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.splittype, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.category, Index.Equality())),
|
||||
Index(
|
||||
t,
|
||||
(t.booktransf, Index.Equality())),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
def default_splittype(cls):
|
||||
""" default category
|
||||
|
@ -140,14 +106,10 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
"""
|
||||
return '%(type)s|%(amount)s %(symbol)s|%(desc)s [%(target)s]' % {
|
||||
'desc': (self.description or '-')[:40],
|
||||
'amount': Report.format_number(
|
||||
self.amount, None,
|
||||
digits=getattr(self.currency, 'digits', 2)),
|
||||
'amount': Report.format_number(self.amount, None),
|
||||
'symbol': getattr(self.currency, 'symbol', '-'),
|
||||
'target': self.category_view
|
||||
if self.splittype == 'cat' else self.booktransf.rec_name,
|
||||
'type': gettext(
|
||||
'cashbook.msg_line_bookingtype_%s' % self.line.bookingtype),
|
||||
'target': self.category_view if self.splittype == 'cat' else self.booktransf.rec_name,
|
||||
'type': gettext('cashbook.msg_line_bookingtype_%s' % self.line.bookingtype),
|
||||
}
|
||||
|
||||
@fields.depends('splittype', 'category', 'booktransf')
|
||||
|
@ -189,7 +151,7 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
if self.category:
|
||||
cfg1 = Configuration.get_singleton()
|
||||
|
||||
if getattr(cfg1, 'catnamelong', True) is True:
|
||||
if getattr(cfg1, 'catnamelong', True) == True:
|
||||
return self.category.rec_name
|
||||
else :
|
||||
return self.category.name
|
||||
|
@ -284,7 +246,7 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
|
||||
to_update_line = []
|
||||
for record in records:
|
||||
if record.line not in to_update_line:
|
||||
if not record.line in to_update_line:
|
||||
to_update_line.append(record.line)
|
||||
|
||||
to_write = Line2.update_values_by_splitlines(to_update_line)
|
||||
|
@ -306,7 +268,7 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
|
||||
if 'amount' in values.keys():
|
||||
for record in records:
|
||||
if record.line not in to_update_line:
|
||||
if not record.line in to_update_line:
|
||||
to_update_line.append(record.line)
|
||||
super(SplitLine, cls).write(*args)
|
||||
|
||||
|
|
|
@ -80,8 +80,8 @@ full copyright notices and license terms. -->
|
|||
</record>
|
||||
<record model="ir.rule" id="rg_split_write-1">
|
||||
<field name="domain" eval="['OR',
|
||||
('line.cashbook.owner.id', '=', Eval('user_id', -1)),
|
||||
('line.cashbook.reviewer.id', 'in', Eval('groups', [])),
|
||||
('line.cashbook.owner.id', '=', Eval('user', {}).get('id', -1)),
|
||||
('line.cashbook.reviewer.id', 'in', Eval('user', {}).get('groups', [])),
|
||||
]" pyson="1"/>
|
||||
<field name="rule_group" ref="rg_split_write"/>
|
||||
</record>
|
||||
|
@ -103,7 +103,7 @@ full copyright notices and license terms. -->
|
|||
</record>
|
||||
<record model="ir.rule" id="rg_split_read-1">
|
||||
<field name="domain" eval="[
|
||||
('line.cashbook.observer.id', 'in', Eval('groups', [])),
|
||||
('line.cashbook.observer.id', 'in', Eval('user', {}).get('groups', [])),
|
||||
]" pyson="1"/>
|
||||
<field name="rule_group" ref="rg_split_read"/>
|
||||
</record>
|
||||
|
|
|
@ -1,4 +1,38 @@
|
|||
# -*- 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.
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
import trytond.tests.test_tryton
|
||||
import unittest
|
||||
|
||||
from trytond.modules.cashbook.tests.test_type import TypeTestCase
|
||||
from trytond.modules.cashbook.tests.test_book import BookTestCase
|
||||
from trytond.modules.cashbook.tests.test_line import LineTestCase
|
||||
from trytond.modules.cashbook.tests.test_splitline import SplitLineTestCase
|
||||
from trytond.modules.cashbook.tests.test_config import ConfigTestCase
|
||||
from trytond.modules.cashbook.tests.test_category import CategoryTestCase
|
||||
from trytond.modules.cashbook.tests.test_reconciliation import ReconTestCase
|
||||
from trytond.modules.cashbook.tests.test_bookingwiz import BookingWizardTestCase
|
||||
|
||||
|
||||
__all__ = ['suite']
|
||||
|
||||
|
||||
class CashbookTestCase(\
|
||||
BookingWizardTestCase,\
|
||||
ReconTestCase,\
|
||||
CategoryTestCase,\
|
||||
ConfigTestCase,\
|
||||
LineTestCase,
|
||||
SplitLineTestCase,
|
||||
BookTestCase,
|
||||
TypeTestCase,
|
||||
):
|
||||
'Test cashbook module'
|
||||
module = 'cashbook'
|
||||
|
||||
# end CashbookTestCase
|
||||
|
||||
def suite():
|
||||
suite = trytond.tests.test_tryton.suite()
|
||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(CashbookTestCase))
|
||||
return suite
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# 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.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
|
@ -11,9 +11,10 @@ from datetime import date
|
|||
from decimal import Decimal
|
||||
|
||||
|
||||
class BookTestCase(object):
|
||||
""" test cashbook
|
||||
"""
|
||||
class BookTestCase(ModuleTestCase):
|
||||
'Test cashbook book module'
|
||||
module = 'cashbook'
|
||||
|
||||
def prep_sequence(self, name='Book Sequ'):
|
||||
""" create numbering-equence
|
||||
"""
|
||||
|
@ -89,7 +90,8 @@ class BookTestCase(object):
|
|||
}])
|
||||
|
||||
with Transaction().set_context({
|
||||
'date': date(2022, 5, 5)}):
|
||||
'date': date(2022, 5, 5),
|
||||
}):
|
||||
self.assertEqual(book.rec_name, 'Book 1 | 10.00 usd | Open')
|
||||
self.assertEqual(book.currency.rec_name, 'usd')
|
||||
self.assertEqual(book.currency.rate, Decimal('1.05'))
|
||||
|
@ -100,8 +102,7 @@ class BookTestCase(object):
|
|||
self.assertEqual(book.balance_ref, Decimal('9.52'))
|
||||
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
self.assertEqual(book.lines[0].rec_name,
|
||||
'05/05/2022|Rev|10.00 usd|Amount in USD [Cat1]')
|
||||
|
||||
@with_transaction()
|
||||
|
@ -144,7 +145,8 @@ class BookTestCase(object):
|
|||
}])
|
||||
|
||||
with Transaction().set_context({
|
||||
'date': date(2022, 5, 5)}):
|
||||
'date': date(2022, 5, 5),
|
||||
}):
|
||||
self.assertEqual(book.rec_name, 'Book 1')
|
||||
self.assertEqual(book.currency.rec_name, 'Euro')
|
||||
self.assertEqual(book.currency.rate, Decimal('1.0'))
|
||||
|
@ -154,9 +156,7 @@ class BookTestCase(object):
|
|||
self.assertEqual(len(book.lines), 0)
|
||||
self.assertEqual(len(book.childs), 1)
|
||||
|
||||
self.assertEqual(
|
||||
book.childs[0].rec_name,
|
||||
'Book 1/Book 2 | 10.00 usd | Open')
|
||||
self.assertEqual(book.childs[0].rec_name, 'Book 1/Book 2 | 10.00 usd | Open')
|
||||
self.assertEqual(book.childs[0].currency.rec_name, 'usd')
|
||||
self.assertEqual(book.childs[0].currency.rate, Decimal('1.05'))
|
||||
self.assertEqual(book.childs[0].company_currency.rec_name, 'Euro')
|
||||
|
@ -188,9 +188,7 @@ class BookTestCase(object):
|
|||
self.assertEqual(book.name, 'Level 1')
|
||||
self.assertEqual(book.rec_name, 'Level 1')
|
||||
self.assertEqual(len(book.childs), 1)
|
||||
self.assertEqual(
|
||||
book.childs[0].rec_name,
|
||||
'Level 1/Level 2 | 0.00 usd | Open')
|
||||
self.assertEqual(book.childs[0].rec_name, 'Level 1/Level 2 | 0.00 usd | Open')
|
||||
|
||||
@with_transaction()
|
||||
def test_book_deny_delete_open(self):
|
||||
|
@ -222,10 +220,8 @@ class BookTestCase(object):
|
|||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The cashbook 'Book 1 | 1.00 usd | Open' cannot be deleted" +
|
||||
" because it contains 1 lines and is not in the status 'Archive'.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The cashbook 'Book 1 | 1.00 usd | Open' cannot be deleted because it contains 1 lines and is not in the status 'Archive'.",
|
||||
Book.delete,
|
||||
[book])
|
||||
|
||||
|
@ -307,10 +303,6 @@ class BookTestCase(object):
|
|||
Book.search_count([('balance_all', '<', Decimal('5.0'))]),
|
||||
0)
|
||||
|
||||
self.assertEqual(
|
||||
Book.search_count([('balance_ref', '<', Decimal('5.0'))]),
|
||||
0)
|
||||
|
||||
@with_transaction()
|
||||
def test_book_deny_btype_set_none(self):
|
||||
""" create cashbook, add lines,
|
||||
|
@ -344,10 +336,8 @@ class BookTestCase(object):
|
|||
self.assertEqual(book.btype.feature, 'gen')
|
||||
self.assertEqual(book.feature, 'gen')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The type cannot be deleted on the cash book 'Book 1 | " +
|
||||
"1.00 usd | Open' because it still contains 1 lines.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The type cannot be deleted on the cash book 'Book 1 | 1.00 usd | Open' because it still contains 1 lines.",
|
||||
Book.write,
|
||||
*[
|
||||
[book],
|
||||
|
@ -403,11 +393,8 @@ class BookTestCase(object):
|
|||
Book.wfclosed([book])
|
||||
self.assertEqual(book.state, 'closed')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The cashbook 'Book 1 | 1.00 usd | Closed' cannot be " +
|
||||
"deleted because it contains 1 lines and is not in the " +
|
||||
"status 'Archive'.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The cashbook 'Book 1 | 1.00 usd | Closed' cannot be deleted because it contains 1 lines and is not in the status 'Archive'.",
|
||||
Book.delete,
|
||||
[book])
|
||||
|
||||
|
@ -476,10 +463,8 @@ class BookTestCase(object):
|
|||
Book.wfclosed([book])
|
||||
self.assertEqual(book.state, 'closed')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The cash book 'Book 1a | 1.00 usd | Closed' is 'Closed' " +
|
||||
"and cannot be changed.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The cash book 'Book 1a | 1.00 usd | Closed' is 'Closed' and cannot be changed.",
|
||||
Book.write,
|
||||
*[
|
||||
[book],
|
||||
|
@ -501,10 +486,8 @@ class BookTestCase(object):
|
|||
Book.wfclosed([book])
|
||||
Book.wfarchive([book])
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The cash book 'Book 1c | 0.00 usd | Archive' is 'Archive'" +
|
||||
" and cannot be changed.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The cash book 'Book 1c | 0.00 usd | Archive' is 'Archive' and cannot be changed.",
|
||||
Book.write,
|
||||
*[
|
||||
[book],
|
||||
|
@ -554,7 +537,8 @@ class BookTestCase(object):
|
|||
self.assertEqual(book.owner.rec_name, 'Frida'),
|
||||
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
# change to user 'diego' , try access
|
||||
with Transaction().set_user(usr_lst[1].id):
|
||||
books = Book.search([])
|
||||
|
@ -564,12 +548,9 @@ class BookTestCase(object):
|
|||
with Transaction().set_user(usr_lst[0].id):
|
||||
books = Book.search([])
|
||||
self.assertEqual(len(books), 1)
|
||||
self.assertEqual(
|
||||
books[0].rec_name,
|
||||
'Fridas book | 0.00 usd | Open')
|
||||
self.assertEqual(books[0].rec_name, 'Fridas book | 0.00 usd | Open')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
self.assertRaisesRegex(UserError,
|
||||
'You are not allowed to access "Cashbook.Name".',
|
||||
Book.write,
|
||||
*[
|
||||
|
@ -581,8 +562,7 @@ class BookTestCase(object):
|
|||
|
||||
@with_transaction()
|
||||
def test_book_permission_reviewer(self):
|
||||
""" create book + 2x users + 1x reviewer-group,
|
||||
add users to group, check access
|
||||
""" create book + 2x users + 1x reviewer-group, add users to group, check access
|
||||
"""
|
||||
pool = Pool()
|
||||
ResUser = pool.get('res.user')
|
||||
|
@ -628,7 +608,8 @@ class BookTestCase(object):
|
|||
self.assertEqual(book.owner.rec_name, 'Frida'),
|
||||
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
# change to user 'diego' , try access
|
||||
with Transaction().set_user(usr_lst[1].id):
|
||||
books = Book.search([])
|
||||
|
@ -640,14 +621,11 @@ class BookTestCase(object):
|
|||
with Transaction().set_user(usr_lst[0].id):
|
||||
books = Book.search([])
|
||||
self.assertEqual(len(books), 1)
|
||||
self.assertEqual(
|
||||
books[0].rec_name,
|
||||
'Fridas book | 0.00 usd | Open')
|
||||
self.assertEqual(books[0].rec_name, 'Fridas book | 0.00 usd | Open')
|
||||
|
||||
@with_transaction()
|
||||
def test_book_permission_observer(self):
|
||||
""" create book + 2x users + 1x observer-group,
|
||||
add users to group, check access
|
||||
""" create book + 2x users + 1x observer-group, add users to group, check access
|
||||
"""
|
||||
pool = Pool()
|
||||
ResUser = pool.get('res.user')
|
||||
|
@ -693,7 +671,8 @@ class BookTestCase(object):
|
|||
self.assertEqual(book.owner.rec_name, 'Frida'),
|
||||
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
# change to user 'diego' , try access
|
||||
with Transaction().set_user(usr_lst[1].id):
|
||||
books = Book.search([])
|
||||
|
@ -705,8 +684,6 @@ class BookTestCase(object):
|
|||
with Transaction().set_user(usr_lst[0].id):
|
||||
books = Book.search([])
|
||||
self.assertEqual(len(books), 1)
|
||||
self.assertEqual(
|
||||
books[0].rec_name,
|
||||
'Fridas book | 0.00 usd | Open')
|
||||
self.assertEqual(books[0].rec_name, 'Fridas book | 0.00 usd | Open')
|
||||
|
||||
# end BookTestCase
|
|
@ -3,17 +3,19 @@
|
|||
# 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.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
|
||||
class BookingWizardTestCase(object):
|
||||
""" test booking wizard
|
||||
"""
|
||||
class BookingWizardTestCase(ModuleTestCase):
|
||||
'Test cashbook booking wizard module'
|
||||
module = 'cashbook'
|
||||
|
||||
@with_transaction()
|
||||
def test_bookwiz_expense(self):
|
||||
""" run booking-wizard to store expense
|
||||
|
@ -24,11 +26,11 @@ class BookingWizardTestCase(object):
|
|||
Category = pool.get('cashbook.category')
|
||||
Party = pool.get('party.party')
|
||||
IrDate = pool.get('ir.date')
|
||||
Config = pool.get('cashbook.configuration')
|
||||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id}):
|
||||
'company': company.id,
|
||||
}):
|
||||
types = self.prep_type()
|
||||
book, = Book.create([{
|
||||
'name': 'Cash Book',
|
||||
|
@ -52,10 +54,6 @@ class BookingWizardTestCase(object):
|
|||
'cattype': 'out',
|
||||
}])
|
||||
|
||||
cfg1 = Config()
|
||||
cfg1.fixate = True
|
||||
cfg1.save()
|
||||
|
||||
(sess_id, start_state, end_state) = BookingWiz.create()
|
||||
w_obj = BookingWiz(sess_id)
|
||||
self.assertEqual(start_state, 'start')
|
||||
|
@ -70,7 +68,6 @@ class BookingWizardTestCase(object):
|
|||
self.assertEqual(result['view']['defaults']['booktransf'], None)
|
||||
self.assertEqual(result['view']['defaults']['description'], None)
|
||||
self.assertEqual(result['view']['defaults']['category'], None)
|
||||
self.assertEqual(result['view']['defaults']['fixate'], True)
|
||||
|
||||
self.assertEqual(len(book.lines), 0)
|
||||
|
||||
|
@ -81,7 +78,7 @@ class BookingWizardTestCase(object):
|
|||
'description': 'Test 1',
|
||||
'category': categories[1].id,
|
||||
'bookingtype': 'out',
|
||||
'fixate': True}
|
||||
}
|
||||
for x in r1.keys():
|
||||
setattr(w_obj.start, x, r1[x])
|
||||
|
||||
|
@ -91,10 +88,7 @@ class BookingWizardTestCase(object):
|
|||
IrDate.today = MagicMock(return_value=date.today())
|
||||
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Exp|-10.00 usd|Test 1 [Food]')
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Exp|-10.00 usd|Test 1 [Food]')
|
||||
|
||||
@with_transaction()
|
||||
def test_bookwiz_transfer(self):
|
||||
|
@ -109,7 +103,8 @@ class BookingWizardTestCase(object):
|
|||
|
||||
company = self.prep_company()
|
||||
with Transaction().set_context({
|
||||
'company': company.id}):
|
||||
'company': company.id,
|
||||
}):
|
||||
types = self.prep_type()
|
||||
books = Book.create([{
|
||||
'name': 'Cash Book',
|
||||
|
@ -132,7 +127,7 @@ class BookingWizardTestCase(object):
|
|||
'addresses':[('create', [{}])],
|
||||
}])
|
||||
|
||||
Category.create([{
|
||||
categories = Category.create([{
|
||||
'name':'Income',
|
||||
'cattype': 'in',
|
||||
}, {
|
||||
|
@ -154,7 +149,6 @@ class BookingWizardTestCase(object):
|
|||
self.assertEqual(result['view']['defaults']['booktransf'], None)
|
||||
self.assertEqual(result['view']['defaults']['description'], 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[1].lines), 0)
|
||||
|
@ -165,7 +159,7 @@ class BookingWizardTestCase(object):
|
|||
'description': 'Test 1',
|
||||
'booktransf': books[1].id,
|
||||
'bookingtype': 'mvout',
|
||||
'fixate': False}
|
||||
}
|
||||
for x in r1.keys():
|
||||
setattr(w_obj.start, x, r1[x])
|
||||
|
||||
|
@ -176,8 +170,7 @@ class BookingWizardTestCase(object):
|
|||
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(len(books[1].lines), 0)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/01/2022|to|-10.00 usd|Test 1 [Bank | 0.00 usd | Open]')
|
||||
|
||||
# end BookingWizardTestCase
|
|
@ -3,19 +3,21 @@
|
|||
# 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.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
|
||||
class CategoryTestCase(object):
|
||||
""" test category
|
||||
"""
|
||||
class CategoryTestCase(ModuleTestCase):
|
||||
'Test cashbook categoy module'
|
||||
module = 'cashbook'
|
||||
|
||||
def prep_category(self, name='Cat1', cattype='out'):
|
||||
""" create category
|
||||
"""
|
||||
pool = Pool()
|
||||
Company = pool.get('company.company')
|
||||
Category = pool.get('cashbook.category')
|
||||
|
||||
company = self.prep_company()
|
||||
|
@ -117,10 +119,8 @@ class CategoryTestCase(object):
|
|||
self.assertEqual(category.childs[0].rec_name, 'Level 1/Level 2')
|
||||
self.assertEqual(category.childs[0].cattype, 'in')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
'The value "out" for field "Type" in "Level 1/Level 2" of ' +
|
||||
'"Category" is not valid according to its domain.',
|
||||
self.assertRaisesRegex(UserError,
|
||||
'The value for field "Type" in "Category" is not valid according to its domain.',
|
||||
Category.write,
|
||||
*[
|
||||
[category.childs[0]],
|
||||
|
@ -140,6 +140,7 @@ class CategoryTestCase(object):
|
|||
self.assertEqual(category.childs[0].rec_name, 'Level 1/Level 2')
|
||||
self.assertEqual(category.childs[0].cattype, 'out')
|
||||
|
||||
|
||||
@with_transaction()
|
||||
def test_category_create_nodupl_at_root(self):
|
||||
""" create category, duplicates are allowed at root-level
|
||||
|
@ -150,7 +151,8 @@ class CategoryTestCase(object):
|
|||
company = self.prep_company()
|
||||
|
||||
with Transaction().set_context({
|
||||
'company': company.id}):
|
||||
'company': company.id,
|
||||
}):
|
||||
cat1, = Category.create([{
|
||||
'name': 'Test 1',
|
||||
'description': 'Info',
|
||||
|
@ -175,8 +177,7 @@ class CategoryTestCase(object):
|
|||
self.assertEqual(cat2.parent, None)
|
||||
|
||||
# deny duplicate of same type
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
self.assertRaisesRegex(UserError,
|
||||
'The category name already exists at this level.',
|
||||
Category.create,
|
||||
[{
|
||||
|
@ -195,7 +196,8 @@ class CategoryTestCase(object):
|
|||
company = self.prep_company()
|
||||
|
||||
with Transaction().set_context({
|
||||
'company': company.id}):
|
||||
'company': company.id,
|
||||
}):
|
||||
cat1, = Category.create([{
|
||||
'name': 'Test 1',
|
||||
'description': 'Info',
|
||||
|
@ -221,9 +223,9 @@ class CategoryTestCase(object):
|
|||
company = self.prep_company()
|
||||
|
||||
with Transaction().set_context({
|
||||
'company': company.id}):
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
'company': company.id,
|
||||
}):
|
||||
self.assertRaisesRegex(UserError,
|
||||
'The category name already exists at this level.',
|
||||
Category.create,
|
||||
[{
|
|
@ -3,17 +3,19 @@
|
|||
# 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.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.modules.company.tests import create_company
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class ConfigTestCase(object):
|
||||
""" test config
|
||||
"""
|
||||
class ConfigTestCase(ModuleTestCase):
|
||||
'Test config type module'
|
||||
module = 'cashbook'
|
||||
|
||||
def prep_company(self):
|
||||
""" get/create company
|
||||
"""
|
||||
|
@ -167,7 +169,8 @@ class ConfigTestCase(object):
|
|||
self.assertEqual(usr_lst[1].name, 'Diego')
|
||||
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
# change to user 'frida'
|
||||
with Transaction().set_user(usr_lst[0].id):
|
||||
cfg1 = Configuration()
|
||||
|
@ -178,12 +181,10 @@ class ConfigTestCase(object):
|
|||
self.assertEqual(cfg2.date_to, None)
|
||||
self.assertEqual(cfg2.checked, True)
|
||||
self.assertEqual(cfg2.done, False)
|
||||
self.assertEqual(cfg2.fixate, False)
|
||||
|
||||
cfg2.date_from = date(2022, 4, 1)
|
||||
cfg2.date_to = date(2022, 5, 30)
|
||||
cfg2.checked = False
|
||||
cfg2.fixate = True
|
||||
cfg2.save()
|
||||
|
||||
# change to user 'diego'
|
||||
|
@ -196,7 +197,6 @@ class ConfigTestCase(object):
|
|||
self.assertEqual(cfg2.date_to, None)
|
||||
self.assertEqual(cfg2.checked, True)
|
||||
self.assertEqual(cfg2.done, False)
|
||||
self.assertEqual(cfg2.fixate, False)
|
||||
|
||||
cfg2.date_from = date(2022, 4, 15)
|
||||
cfg2.date_to = date(2022, 5, 15)
|
||||
|
@ -212,6 +212,5 @@ class ConfigTestCase(object):
|
|||
self.assertEqual(cfg2.date_to, date(2022, 5, 30))
|
||||
self.assertEqual(cfg2.checked, False)
|
||||
self.assertEqual(cfg2.done, False)
|
||||
self.assertEqual(cfg2.fixate, True)
|
||||
|
||||
# end ConfigTestCase
|
|
@ -3,7 +3,7 @@
|
|||
# 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.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
|
@ -12,9 +12,10 @@ from unittest.mock import MagicMock
|
|||
from decimal import Decimal
|
||||
|
||||
|
||||
class LineTestCase(object):
|
||||
""" test lines
|
||||
"""
|
||||
class LineTestCase(ModuleTestCase):
|
||||
'Test cashbook line module'
|
||||
module = 'cashbook'
|
||||
|
||||
@with_transaction()
|
||||
def test_line_check_add_amount2nd_currency(self):
|
||||
""" create cashbook, lines, add transfer without
|
||||
|
@ -75,10 +76,8 @@ class LineTestCase(object):
|
|||
}])],
|
||||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> EUR ' +
|
||||
'[Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].amount, Decimal('10.0'))
|
||||
# auto-created
|
||||
self.assertEqual(books[0].lines[0].amount_2nd_currency, Decimal('9.52'))
|
||||
|
@ -98,10 +97,8 @@ class LineTestCase(object):
|
|||
}])],
|
||||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'06/01/2022|to|-10.00 usd|Transfer USD --> EUR ' +
|
||||
'[Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'06/01/2022|to|-10.00 usd|Transfer USD --> EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].amount, Decimal('10.0'))
|
||||
# auto-created
|
||||
self.assertEqual(books[0].lines[0].amount_2nd_currency, Decimal('9.80'))
|
||||
|
@ -121,10 +118,8 @@ class LineTestCase(object):
|
|||
}])],
|
||||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> ' +
|
||||
'EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].amount, Decimal('10.0'))
|
||||
# manual set
|
||||
self.assertEqual(books[0].lines[0].amount_2nd_currency, Decimal('8.5'))
|
||||
|
@ -210,10 +205,8 @@ class LineTestCase(object):
|
|||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(len(books[1].lines), 0)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> ' +
|
||||
'EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].amount_2nd_currency, Decimal('9.52'))
|
||||
|
||||
# clear field 'amount_2nd_currency' to prepare for migration
|
||||
|
@ -236,6 +229,7 @@ class LineTestCase(object):
|
|||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Lines = pool.get('cashbook.line')
|
||||
Reconciliation = pool.get('cashbook.recon')
|
||||
|
||||
types = self.prep_type()
|
||||
company = self.prep_company()
|
||||
|
@ -275,10 +269,8 @@ class LineTestCase(object):
|
|||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(len(books[1].lines), 0)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> ' +
|
||||
'EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].amount_2nd_currency, Decimal('9.52'))
|
||||
self.assertEqual(books[0].lines[0].reference, None)
|
||||
self.assertEqual(len(books[0].lines[0].references), 0)
|
||||
|
@ -291,16 +283,10 @@ class LineTestCase(object):
|
|||
self.assertEqual(books[0].lines[0].reference, None)
|
||||
self.assertEqual(len(books[0].lines[0].references), 1)
|
||||
|
||||
self.prep_valstore_run_worker()
|
||||
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> ' +
|
||||
'EUR [Book EURO | 9.52 € | Open]')
|
||||
self.assertEqual(
|
||||
books[1].lines[0].rec_name,
|
||||
'05/05/2022|from|9.52 €|Transfer USD --> ' +
|
||||
'EUR [Book USD | -10.00 usd | Open]')
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 usd|Transfer USD --> EUR [Book EURO | 9.52 € | Open]')
|
||||
self.assertEqual(books[1].lines[0].rec_name,
|
||||
'05/05/2022|from|9.52 €|Transfer USD --> EUR [Book USD | -10.00 usd | Open]')
|
||||
self.assertEqual(books[0].balance, Decimal('-10.0'))
|
||||
self.assertEqual(books[0].currency.rec_name, 'usd')
|
||||
self.assertEqual(books[1].balance, Decimal('9.52'))
|
||||
|
@ -314,6 +300,7 @@ class LineTestCase(object):
|
|||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Lines = pool.get('cashbook.line')
|
||||
Reconciliation = pool.get('cashbook.recon')
|
||||
|
||||
types = self.prep_type()
|
||||
company = self.prep_company()
|
||||
|
@ -353,10 +340,8 @@ class LineTestCase(object):
|
|||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(len(books[1].lines), 0)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/05/2022|from|10.00 usd|Transfer USD <-- ' +
|
||||
'EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/05/2022|from|10.00 usd|Transfer USD <-- EUR [Book EURO | 0.00 € | Open]')
|
||||
self.assertEqual(books[0].lines[0].reference, None)
|
||||
self.assertEqual(len(books[0].lines[0].references), 0)
|
||||
self.assertEqual(books[0].lines[0].reconciliation, None)
|
||||
|
@ -368,16 +353,10 @@ class LineTestCase(object):
|
|||
self.assertEqual(books[0].lines[0].reference, None)
|
||||
self.assertEqual(len(books[0].lines[0].references), 1)
|
||||
|
||||
self.prep_valstore_run_worker()
|
||||
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/05/2022|from|10.00 usd|Transfer USD <-- ' +
|
||||
'EUR [Book EURO | -9.52 € | Open]')
|
||||
self.assertEqual(
|
||||
books[1].lines[0].rec_name,
|
||||
'05/05/2022|to|-9.52 €|Transfer USD <-- ' +
|
||||
'EUR [Book USD | 10.00 usd | Open]')
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/05/2022|from|10.00 usd|Transfer USD <-- EUR [Book EURO | -9.52 € | Open]')
|
||||
self.assertEqual(books[1].lines[0].rec_name,
|
||||
'05/05/2022|to|-9.52 €|Transfer USD <-- EUR [Book USD | 10.00 usd | Open]')
|
||||
self.assertEqual(books[0].balance, Decimal('10.0'))
|
||||
self.assertEqual(books[0].currency.rec_name, 'usd')
|
||||
self.assertEqual(books[1].balance, Decimal('-9.52'))
|
||||
|
@ -392,6 +371,7 @@ class LineTestCase(object):
|
|||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Lines = pool.get('cashbook.line')
|
||||
Reconciliation = pool.get('cashbook.recon')
|
||||
Currency = pool.get('currency.currency')
|
||||
CurrencyRate = pool.get('currency.currency.rate')
|
||||
|
||||
|
@ -447,10 +427,8 @@ class LineTestCase(object):
|
|||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(len(books[1].lines), 0)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 CHF|Transfer CHF --> ' +
|
||||
'USD [Book USD | 0.00 usd | Open]')
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 CHF|Transfer CHF --> USD [Book USD | 0.00 usd | Open]')
|
||||
self.assertEqual(books[0].lines[0].reference, None)
|
||||
self.assertEqual(len(books[0].lines[0].references), 0)
|
||||
self.assertEqual(books[0].lines[0].reconciliation, None)
|
||||
|
@ -462,21 +440,15 @@ class LineTestCase(object):
|
|||
self.assertEqual(books[0].lines[0].reference, None)
|
||||
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 = 10.0961538 USD
|
||||
# EUR | USD | CHF
|
||||
# -----+-----+----- @ 05/02/2022
|
||||
# 1.00| 1.05| 1.04
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 CHF|Transfer CHF --> ' +
|
||||
'USD [Book USD | 10.10 usd | Open]')
|
||||
self.assertEqual(
|
||||
books[1].lines[0].rec_name,
|
||||
'05/05/2022|from|10.10 usd|Transfer CHF --> ' +
|
||||
'USD [Book CHF | -10.00 CHF | Open]')
|
||||
self.assertEqual(books[0].lines[0].rec_name,
|
||||
'05/05/2022|to|-10.00 CHF|Transfer CHF --> USD [Book USD | 10.10 usd | Open]')
|
||||
self.assertEqual(books[1].lines[0].rec_name,
|
||||
'05/05/2022|from|10.10 usd|Transfer CHF --> USD [Book CHF | -10.00 CHF | Open]')
|
||||
self.assertEqual(books[0].balance, Decimal('-10.0'))
|
||||
self.assertEqual(books[0].currency.rec_name, 'Swiss Franc')
|
||||
self.assertEqual(books[1].balance, Decimal('10.10'))
|
||||
|
@ -535,97 +507,68 @@ class LineTestCase(object):
|
|||
}])
|
||||
|
||||
self.assertEqual(len(book.lines), 4)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].balance, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[0].reconciliation, None)
|
||||
self.assertEqual(book.lines[0].state, 'edit')
|
||||
self.assertEqual(book.lines[0].feature, 'gen')
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name,
|
||||
'05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].balance, Decimal('2.0'))
|
||||
self.assertEqual(book.lines[1].reconciliation, None)
|
||||
self.assertEqual(book.lines[1].state, 'edit')
|
||||
self.assertEqual(
|
||||
book.lines[2].rec_name,
|
||||
'05/15/2022|Rev|1.00 usd|Text 3 [Cat1]')
|
||||
self.assertEqual(book.lines[2].rec_name, '05/15/2022|Rev|1.00 usd|Text 3 [Cat1]')
|
||||
self.assertEqual(book.lines[2].balance, Decimal('3.0'))
|
||||
self.assertEqual(book.lines[2].reconciliation, None)
|
||||
self.assertEqual(book.lines[2].state, 'edit')
|
||||
self.assertEqual(
|
||||
book.lines[3].rec_name,
|
||||
'05/17/2022|Rev|1.00 usd|Text 4 [Cat1]')
|
||||
self.assertEqual(book.lines[3].rec_name, '05/17/2022|Rev|1.00 usd|Text 4 [Cat1]')
|
||||
self.assertEqual(book.lines[3].balance, Decimal('4.0'))
|
||||
self.assertEqual(book.lines[3].reconciliation, None)
|
||||
self.assertEqual(book.lines[3].state, 'edit')
|
||||
|
||||
Lines.wfcheck([book.lines[0], book.lines[1]])
|
||||
recon, = Reconciliation.create([{
|
||||
'cashbook': book.id}])
|
||||
self.assertEqual(
|
||||
recon.rec_name,
|
||||
'05/01/2022 - 05/02/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
'cashbook': book.id,
|
||||
}])
|
||||
self.assertEqual(recon.rec_name, '05/01/2022 - 05/02/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
|
||||
Reconciliation.wfcheck([recon])
|
||||
self.assertEqual(
|
||||
recon.rec_name,
|
||||
'05/01/2022 - 05/02/2022 | 0.00 usd - 2.00 usd [2]')
|
||||
self.assertEqual(recon.rec_name, '05/01/2022 - 05/02/2022 | 0.00 usd - 2.00 usd [2]')
|
||||
|
||||
self.assertEqual(len(book.lines), 4)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].balance, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[0].reconciliation.id, recon.id)
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name,
|
||||
'05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].balance, Decimal('2.0'))
|
||||
self.assertEqual(book.lines[1].reconciliation.id, recon.id)
|
||||
self.assertEqual(book.lines[1].state, 'check')
|
||||
self.assertEqual(
|
||||
book.lines[2].rec_name,
|
||||
'05/15/2022|Rev|1.00 usd|Text 3 [Cat1]')
|
||||
self.assertEqual(book.lines[2].rec_name, '05/15/2022|Rev|1.00 usd|Text 3 [Cat1]')
|
||||
self.assertEqual(book.lines[2].balance, Decimal('3.0'))
|
||||
self.assertEqual(book.lines[2].reconciliation, None)
|
||||
self.assertEqual(book.lines[2].state, 'edit')
|
||||
self.assertEqual(
|
||||
book.lines[3].rec_name,
|
||||
'05/17/2022|Rev|1.00 usd|Text 4 [Cat1]')
|
||||
self.assertEqual(book.lines[3].rec_name, '05/17/2022|Rev|1.00 usd|Text 4 [Cat1]')
|
||||
self.assertEqual(book.lines[3].balance, Decimal('4.0'))
|
||||
self.assertEqual(book.lines[3].reconciliation, None)
|
||||
self.assertEqual(book.lines[3].state, 'edit')
|
||||
|
||||
Reconciliation.wfdone([recon])
|
||||
self.assertEqual(
|
||||
recon.rec_name,
|
||||
'05/01/2022 - 05/02/2022 | 0.00 usd - 2.00 usd [2]')
|
||||
self.assertEqual(recon.rec_name, '05/01/2022 - 05/02/2022 | 0.00 usd - 2.00 usd [2]')
|
||||
|
||||
self.assertEqual(len(book.lines), 4)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].balance, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[0].reconciliation.id, recon.id)
|
||||
self.assertEqual(book.lines[0].state, 'done')
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name,
|
||||
'05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].balance, Decimal('2.0'))
|
||||
self.assertEqual(book.lines[1].reconciliation.id, recon.id)
|
||||
self.assertEqual(book.lines[1].state, 'done')
|
||||
self.assertEqual(
|
||||
book.lines[2].rec_name,
|
||||
'05/15/2022|Rev|1.00 usd|Text 3 [Cat1]')
|
||||
self.assertEqual(book.lines[2].rec_name, '05/15/2022|Rev|1.00 usd|Text 3 [Cat1]')
|
||||
self.assertEqual(book.lines[2].balance, Decimal('3.0'))
|
||||
self.assertEqual(book.lines[2].reconciliation, None)
|
||||
self.assertEqual(book.lines[2].state, 'edit')
|
||||
self.assertEqual(
|
||||
book.lines[3].rec_name,
|
||||
'05/17/2022|Rev|1.00 usd|Text 4 [Cat1]')
|
||||
self.assertEqual(book.lines[3].rec_name, '05/17/2022|Rev|1.00 usd|Text 4 [Cat1]')
|
||||
self.assertEqual(book.lines[3].balance, Decimal('4.0'))
|
||||
self.assertEqual(book.lines[3].reconciliation, None)
|
||||
self.assertEqual(book.lines[3].state, 'edit')
|
||||
|
@ -645,7 +588,8 @@ class LineTestCase(object):
|
|||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
with Transaction().set_context({
|
||||
'company': company.id}):
|
||||
'company': company.id,
|
||||
}):
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -676,14 +620,10 @@ class LineTestCase(object):
|
|||
self.assertEqual(book.number_atcheck, False)
|
||||
self.assertEqual(len(book.lines), 2)
|
||||
self.assertEqual(book.lines[0].date, date(2022, 5, 1))
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].state_cashbook, 'open')
|
||||
self.assertEqual(book.lines[1].date, date(2022, 5, 2))
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name,
|
||||
'05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
|
||||
# add reconciliation
|
||||
Book.write(*[
|
||||
|
@ -697,10 +637,8 @@ class LineTestCase(object):
|
|||
}])
|
||||
self.assertEqual(len(book.reconciliations), 1)
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 0)
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].date_from, date(2022, 5, 1))
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].date_to, date(2022, 5, 30))
|
||||
self.assertEqual(book.reconciliations[0].date_from, date(2022, 5, 1))
|
||||
self.assertEqual(book.reconciliations[0].date_to, date(2022, 5, 30))
|
||||
self.assertEqual(book.reconciliations[0].state, 'edit')
|
||||
|
||||
Lines.wfcheck(book.lines)
|
||||
|
@ -711,12 +649,8 @@ class LineTestCase(object):
|
|||
|
||||
Reconciliation.wfcheck(book.reconciliations)
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 2)
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].lines[1].rec_name,
|
||||
'05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.reconciliations[0].lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.reconciliations[0].lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.reconciliations[0].lines[0].number, None)
|
||||
self.assertEqual(book.reconciliations[0].lines[1].number, None)
|
||||
|
||||
|
@ -785,62 +719,41 @@ class LineTestCase(object):
|
|||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(len(book.lines), 3)
|
||||
self.assertEqual(book.lines[0].date, date(2022, 5, 1))
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].state_cashbook, 'open')
|
||||
self.assertEqual(book.lines[1].date, date(2022, 5, 2))
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[2].date, date(2022, 5, 3))
|
||||
self.assertEqual(
|
||||
book.lines[2].rec_name, '05/03/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||
self.assertEqual(book.lines[2].rec_name, '05/03/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', '=', 'Text 1')]), 1)
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', '=', 'Text 1a')]), 0)
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', 'ilike', 'text%')]), 3)
|
||||
self.assertEqual(Lines.search_count([('rec_name', '=', 'Text 1')]), 1)
|
||||
self.assertEqual(Lines.search_count([('rec_name', '=', 'Text 1a')]), 0)
|
||||
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'text%')]), 3)
|
||||
# search in category of split-line
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', '=', 'sp-cat1')]), 1)
|
||||
self.assertEqual(Lines.search_count([('rec_name', '=', 'sp-cat1')]), 1)
|
||||
# search in description of split-line
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', '=', 'text3-spline1')]), 1)
|
||||
self.assertEqual(Lines.search_count([('rec_name', '=', 'text3-spline1')]), 1)
|
||||
# ilike fails in fields.Text to find subtext...
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', 'ilike', '%spline%')]), 0)
|
||||
self.assertEqual(Lines.search_count([('rec_name', 'ilike', '%spline%')]), 0)
|
||||
# ...but it uses separator-chars
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', 'ilike', 'text3%')]), 1)
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', 'ilike', 'spline1')]), 1)
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', 'ilike', '%spline1')]), 1)
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', 'ilike', 'spline1%')]), 0)
|
||||
self.assertEqual(
|
||||
Lines.search_count([('rec_name', 'ilike', 'text3')]), 1)
|
||||
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'text3%')]), 1)
|
||||
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'spline1')]), 1)
|
||||
self.assertEqual(Lines.search_count([('rec_name', 'ilike', '%spline1')]), 1)
|
||||
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'spline1%')]), 0)
|
||||
self.assertEqual(Lines.search_count([('rec_name', 'ilike', 'text3')]), 1)
|
||||
|
||||
self.assertEqual(
|
||||
Lines.search_count([('state_cashbook', '=', 'open')]), 3)
|
||||
self.assertEqual(
|
||||
Lines.search_count([('state_cashbook', '=', 'closed')]), 0)
|
||||
self.assertEqual(
|
||||
Lines.search_count([('cashbook.state', '=', 'open')]), 3)
|
||||
self.assertEqual(
|
||||
Lines.search_count([('cashbook.state', '=', 'closed')]), 0)
|
||||
self.assertEqual(Lines.search_count([('state_cashbook', '=', 'open')]), 3)
|
||||
self.assertEqual(Lines.search_count([('state_cashbook', '=', 'closed')]), 0)
|
||||
self.assertEqual(Lines.search_count([('cashbook.state', '=', 'open')]), 3)
|
||||
self.assertEqual(Lines.search_count([('cashbook.state', '=', 'closed')]), 0)
|
||||
|
||||
# sorting: date -> state -> id
|
||||
self.assertEqual(len(book.lines), 3)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].state, 'edit')
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/02/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].state, 'edit')
|
||||
self.assertEqual(
|
||||
book.lines[2].rec_name, '05/03/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||
self.assertEqual(book.lines[2].rec_name, '05/03/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||
self.assertEqual(book.lines[2].state, 'edit')
|
||||
|
||||
# set to same date
|
||||
|
@ -851,27 +764,21 @@ class LineTestCase(object):
|
|||
}])
|
||||
# check again
|
||||
book, = Book.search([])
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].state, 'edit')
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name, '05/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].state, 'edit')
|
||||
self.assertEqual(
|
||||
book.lines[2].rec_name, '05/01/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||
self.assertEqual(book.lines[2].rec_name, '05/01/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||
self.assertEqual(book.lines[2].state, 'edit')
|
||||
|
||||
# set to 'check', will sort first
|
||||
Lines.wfcheck([book.lines[1]])
|
||||
book, = Book.search([])
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].state, 'edit')
|
||||
self.assertEqual(
|
||||
book.lines[2].rec_name, '05/01/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||
self.assertEqual(book.lines[2].rec_name, '05/01/2022|Rev/Sp|1.00 usd|Text 3 [-]')
|
||||
self.assertEqual(book.lines[2].state, 'edit')
|
||||
|
||||
@with_transaction()
|
||||
|
@ -884,7 +791,7 @@ class LineTestCase(object):
|
|||
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': None,
|
||||
|
@ -893,10 +800,8 @@ class LineTestCase(object):
|
|||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
r'The value "Book 1" for field "Cashbook" in "\d+" of ' +
|
||||
r'"Cashbook Line" is not valid according to its domain.',
|
||||
self.assertRaisesRegex(UserError,
|
||||
'The value for field "Cashbook" in "Cashbook Line" is not valid according to its domain.',
|
||||
Line.create,
|
||||
[{
|
||||
'cashbook': book.id,
|
||||
|
@ -906,49 +811,6 @@ class LineTestCase(object):
|
|||
'amount': Decimal('0.0'),
|
||||
}])
|
||||
|
||||
@with_transaction()
|
||||
def test_line_check_deny_delete_of_party(self):
|
||||
""" create cashbook + line, delete party should fail
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Party = pool.get('party.party')
|
||||
|
||||
types = self.prep_type()
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
'company': company.id,
|
||||
'currency': company.currency.id,
|
||||
'number_sequ': self.prep_sequence().id,
|
||||
'start_date': date(2022, 5, 1),
|
||||
'lines': [('create', [{
|
||||
'date': date(2022, 5, 1),
|
||||
'description': 'Text 1',
|
||||
'category': category.id,
|
||||
'bookingtype': 'in',
|
||||
'amount': Decimal('1.0'),
|
||||
'party': party.id,
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(book.lines[0].party.rec_name, 'Party')
|
||||
self.assertEqual(book.lines[0].party.id, party.id)
|
||||
|
||||
self.assertEqual(Party.search_count([('name', '=', 'Party')]), 1)
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
'The records could not be deleted because they are used by ' +
|
||||
'field "Party" of "Cashbook Line".',
|
||||
Party.delete,
|
||||
[party])
|
||||
|
||||
@with_transaction()
|
||||
def test_line_create_check_deny_write(self):
|
||||
""" create cashbook + line, 'close' book, write to line
|
||||
|
@ -996,10 +858,8 @@ class LineTestCase(object):
|
|||
Line.wfcheck([book.lines[0]])
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The cashbook line '05/01/2022|1.00 usd|works [Cat1]' is " +
|
||||
"'Checked' and cannot be changed.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The cashbook line '05/01/2022|1.00 usd|works [Cat1]' is 'Checked' and cannot be changed.",
|
||||
Line.write,
|
||||
*[
|
||||
[book.lines[0]],
|
||||
|
@ -1011,10 +871,8 @@ class LineTestCase(object):
|
|||
Book.wfclosed([book])
|
||||
self.assertEqual(book.state, 'closed')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The cash book 'Book | 2.00 usd | Closed' is 'Closed' " +
|
||||
"and cannot be changed.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The cash book 'Book | 2.00 usd | Closed' is 'Closed' and cannot be changed.",
|
||||
Line.write,
|
||||
*[
|
||||
[book.lines[0]],
|
||||
|
@ -1098,12 +956,13 @@ class LineTestCase(object):
|
|||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Line = pool.get('cashbook.line')
|
||||
Category = pool.get('cashbook.category')
|
||||
|
||||
types = self.prep_type()
|
||||
self.prep_category(cattype='in')
|
||||
category_in = self.prep_category(cattype='in')
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
party = self.prep_party()
|
||||
|
||||
book2, = Book.create([{
|
||||
'name': 'Book 2',
|
||||
|
@ -1133,45 +992,32 @@ class LineTestCase(object):
|
|||
self.assertEqual(book.rec_name, 'Book 1 | -1.00 usd | Open')
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(len(book2.lines), 0)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|to|-1.00 usd|Transfer Out [Book 2 | 0.00 usd | Open]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|to|-1.00 usd|Transfer Out [Book 2 | 0.00 usd | Open]')
|
||||
self.assertEqual(len(book.lines[0].references), 0)
|
||||
|
||||
# check counterpart
|
||||
self.assertEqual(
|
||||
book.lines[0].booktransf.rec_name,
|
||||
'Book 2 | 0.00 usd | Open')
|
||||
self.assertEqual(book.lines[0].booktransf.rec_name, 'Book 2 | 0.00 usd | Open')
|
||||
self.assertEqual(book.lines[0].booktransf.btype.feature, 'gen')
|
||||
self.assertEqual(book.lines[0].booktransf_feature, 'gen')
|
||||
|
||||
# check payee
|
||||
self.assertEqual(
|
||||
book.lines[0].payee.rec_name, 'Book 2 | 0.00 usd | Open')
|
||||
self.assertEqual(book.lines[0].payee.rec_name, 'Book 2 | 0.00 usd | Open')
|
||||
self.assertEqual(Line.search_count([('payee', 'ilike', 'book 2%')]), 1)
|
||||
|
||||
# set line to 'checked', this creates the counterpart
|
||||
Line.wfcheck(list(book.lines))
|
||||
|
||||
self.prep_valstore_run_worker()
|
||||
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|to|-1.00 usd|Transfer Out [Book 2 | 1.00 usd | Open]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|to|-1.00 usd|Transfer Out [Book 2 | 1.00 usd | Open]')
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
self.assertEqual(len(book.lines[0].references), 1)
|
||||
self.assertEqual(book.lines[0].reference, None)
|
||||
self.assertEqual(book.lines[0].references[0].id, book2.lines[0].id)
|
||||
|
||||
self.assertEqual(len(book2.lines), 1)
|
||||
self.assertEqual(
|
||||
book2.lines[0].rec_name,
|
||||
'05/01/2022|from|1.00 usd|Transfer Out [Book 1 | -1.00 usd | Open]')
|
||||
self.assertEqual(book2.lines[0].rec_name, '05/01/2022|from|1.00 usd|Transfer Out [Book 1 | -1.00 usd | Open]')
|
||||
self.assertEqual(book2.lines[0].state, 'check')
|
||||
self.assertEqual(
|
||||
book2.lines[0].reference.rec_name,
|
||||
'05/01/2022|to|-1.00 usd|Transfer Out [Book 2 | 1.00 usd | Open]')
|
||||
self.assertEqual(book2.lines[0].reference.rec_name, '05/01/2022|to|-1.00 usd|Transfer Out [Book 2 | 1.00 usd | Open]')
|
||||
self.assertEqual(len(book2.lines[0].references), 0)
|
||||
|
||||
@with_transaction()
|
||||
|
@ -1181,12 +1027,13 @@ class LineTestCase(object):
|
|||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Line = pool.get('cashbook.line')
|
||||
Category = pool.get('cashbook.category')
|
||||
|
||||
types = self.prep_type()
|
||||
category_in = self.prep_category(cattype='in')
|
||||
self.prep_category(name='Out Category', cattype='out')
|
||||
category_out = self.prep_category(name='Out Category', cattype='out')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
party = self.prep_party()
|
||||
|
||||
book2, = Book.create([{
|
||||
'name': 'Book 2',
|
||||
|
@ -1216,41 +1063,28 @@ class LineTestCase(object):
|
|||
self.assertEqual(book.rec_name, 'Book 1 | 1.00 usd | Open')
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(len(book2.lines), 0)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|from|1.00 usd|Transfer In [Book 2 | 0.00 usd | Open]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|from|1.00 usd|Transfer In [Book 2 | 0.00 usd | Open]')
|
||||
self.assertEqual(len(book.lines[0].references), 0)
|
||||
|
||||
# set line to 'checked', this creates the counterpart
|
||||
Line.wfcheck(list(book.lines))
|
||||
|
||||
self.prep_valstore_run_worker()
|
||||
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|from|1.00 usd|Transfer In [Book 2 | -1.00 usd | Open]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|from|1.00 usd|Transfer In [Book 2 | -1.00 usd | Open]')
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
self.assertEqual(len(book.lines[0].references), 1)
|
||||
self.assertEqual(book.lines[0].reference, None)
|
||||
self.assertEqual(book.lines[0].references[0].id, book2.lines[0].id)
|
||||
|
||||
self.assertEqual(len(book2.lines), 1)
|
||||
self.assertEqual(
|
||||
book2.lines[0].rec_name,
|
||||
'05/01/2022|to|-1.00 usd|Transfer In [Book 1 | 1.00 usd | Open]')
|
||||
self.assertEqual(book2.lines[0].rec_name, '05/01/2022|to|-1.00 usd|Transfer In [Book 1 | 1.00 usd | Open]')
|
||||
self.assertEqual(book2.lines[0].state, 'check')
|
||||
self.assertEqual(
|
||||
book2.lines[0].reference.rec_name,
|
||||
'05/01/2022|from|1.00 usd|Transfer In [Book 2 | -1.00 usd | Open]')
|
||||
self.assertEqual(book2.lines[0].reference.rec_name, '05/01/2022|from|1.00 usd|Transfer In [Book 2 | -1.00 usd | Open]')
|
||||
self.assertEqual(len(book2.lines[0].references), 0)
|
||||
|
||||
# tryt wfedit to 'book2.lines[0]'
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The current line is managed by the cashbook line " +
|
||||
"'05/01/2022|from|1.00 usd|Transfer In [Book 2 | -1.00 usd " +
|
||||
"| Open]', cashbook: 'Book 1 | 1.00 usd | Open'.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The current line is managed by the cashbook line '05/01/2022|from|1.00 usd|Transfer In [Book 2 | -1.00 usd | Open]', cashbook: 'Book 1 | 1.00 usd | Open'.",
|
||||
Line.wfedit,
|
||||
[book2.lines[0]])
|
||||
|
||||
|
@ -1264,6 +1098,8 @@ class LineTestCase(object):
|
|||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Line = pool.get('cashbook.line')
|
||||
Configuration = pool.get('cashbook.configuration')
|
||||
Category = pool.get('cashbook.category')
|
||||
|
||||
types = self.prep_type()
|
||||
category_in = self.prep_category(cattype='in')
|
||||
|
@ -1410,16 +1246,18 @@ class LineTestCase(object):
|
|||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Line = pool.get('cashbook.line')
|
||||
Configuration = pool.get('cashbook.configuration')
|
||||
Category = pool.get('cashbook.category')
|
||||
|
||||
types = self.prep_type()
|
||||
self.prep_category(cattype='in')
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
party = self.prep_party()
|
||||
|
||||
with Transaction().set_context({
|
||||
'company': company.id}):
|
||||
'company': company.id,
|
||||
}):
|
||||
|
||||
category2, = Category.create([{
|
||||
'company': company.id,
|
||||
|
@ -1561,11 +1399,8 @@ class LineTestCase(object):
|
|||
Book.wfclosed([book])
|
||||
self.assertEqual(book.state, 'closed')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The cashbook line '05/01/2022 Text 1' cannot be deleted " +
|
||||
"because the Cashbook 'Book | 2.00 usd | Closed' is" +
|
||||
" in state 'Closed'.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The cashbook line '05/01/2022 Text 1' cannot be deleted because the Cashbook 'Book | 2.00 usd | Closed' is in state 'Closed'.",
|
||||
Lines.delete,
|
||||
[book.lines[0]])
|
||||
|
||||
|
@ -1612,10 +1447,8 @@ class LineTestCase(object):
|
|||
Lines.wfcheck([book.lines[0]])
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The cashbook line '05/01/2022|1.00 usd|Test 1 [Cat1]' " +
|
||||
"cannot be deleted, its in state 'Checked'.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The cashbook line '05/01/2022|1.00 usd|Test 1 [Cat1]' cannot be deleted, its in state 'Checked'.",
|
||||
Lines.delete,
|
||||
[book.lines[0]])
|
||||
|
||||
|
@ -1672,7 +1505,8 @@ class LineTestCase(object):
|
|||
self.assertEqual(book.owner.rec_name, 'Frida'),
|
||||
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
# change to user 'diego' , try access
|
||||
with Transaction().set_user(usr_lst[1].id):
|
||||
lines = Line.search([])
|
||||
|
@ -1682,28 +1516,20 @@ class LineTestCase(object):
|
|||
with Transaction().set_user(usr_lst[0].id):
|
||||
lines = Line.search([])
|
||||
self.assertEqual(len(lines), 1)
|
||||
self.assertEqual(
|
||||
lines[0].cashbook.rec_name,
|
||||
'Fridas book | 1.00 usd | Open')
|
||||
self.assertEqual(
|
||||
lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
self.assertEqual(lines[0].cashbook.rec_name, 'Fridas book | 1.00 usd | Open')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
|
||||
Line.write(*[
|
||||
lines,
|
||||
{
|
||||
'description': 'Test 2',
|
||||
}])
|
||||
self.assertEqual(
|
||||
lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
self.assertEqual(
|
||||
lines[0].owner_cashbook.rec_name, 'Frida')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
self.assertEqual(lines[0].owner_cashbook.rec_name, 'Frida')
|
||||
|
||||
@with_transaction()
|
||||
def test_line_permission_reviewer(self):
|
||||
""" create book+line + 2x users + 1x reviewer-group,
|
||||
add users to group, check access
|
||||
""" create book+line + 2x users + 1x reviewer-group, add users to group, check access
|
||||
"""
|
||||
pool = Pool()
|
||||
ResUser = pool.get('res.user')
|
||||
|
@ -1761,47 +1587,37 @@ class LineTestCase(object):
|
|||
self.assertEqual(book.owner.rec_name, 'Frida'),
|
||||
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
# change to user 'diego' , try access
|
||||
with Transaction().set_user(usr_lst[1].id):
|
||||
lines = Line.search([])
|
||||
self.assertEqual(len(lines), 1)
|
||||
self.assertEqual(len(lines[0].cashbook.reviewer.users), 1)
|
||||
self.assertEqual(
|
||||
lines[0].cashbook.reviewer.users[0].rec_name,
|
||||
'Diego')
|
||||
self.assertEqual(
|
||||
lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
self.assertEqual(lines[0].cashbook.reviewer.users[0].rec_name, 'Diego')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
Line.write(*[
|
||||
lines,
|
||||
{
|
||||
'description': 'Test 2',
|
||||
}])
|
||||
self.assertEqual(
|
||||
lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
|
||||
# change to user 'frida' read/write line
|
||||
with Transaction().set_user(usr_lst[0].id):
|
||||
lines = Line.search([])
|
||||
self.assertEqual(len(lines), 1)
|
||||
self.assertEqual(
|
||||
lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
Line.write(*[
|
||||
lines,
|
||||
{
|
||||
'description': 'Test 3',
|
||||
}])
|
||||
self.assertEqual(
|
||||
lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Test 3 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 3 [Cat1]')
|
||||
|
||||
@with_transaction()
|
||||
def test_line_permission_observer(self):
|
||||
""" create book+line + 2x users + 1x observer-group,
|
||||
add users to group, check access
|
||||
""" create book+line + 2x users + 1x observer-group, add users to group, check access
|
||||
"""
|
||||
pool = Pool()
|
||||
ResUser = pool.get('res.user')
|
||||
|
@ -1859,25 +1675,18 @@ class LineTestCase(object):
|
|||
self.assertEqual(book.owner.rec_name, 'Frida'),
|
||||
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
# change to user 'diego' , try access
|
||||
with Transaction().set_user(usr_lst[1].id):
|
||||
lines = Line.search([])
|
||||
self.assertEqual(len(lines), 1)
|
||||
self.assertEqual(len(lines[0].cashbook.observer.users), 1)
|
||||
self.assertEqual(
|
||||
lines[0].cashbook.observer.users[0].rec_name,
|
||||
'Diego')
|
||||
self.assertEqual(
|
||||
lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
self.assertEqual(lines[0].cashbook.observer.users[0].rec_name, 'Diego')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
'You are not allowed to write to records ' +
|
||||
'"[0-9]{1,}" of "Cashbook Line" because of at least ' +
|
||||
'one of these rules:\nOwners and reviewers: ' +
|
||||
'Cashbook line write - ',
|
||||
self.assertRaisesRegex(UserError,
|
||||
'You are not allowed to write to records "[0-9]{1,}" of "Cashbook Line" because of at least one of these rules:\nOwners and reviewers: Cashbook line write - ',
|
||||
Line.write,
|
||||
*[
|
||||
lines,
|
||||
|
@ -1890,16 +1699,12 @@ class LineTestCase(object):
|
|||
with Transaction().set_user(usr_lst[0].id):
|
||||
lines = Line.search([])
|
||||
self.assertEqual(len(lines), 1)
|
||||
self.assertEqual(
|
||||
lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 1 [Cat1]')
|
||||
Line.write(*[
|
||||
lines,
|
||||
{
|
||||
'description': 'Test 2',
|
||||
}])
|
||||
self.assertEqual(
|
||||
lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
self.assertEqual(lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Test 2 [Cat1]')
|
||||
|
||||
# end LineTestCase
|
|
@ -1,37 +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 ModuleTestCase
|
||||
|
||||
from .type import TypeTestCase
|
||||
from .book import BookTestCase
|
||||
from .line import LineTestCase
|
||||
from .splitline import SplitLineTestCase
|
||||
from .config import ConfigTestCase
|
||||
from .category import CategoryTestCase
|
||||
from .reconciliation import ReconTestCase
|
||||
from .bookingwiz import BookingWizardTestCase
|
||||
from .valuestore import ValuestoreTestCase
|
||||
|
||||
|
||||
class CashbookTestCase(
|
||||
ValuestoreTestCase,
|
||||
BookingWizardTestCase,
|
||||
ReconTestCase,
|
||||
CategoryTestCase,
|
||||
ConfigTestCase,
|
||||
LineTestCase,
|
||||
SplitLineTestCase,
|
||||
BookTestCase,
|
||||
TypeTestCase,
|
||||
ModuleTestCase):
|
||||
'Test cashbook module'
|
||||
module = 'cashbook'
|
||||
|
||||
# end CashbookTestCase
|
||||
|
||||
|
||||
del ModuleTestCase
|
|
@ -3,16 +3,18 @@
|
|||
# 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.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class ReconTestCase(object):
|
||||
""" test reconciliation
|
||||
"""
|
||||
class ReconTestCase(ModuleTestCase):
|
||||
'Test cashbook reconciliation module'
|
||||
module = 'cashbook'
|
||||
|
||||
@with_transaction()
|
||||
def test_recon_check_overlap_start(self):
|
||||
""" create, check deny of overlap date - date_from
|
||||
|
@ -22,7 +24,7 @@ class ReconTestCase(object):
|
|||
Reconciliation = pool.get('cashbook.recon')
|
||||
|
||||
types = self.prep_type()
|
||||
self.prep_category(cattype='in')
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
|
@ -39,21 +41,18 @@ class ReconTestCase(object):
|
|||
}])
|
||||
|
||||
Book.write(*[
|
||||
[book], {'reconciliations': [('create', [{
|
||||
[book],
|
||||
{
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 6, 1),
|
||||
'date_from': date(2022, 6, 1),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(
|
||||
book.reconciliations[1].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[1].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
self.assertRaisesRegex(UserError,
|
||||
'The date range overlaps with another reconciliation.',
|
||||
Reconciliation.write,
|
||||
*[
|
||||
|
@ -73,7 +72,7 @@ class ReconTestCase(object):
|
|||
Reconciliation = pool.get('cashbook.recon')
|
||||
|
||||
types = self.prep_type()
|
||||
self.prep_category(cattype='in')
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
|
@ -90,21 +89,18 @@ class ReconTestCase(object):
|
|||
}])
|
||||
|
||||
Book.write(*[
|
||||
[book], {'reconciliations': [('create', [{
|
||||
[book],
|
||||
{
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 6, 1),
|
||||
'date_from': date(2022, 6, 1),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(
|
||||
book.reconciliations[1].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[1].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
self.assertRaisesRegex(UserError,
|
||||
'The date range overlaps with another reconciliation.',
|
||||
Reconciliation.write,
|
||||
*[
|
||||
|
@ -123,7 +119,7 @@ class ReconTestCase(object):
|
|||
Reconciliation = pool.get('cashbook.recon')
|
||||
|
||||
types = self.prep_type()
|
||||
self.prep_category(cattype='in')
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
|
@ -140,21 +136,18 @@ class ReconTestCase(object):
|
|||
}])
|
||||
|
||||
Book.write(*[
|
||||
[book], {'reconciliations': [('create', [{
|
||||
[book],
|
||||
{
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 6, 1),
|
||||
'date_from': date(2022, 6, 1),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(
|
||||
book.reconciliations[1].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[1].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
self.assertRaisesRegex(UserError,
|
||||
'The date range overlaps with another reconciliation.',
|
||||
Reconciliation.write,
|
||||
*[
|
||||
|
@ -174,7 +167,7 @@ class ReconTestCase(object):
|
|||
Reconciliation = pool.get('cashbook.recon')
|
||||
|
||||
types = self.prep_type()
|
||||
self.prep_category(cattype='in')
|
||||
category = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
|
@ -191,21 +184,18 @@ class ReconTestCase(object):
|
|||
}])
|
||||
|
||||
Book.write(*[
|
||||
[book], {'reconciliations': [('create', [{
|
||||
[book],
|
||||
{
|
||||
'reconciliations': [('create', [{
|
||||
'date': date(2022, 6, 1),
|
||||
'date_from': date(2022, 6, 1),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])],
|
||||
}])
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(
|
||||
book.reconciliations[1].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[1].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
self.assertRaisesRegex(UserError,
|
||||
'The date range overlaps with another reconciliation.',
|
||||
Reconciliation.write,
|
||||
*[
|
||||
|
@ -240,15 +230,11 @@ class ReconTestCase(object):
|
|||
}])],
|
||||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].feature, 'gen')
|
||||
|
||||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
|
||||
@with_transaction()
|
||||
def test_recon_set_start_amount_by_predecessor(self):
|
||||
|
@ -293,18 +279,14 @@ class ReconTestCase(object):
|
|||
}])
|
||||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(len(book.reconciliations), 1)
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 0)
|
||||
|
||||
Lines.wfcheck(list(book.lines))
|
||||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
|
||||
self.assertEqual(book.reconciliations[0].state, 'check')
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 12.00 usd [2]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 12.00 usd [2]')
|
||||
Reconciliation.wfdone(list(book.reconciliations))
|
||||
self.assertEqual(book.reconciliations[0].state, 'done')
|
||||
|
||||
|
@ -313,13 +295,9 @@ class ReconTestCase(object):
|
|||
'date_from': date(2022, 5, 31),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])
|
||||
self.assertEqual(
|
||||
recons[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(recons[0].rec_name, '05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
Reconciliation.wfcheck(recons)
|
||||
self.assertEqual(
|
||||
recons[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 12.00 usd - 12.00 usd [0]')
|
||||
self.assertEqual(recons[0].rec_name, '05/31/2022 - 06/30/2022 | 12.00 usd - 12.00 usd [0]')
|
||||
|
||||
@with_transaction()
|
||||
def test_recon_predecessor_done(self):
|
||||
|
@ -347,9 +325,7 @@ class ReconTestCase(object):
|
|||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].state, 'check')
|
||||
|
||||
recons = Reconciliation.create([{
|
||||
|
@ -357,20 +333,14 @@ class ReconTestCase(object):
|
|||
'date_from': date(2022, 5, 31),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The predecessor " +
|
||||
"'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]' " +
|
||||
"must be in the 'Done' state before you can check the " +
|
||||
"current reconciliation " +
|
||||
"'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]'.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The predecessor '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]' must be in the 'Done' state before you can check the current reconciliation '05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]'.",
|
||||
Reconciliation.wfcheck,
|
||||
recons)
|
||||
|
||||
@with_transaction()
|
||||
def test_recon_autoset_date_to(self):
|
||||
""" create reconciliation, check:
|
||||
set date_to to last date of checked-line
|
||||
""" create reconciliation, check: set date_to to last date of checked-line
|
||||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
|
@ -413,14 +383,10 @@ class ReconTestCase(object):
|
|||
'date_to': date(2022, 5, 31),
|
||||
}])
|
||||
# dates are updates by .create()
|
||||
self.assertEqual(
|
||||
recon.rec_name,
|
||||
'05/01/2022 - 05/18/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(recon.rec_name, '05/01/2022 - 05/18/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
|
||||
Reconciliation.wfcheck([recon])
|
||||
self.assertEqual(
|
||||
recon.rec_name,
|
||||
'05/01/2022 - 05/18/2022 | 0.00 usd - 15.00 usd [2]')
|
||||
self.assertEqual(recon.rec_name, '05/01/2022 - 05/18/2022 | 0.00 usd - 15.00 usd [2]')
|
||||
|
||||
@with_transaction()
|
||||
def test_recon_autoset_date_from(self):
|
||||
|
@ -451,8 +417,7 @@ class ReconTestCase(object):
|
|||
Reconciliation.wfdone([book.reconciliations[0]])
|
||||
|
||||
# date_from is corrected by .create() to start_date of book
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
self.assertEqual(book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
|
||||
r2, = Reconciliation.create([{
|
||||
|
@ -460,9 +425,7 @@ class ReconTestCase(object):
|
|||
'date_from': date(2022, 6, 10),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])
|
||||
self.assertEqual(
|
||||
r2.rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(r2.rec_name, '05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
|
||||
# update 'date_from' to wrong value
|
||||
Reconciliation.write(*[
|
||||
|
@ -470,15 +433,10 @@ class ReconTestCase(object):
|
|||
{
|
||||
'date_from': date(2022, 6, 1),
|
||||
}])
|
||||
self.assertEqual(
|
||||
r2.rec_name,
|
||||
'06/01/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(r2.rec_name, '06/01/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The start date '06/01/2022' of the current reconciliation" +
|
||||
" '06/01/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]' " +
|
||||
"must correspond to the end date '05/31/2022' of the predecessor.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The start date '06/01/2022' of the current reconciliation '06/01/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]' must correspond to the end date '05/31/2022' of the predecessor.",
|
||||
Reconciliation.wfcheck,
|
||||
[r2])
|
||||
|
||||
|
@ -526,23 +484,14 @@ class ReconTestCase(object):
|
|||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(len(book.lines), 2)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name,
|
||||
'05/05/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/05/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(len(book.reconciliations), 1)
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 0)
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"For reconciliation, the line " +
|
||||
"'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]' must be in the " +
|
||||
"status 'Check' or 'Done'.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"For reconciliation, the line '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]' must be in the status 'Check' or 'Done'.",
|
||||
Lines.write,
|
||||
*[
|
||||
[book.lines[0]],
|
||||
|
@ -559,11 +508,8 @@ class ReconTestCase(object):
|
|||
}])
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 2)
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The status cannot be changed to 'Edit' as long as the line " +
|
||||
"'05/01/2022|1.00 usd|Text 1 [Cat1]' is associated " +
|
||||
"with a reconciliation.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The status cannot be changed to 'Edit' as long as the line '05/01/2022|1.00 usd|Text 1 [Cat1]' is associated with a reconciliation.",
|
||||
Lines.wfedit,
|
||||
[book.lines[0]])
|
||||
|
||||
|
@ -587,16 +533,10 @@ class ReconTestCase(object):
|
|||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
self.assertEqual(book.reconciliations[0].state, 'check')
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 1)
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.reconciliations[0].lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].state, 'check')
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name,
|
||||
'06/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '06/01/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[1].state, 'edit')
|
||||
|
||||
# move 1st line into date-range of checked-reconciliation, wf-check
|
||||
|
@ -605,10 +545,8 @@ class ReconTestCase(object):
|
|||
{
|
||||
'date': date(2022, 5, 20),
|
||||
}])
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"For the date '05/20/2022' there is already a completed " +
|
||||
"reconciliation. Use a different date.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"For the date '05/20/2022' there is already a completed reconciliation. Use a different date.",
|
||||
Lines.wfcheck,
|
||||
[book.lines[1]])
|
||||
|
||||
|
@ -633,12 +571,8 @@ class ReconTestCase(object):
|
|||
'date_from': date(2022, 5, 31),
|
||||
'date_to': date(2022, 6, 30),
|
||||
}])
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(
|
||||
book.reconciliations[1].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 1.00 usd [1]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/31/2022 - 06/30/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[1].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 1.00 usd [1]')
|
||||
Reconciliation.wfdone([book.reconciliations[1]])
|
||||
Reconciliation.wfcheck([recon2])
|
||||
|
||||
|
@ -647,10 +581,8 @@ class ReconTestCase(object):
|
|||
{
|
||||
'date': date(2022, 5, 31),
|
||||
}])
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"For the date '05/31/2022' there is already a completed " +
|
||||
"reconciliation. Use a different date.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"For the date '05/31/2022' there is already a completed reconciliation. Use a different date.",
|
||||
Lines.wfcheck,
|
||||
[book.lines[1]])
|
||||
|
||||
|
@ -698,19 +630,13 @@ class ReconTestCase(object):
|
|||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(len(book.lines), 2)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name,
|
||||
'06/05/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '06/05/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
|
||||
Lines.wfcheck([book.lines[0]])
|
||||
Reconciliation.wfcheck([book.reconciliations[0]])
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 1)
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.reconciliations[0].lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
|
||||
Lines.write(*[
|
||||
[book.lines[1]],
|
||||
|
@ -718,11 +644,8 @@ class ReconTestCase(object):
|
|||
'date': date(2022, 5, 15),
|
||||
}])
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"In the date range from 05/01/2022 to 05/31/2022, " +
|
||||
"there are still cashbook lines that do not belong " +
|
||||
"to any reconciliation.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"In the date range from 05/01/2022 to 05/31/2022, there are still cashbook lines that do not belong to any reconciliation.",
|
||||
Reconciliation.wfdone,
|
||||
[book.reconciliations[0]])
|
||||
|
||||
|
@ -768,27 +691,20 @@ class ReconTestCase(object):
|
|||
self.assertEqual(len(book.reconciliations), 1)
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 1)
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The reconciliation '05/01/2022 - 05/31/2022 " +
|
||||
"| 0.00 - 0.00 usd [0]' cannot be deleted, its in state 'Check'.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The reconciliation '05/01/2022 - 05/31/2022 | 0.00 - 0.00 usd [0]' cannot be deleted, its in state 'Check'.",
|
||||
Reconciliation.delete,
|
||||
list(book.reconciliations))
|
||||
|
||||
Book.wfclosed([book])
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The cashbook line '05/01/2022 - 05/31/2022: 0.00 usd' " +
|
||||
"cannot be deleted because the Cashbook " +
|
||||
"'Book 1 | 1.00 usd | Closed' is in state 'Closed'.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The cashbook line '05/01/2022 - 05/31/2022: 0.00 usd' cannot be deleted because the Cashbook 'Book 1 | 1.00 usd | Closed' is in state 'Closed'.",
|
||||
Reconciliation.delete,
|
||||
list(book.reconciliations))
|
||||
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"The cash book 'Book 1 | 1.00 usd | Closed' is 'Closed' " +
|
||||
"and cannot be changed.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"The cash book 'Book 1 | 1.00 usd | Closed' is 'Closed' and cannot be changed.",
|
||||
Reconciliation.write,
|
||||
*[
|
||||
list(book.reconciliations),
|
||||
|
@ -841,27 +757,17 @@ class ReconTestCase(object):
|
|||
self.assertEqual(book.name, 'Book 1')
|
||||
self.assertEqual(book.state, 'open')
|
||||
self.assertEqual(len(book.lines), 2)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(
|
||||
book.lines[1].rec_name,
|
||||
'05/05/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[1].rec_name, '05/05/2022|Rev|1.00 usd|Text 2 [Cat1]')
|
||||
self.assertEqual(book.lines[0].reconciliation, None)
|
||||
self.assertEqual(book.lines[1].reconciliation, None)
|
||||
self.assertEqual(len(book.reconciliations), 1)
|
||||
self.assertEqual(
|
||||
book.reconciliations[0].rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(book.reconciliations[0].rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]')
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 0)
|
||||
|
||||
# run wf, fail with lines not 'checked'
|
||||
self.assertRaisesRegex(
|
||||
UserError,
|
||||
"For the reconciliation '05/01/2022 - 05/31/2022 | " +
|
||||
"0.00 usd - 0.00 usd [0]' of the cashbook " +
|
||||
"'Book 1 | 2.00 usd | Open', all lines in the date range " +
|
||||
"from '05/01/2022' to '05/31/2022' must be in the 'Check' state.",
|
||||
self.assertRaisesRegex(UserError,
|
||||
"For the reconciliation '05/01/2022 - 05/31/2022 | 0.00 usd - 0.00 usd [0]' of the cashbook 'Book 1 | 2.00 usd | Open', all lines in the date range from '05/01/2022' to '05/31/2022' must be in the 'Check' state.",
|
||||
Reconciliation.wfcheck,
|
||||
list(book.reconciliations),
|
||||
)
|
||||
|
@ -870,12 +776,8 @@ class ReconTestCase(object):
|
|||
Lines.wfcheck(book.lines)
|
||||
Reconciliation.wfcheck(list(book.reconciliations))
|
||||
self.assertEqual(len(book.reconciliations[0].lines), 2)
|
||||
self.assertEqual(
|
||||
book.lines[0].reconciliation.rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 2.00 usd [2]')
|
||||
self.assertEqual(
|
||||
book.lines[1].reconciliation.rec_name,
|
||||
'05/01/2022 - 05/31/2022 | 0.00 usd - 2.00 usd [2]')
|
||||
self.assertEqual(book.lines[0].reconciliation.rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 2.00 usd [2]')
|
||||
self.assertEqual(book.lines[1].reconciliation.rec_name, '05/01/2022 - 05/31/2022 | 0.00 usd - 2.00 usd [2]')
|
||||
|
||||
# check --> edit
|
||||
Reconciliation.wfedit(list(book.reconciliations))
|
|
@ -3,15 +3,18 @@
|
|||
# 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.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
from datetime import date
|
||||
from unittest.mock import MagicMock
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
class SplitLineTestCase(object):
|
||||
""" test split lines
|
||||
"""
|
||||
class SplitLineTestCase(ModuleTestCase):
|
||||
'Test split line module'
|
||||
module = 'cashbook'
|
||||
|
||||
@with_transaction()
|
||||
def test_splitline_in_category(self):
|
||||
|
@ -19,11 +22,12 @@ class SplitLineTestCase(object):
|
|||
"""
|
||||
pool = Pool()
|
||||
Book = pool.get('cashbook.book')
|
||||
Line = pool.get('cashbook.line')
|
||||
|
||||
types = self.prep_type()
|
||||
category1 = self.prep_category(cattype='in')
|
||||
company = self.prep_company()
|
||||
self.prep_party()
|
||||
party = self.prep_party()
|
||||
book, = Book.create([{
|
||||
'name': 'Book 1',
|
||||
'btype': types.id,
|
||||
|
@ -55,9 +59,7 @@ class SplitLineTestCase(object):
|
|||
}])],
|
||||
}])
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev/Sp|11.00 usd|- [-]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev/Sp|11.00 usd|- [-]')
|
||||
self.assertEqual(book.lines[0].category, None)
|
||||
self.assertEqual(len(book.lines[0].splitlines), 2)
|
||||
|
||||
|
@ -66,33 +68,11 @@ class SplitLineTestCase(object):
|
|||
self.assertEqual(book.lines[0].splitlines[1].feature, 'gen')
|
||||
self.assertEqual(book.lines[0].splitlines[1].booktransf_feature, None)
|
||||
|
||||
self.assertEqual(
|
||||
book.lines[0].splitlines[0].rec_name,
|
||||
self.assertEqual(book.lines[0].splitlines[0].rec_name,
|
||||
'Rev/Sp|5.00 usd|from category [Cat1]')
|
||||
self.assertEqual(
|
||||
book.lines[0].splitlines[1].rec_name,
|
||||
self.assertEqual(book.lines[0].splitlines[1].rec_name,
|
||||
'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()
|
||||
def test_splitline_category_and_transfer(self):
|
||||
""" add book, line, two split-lines,
|
||||
|
@ -131,9 +111,7 @@ class SplitLineTestCase(object):
|
|||
}])
|
||||
self.assertEqual(books[0].rec_name, 'Book 1 | 1.00 usd | Open')
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(books[0].lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(books[1].rec_name, 'Book 2 | 0.00 usd | Open')
|
||||
|
||||
Book.write(*[
|
||||
|
@ -155,26 +133,20 @@ class SplitLineTestCase(object):
|
|||
})]
|
||||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/01/2022|Rev/Sp|11.00 usd|Text 1 [-]')
|
||||
self.assertEqual(books[0].lines[0].rec_name, '05/01/2022|Rev/Sp|11.00 usd|Text 1 [-]')
|
||||
self.assertEqual(books[0].lines[0].category, None)
|
||||
self.assertEqual(len(books[0].lines[0].splitlines), 2)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].splitlines[0].rec_name,
|
||||
self.assertEqual(books[0].lines[0].splitlines[0].rec_name,
|
||||
'Rev/Sp|5.00 usd|from category [Cat1]')
|
||||
self.assertEqual(
|
||||
books[0].lines[0].splitlines[1].rec_name,
|
||||
self.assertEqual(books[0].lines[0].splitlines[1].rec_name,
|
||||
'Rev/Sp|6.00 usd|from cashbook [Book 2 | 0.00 usd | Open]')
|
||||
self.assertEqual(len(books[1].lines), 0)
|
||||
self.assertEqual(books[0].lines[0].splitlines[0].feature, 'gen')
|
||||
|
||||
self.assertEqual(books[0].lines[0].splitlines[0].feature, 'gen')
|
||||
self.assertEqual(
|
||||
books[0].lines[0].splitlines[0].booktransf_feature, None)
|
||||
self.assertEqual(books[0].lines[0].splitlines[0].booktransf_feature, None)
|
||||
self.assertEqual(books[0].lines[0].splitlines[1].feature, 'gen')
|
||||
self.assertEqual(
|
||||
books[0].lines[0].splitlines[1].booktransf_feature, 'gen')
|
||||
self.assertEqual(books[0].lines[0].splitlines[1].booktransf_feature, 'gen')
|
||||
|
||||
# wf: edit -> check
|
||||
Line.wfcheck(books[0].lines)
|
||||
|
@ -182,16 +154,13 @@ class SplitLineTestCase(object):
|
|||
self.assertEqual(books[0].lines[0].state, 'check')
|
||||
self.assertEqual(books[0].lines[0].number, '1')
|
||||
self.assertEqual(len(books[0].lines[0].references), 1)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].references[0].rec_name,
|
||||
self.assertEqual(books[0].lines[0].references[0].rec_name,
|
||||
'05/01/2022|to|-6.00 usd|from cashbook [Book 1 | 11.00 usd | Open]')
|
||||
|
||||
self.assertEqual(len(books[1].lines), 1)
|
||||
self.assertEqual(
|
||||
books[1].lines[0].reference.rec_name,
|
||||
self.assertEqual(books[1].lines[0].reference.rec_name,
|
||||
'05/01/2022|Rev/Sp|11.00 usd|Text 1 [-]')
|
||||
self.assertEqual(
|
||||
books[1].lines[0].rec_name,
|
||||
self.assertEqual(books[1].lines[0].rec_name,
|
||||
'05/01/2022|to|-6.00 usd|from cashbook [Book 1 | 11.00 usd | Open]')
|
||||
|
||||
# wf: check --> edit
|
||||
|
@ -240,9 +209,7 @@ class SplitLineTestCase(object):
|
|||
}])
|
||||
self.assertEqual(books[0].rec_name, 'Book 1 | -1.00 € | Open')
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/01/2022|Exp|-1.00 €|Text 1 [Cat1]')
|
||||
self.assertEqual(books[0].lines[0].rec_name, '05/01/2022|Exp|-1.00 €|Text 1 [Cat1]')
|
||||
self.assertEqual(books[1].rec_name, 'Book 2 | 0.00 usd | Open')
|
||||
|
||||
# EUR --> USD
|
||||
|
@ -265,22 +232,15 @@ class SplitLineTestCase(object):
|
|||
})]
|
||||
}])
|
||||
self.assertEqual(len(books[0].lines), 1)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].rec_name,
|
||||
'05/01/2022|Exp/Sp|-11.00 €|Text 1 [-]')
|
||||
self.assertEqual(books[0].lines[0].rec_name, '05/01/2022|Exp/Sp|-11.00 €|Text 1 [-]')
|
||||
self.assertEqual(books[0].lines[0].category, None)
|
||||
self.assertEqual(len(books[0].lines[0].splitlines), 2)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].splitlines[0].rec_name,
|
||||
self.assertEqual(books[0].lines[0].splitlines[0].rec_name,
|
||||
'Exp/Sp|5.00 €|to category [Cat1]')
|
||||
self.assertEqual(
|
||||
books[0].lines[0].splitlines[0].amount_2nd_currency, None)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].splitlines[1].rec_name,
|
||||
self.assertEqual(books[0].lines[0].splitlines[0].amount_2nd_currency, None)
|
||||
self.assertEqual(books[0].lines[0].splitlines[1].rec_name,
|
||||
'Exp/Sp|6.00 €|to book2 [Book 2 | 0.00 usd | Open]')
|
||||
self.assertEqual(
|
||||
books[0].lines[0].splitlines[1].amount_2nd_currency,
|
||||
Decimal('6.3'))
|
||||
self.assertEqual(books[0].lines[0].splitlines[1].amount_2nd_currency, Decimal('6.3'))
|
||||
self.assertEqual(len(books[1].lines), 0)
|
||||
|
||||
# wf: edit -> check
|
||||
|
@ -289,21 +249,16 @@ class SplitLineTestCase(object):
|
|||
self.assertEqual(books[0].lines[0].state, 'check')
|
||||
self.assertEqual(books[0].lines[0].number, '1')
|
||||
self.assertEqual(len(books[0].lines[0].references), 1)
|
||||
self.assertEqual(
|
||||
books[0].lines[0].references[0].rec_name,
|
||||
self.assertEqual(books[0].lines[0].references[0].rec_name,
|
||||
'05/01/2022|from|6.30 usd|to book2 [Book 1 | -11.00 € | Open]')
|
||||
|
||||
self.assertEqual(len(books[1].lines), 1)
|
||||
self.assertEqual(
|
||||
books[1].lines[0].reference.rec_name,
|
||||
self.assertEqual(books[1].lines[0].reference.rec_name,
|
||||
'05/01/2022|Exp/Sp|-11.00 €|Text 1 [-]')
|
||||
self.assertEqual(
|
||||
books[1].lines[0].rec_name,
|
||||
self.assertEqual(books[1].lines[0].rec_name,
|
||||
'05/01/2022|from|6.30 usd|to book2 [Book 1 | -11.00 € | Open]')
|
||||
self.assertEqual(
|
||||
books[1].lines[0].amount, Decimal('6.3'))
|
||||
self.assertEqual(
|
||||
books[1].lines[0].amount_2nd_currency, Decimal('6.0'))
|
||||
self.assertEqual(books[1].lines[0].amount, Decimal('6.3'))
|
||||
self.assertEqual(books[1].lines[0].amount_2nd_currency, Decimal('6.0'))
|
||||
|
||||
# wf: check --> edit
|
||||
Line.wfedit(books[0].lines)
|
||||
|
@ -343,9 +298,7 @@ class SplitLineTestCase(object):
|
|||
}])
|
||||
|
||||
self.assertEqual(len(book.lines), 1)
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|1.00 usd|Text 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].amount, Decimal('1.0'))
|
||||
self.assertEqual(book.lines[0].category.rec_name, 'Cat1')
|
||||
|
||||
|
@ -364,9 +317,7 @@ class SplitLineTestCase(object):
|
|||
}])],
|
||||
}])
|
||||
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev/Sp|7.00 usd|Text 1 [-]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev/Sp|7.00 usd|Text 1 [-]')
|
||||
self.assertEqual(book.lines[0].amount, Decimal('7.0'))
|
||||
self.assertEqual(book.lines[0].category, None)
|
||||
|
||||
|
@ -374,22 +325,17 @@ class SplitLineTestCase(object):
|
|||
self.assertEqual(book.lines[0].splitlines[0].amount, Decimal('5.0'))
|
||||
self.assertEqual(book.lines[0].splitlines[0].category.rec_name, 'Cat1')
|
||||
self.assertEqual(book.lines[0].splitlines[0].description, 'line 1')
|
||||
self.assertEqual(
|
||||
book.lines[0].splitlines[0].rec_name,
|
||||
'Rev/Sp|5.00 usd|line 1 [Cat1]')
|
||||
self.assertEqual(book.lines[0].splitlines[0].rec_name, 'Rev/Sp|5.00 usd|line 1 [Cat1]')
|
||||
|
||||
self.assertEqual(book.lines[0].splitlines[1].amount, Decimal('2.0'))
|
||||
self.assertEqual(book.lines[0].splitlines[1].category.rec_name, 'Cat2')
|
||||
self.assertEqual(book.lines[0].splitlines[1].description, 'line 2')
|
||||
self.assertEqual(
|
||||
book.lines[0].splitlines[1].rec_name,
|
||||
'Rev/Sp|2.00 usd|line 2 [Cat2]')
|
||||
self.assertEqual(book.lines[0].splitlines[1].rec_name, 'Rev/Sp|2.00 usd|line 2 [Cat2]')
|
||||
|
||||
Lines.write(*[
|
||||
[book.lines[0]],
|
||||
{
|
||||
'splitlines': [
|
||||
('write',
|
||||
'splitlines': [('write',
|
||||
[book.lines[0].splitlines[0]],
|
||||
{
|
||||
'amount': Decimal('3.5'),
|
||||
|
@ -406,9 +352,7 @@ class SplitLineTestCase(object):
|
|||
'amount': Decimal('7.5'),
|
||||
'category': category2.id,
|
||||
}])
|
||||
self.assertEqual(
|
||||
book.lines[0].rec_name,
|
||||
'05/01/2022|Rev|7.50 usd|Text 1 [Cat2]')
|
||||
self.assertEqual(book.lines[0].rec_name, '05/01/2022|Rev|7.50 usd|Text 1 [Cat2]')
|
||||
self.assertEqual(book.lines[0].category.rec_name, 'Cat2')
|
||||
self.assertEqual(len(book.lines[0].splitlines), 0)
|
||||
|
|
@ -3,15 +3,16 @@
|
|||
# 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.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.exceptions import UserError
|
||||
|
||||
|
||||
class TypeTestCase(object):
|
||||
""" test types
|
||||
"""
|
||||
class TypeTestCase(ModuleTestCase):
|
||||
'Test cashbook type module'
|
||||
module = 'cashbook'
|
||||
|
||||
def prep_type(self, name='Cash', short='CAS'):
|
||||
""" create book-type
|
||||
"""
|
|
@ -1,840 +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 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,11 +1,10 @@
|
|||
[tryton]
|
||||
version=7.0.0
|
||||
version=6.0.25
|
||||
depends:
|
||||
res
|
||||
currency
|
||||
party
|
||||
company
|
||||
irrulecontext
|
||||
xml:
|
||||
icon.xml
|
||||
group.xml
|
||||
|
@ -22,4 +21,3 @@ xml:
|
|||
wizard_runreport.xml
|
||||
wizard_booking.xml
|
||||
menu.xml
|
||||
cron.xml
|
||||
|
|
26
types.py
26
types.py
|
@ -3,7 +3,7 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.model import ModelView, ModelSQL, fields, Unique, Index
|
||||
from trytond.model import ModelView, ModelSQL, fields, Unique
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.i18n import gettext
|
||||
|
||||
|
@ -14,11 +14,9 @@ class Type(ModelSQL, ModelView):
|
|||
|
||||
name = fields.Char(string='Name', required=True, translate=True)
|
||||
short = fields.Char(string='Abbreviation', required=True, size=3)
|
||||
company = fields.Many2One(
|
||||
string='Company', model_name='company.company',
|
||||
company = fields.Many2One(string='Company', model_name='company.company',
|
||||
required=True, ondelete="RESTRICT")
|
||||
feature = fields.Selection(
|
||||
string='Feature', required=True,
|
||||
feature = fields.Selection(string='Feature', required=True,
|
||||
selection='get_sel_feature',
|
||||
help='Select feature set of the Cashbook.')
|
||||
|
||||
|
@ -28,15 +26,8 @@ class Type(ModelSQL, ModelView):
|
|||
cls._order.insert(0, ('name', 'ASC'))
|
||||
t = cls.__table__()
|
||||
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
|
||||
def default_feature(cls):
|
||||
|
@ -55,16 +46,17 @@ class Type(ModelSQL, ModelView):
|
|||
"""
|
||||
return '%(short)s - %(name)s' % {
|
||||
'short': self.short or '-',
|
||||
'name': self.name or '-'}
|
||||
'name': self.name or '-',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def search_rec_name(cls, name, clause):
|
||||
""" search in name + short
|
||||
"""
|
||||
return [
|
||||
'OR',
|
||||
return ['OR',
|
||||
('name',) + tuple(clause[1:]),
|
||||
('short',) + tuple(clause[1:])]
|
||||
('short',) + tuple(clause[1:]),
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
|
|
217
valuestore.py
217
valuestore.py
|
@ -1,217 +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 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
|
||||
|
||||
|
|
|
@ -20,15 +20,14 @@ full copyright notices and license terms. -->
|
|||
<newline/>
|
||||
|
||||
<notebook colspan="4">
|
||||
<page name="balance" string="Balance" col="6">
|
||||
<separator colspan="2" id="balance" string="Balance"/>
|
||||
<newline/>
|
||||
<page name="balance" string="Balance" col="4">
|
||||
<separator colspan="4" id="balance" string="Balance"/>
|
||||
<label name="balance"/>
|
||||
<field name="balance" symbol="currency"/>
|
||||
<newline/>
|
||||
|
||||
<label name="balance_all"/>
|
||||
<field name="balance_all" symbol="currency"/>
|
||||
<newline/>
|
||||
<label name="balance_ref"/>
|
||||
<field name="balance_ref" symbol="company_currency"/>
|
||||
</page>
|
||||
|
|
|
@ -4,8 +4,6 @@ The COPYRIGHT file at the top level of this repository contains the
|
|||
full copyright notices and license terms. -->
|
||||
<tree keyword_open="1">
|
||||
<field name="rec_name" expand="1"/>
|
||||
<field name="balance" sum="1" symbol="currency"/>
|
||||
<field name="balance_all" symbol="currency" optional="1"/>
|
||||
<field name="balance_ref" symbol="company_currency" optional="1"/>
|
||||
<field name="state" optional="0"/>
|
||||
<field name="balance" sum="Balance" symbol="currency"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
|
|
|
@ -5,9 +5,7 @@ full copyright notices and license terms. -->
|
|||
<tree keyword_open="1" tree_state="1">
|
||||
<field name="name" expand="1"/>
|
||||
<field name="balance" symbol="currency"/>
|
||||
<field name="balance_all" symbol="currency" optional="1"/>
|
||||
<field name="balance_ref" symbol="company_currency" optional="1"/>
|
||||
<field name="state" optional="0"/>
|
||||
<field name="state"/>
|
||||
<field name="parent" tree_invisible="1"/>
|
||||
<field name="childs" tree_invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -28,10 +28,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<label name="book5"/>
|
||||
<field name="book5"/>
|
||||
|
||||
<label name="fixate"/>
|
||||
<field name="fixate"/>
|
||||
<newline/>
|
||||
|
||||
<separator id="sepcb" colspan="4" string="Cashbook"/>
|
||||
<label name="catnamelong"/>
|
||||
<field name="catnamelong"/>
|
||||
|
|
|
@ -22,10 +22,6 @@ full copyright notices and license terms. -->
|
|||
<page id="descr" string="Description" col="1">
|
||||
<field name="description"/>
|
||||
</page>
|
||||
<page name="fixate" col="2">
|
||||
<label name="fixate"/>
|
||||
<field name="fixate"/>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
<field name="cashbooks"/>
|
||||
|
@ -33,3 +29,4 @@ full copyright notices and license terms. -->
|
|||
<field name="currency"/>
|
||||
<field name="owner_cashbook"/>
|
||||
</form>
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ The COPYRIGHT file at the top level of this repository contains the
|
|||
full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="cashbook" tree_invisible="1"/>
|
||||
<field name="number" optional="0"/>
|
||||
<field name="number"/>
|
||||
<field name="date"/>
|
||||
<field name="payee"/>
|
||||
<field name="category_view"/>
|
||||
<field name="descr_short" expand="1"/>
|
||||
<field name="credit" sum="1" optional="0"/>
|
||||
<field name="debit" sum="1" optional="0"/>
|
||||
<field name="balance" optional="0"/>
|
||||
<field name="state" optional="0"/>
|
||||
<field name="credit" sum="Credit"/>
|
||||
<field name="debit" sum="Debit"/>
|
||||
<field name="balance"/>
|
||||
<field name="state"/>
|
||||
<button name="wfcheck"/>
|
||||
</tree>
|
||||
|
|
|
@ -4,13 +4,13 @@ The COPYRIGHT file at the top level of this repository contains the
|
|||
full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="cashbook" tree_invisible="1"/>
|
||||
<field name="number" optional="0"/>
|
||||
<field name="date" optional="0"/>
|
||||
<field name="payee" optional="0"/>
|
||||
<field name="category_view" optional="0"/>
|
||||
<field name="descr_short" expand="1" optional="0"/>
|
||||
<field name="credit" sum="1" optional="0"/>
|
||||
<field name="debit" sum="1" optional="0"/>
|
||||
<field name="state" optional="0"/>
|
||||
<field name="number"/>
|
||||
<field name="date"/>
|
||||
<field name="payee"/>
|
||||
<field name="category_view"/>
|
||||
<field name="descr_short" expand="1"/>
|
||||
<field name="credit" sum="Credit"/>
|
||||
<field name="debit" sum="Debit"/>
|
||||
<field name="state"/>
|
||||
<button name="wfrecon"/>
|
||||
</tree>
|
||||
|
|
|
@ -4,11 +4,11 @@ The COPYRIGHT file at the top level of this repository contains the
|
|||
full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="cashbook"/>
|
||||
<field name="date" optional="0"/>
|
||||
<field name="date_from" optional="0"/>
|
||||
<field name="date_to" optional="0"/>
|
||||
<field name="start_amount" optional="0"/>
|
||||
<field name="end_amount" optional="0"/>
|
||||
<field name="lines" optional="0"/>
|
||||
<field name="state" optional="0"/>
|
||||
<field name="date"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
<field name="start_amount"/>
|
||||
<field name="end_amount"/>
|
||||
<field name="lines"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
|
|
|
@ -8,7 +8,7 @@ full copyright notices and license terms. -->
|
|||
<field name="splittype"/>
|
||||
<field name="category"/>
|
||||
<field name="booktransf"/>
|
||||
<field name="description" expand="1" optional="0"/>
|
||||
<field name="amount" sum="1" symbol="currency" optional="0"/>
|
||||
<field name="amount_2nd_currency" symbol="currency2nd" optional="0"/>
|
||||
<field name="description" expand="1"/>
|
||||
<field name="amount" sum="Amount" symbol="currency"/>
|
||||
<field name="amount_2nd_currency" symbol="currency2nd"/>
|
||||
</tree>
|
||||
|
|
|
@ -18,41 +18,32 @@ class EnterBookingStart(ModelView):
|
|||
'Enter Booking'
|
||||
__name__ = 'cashbook.enterbooking.start'
|
||||
|
||||
cashbook = fields.Many2One(
|
||||
string='Cashbook', model_name='cashbook.book',
|
||||
cashbook = fields.Many2One(string='Cashbook', model_name='cashbook.book',
|
||||
domain=[('id', 'in', Eval('cashbooks', [])), ('btype', '!=', None)],
|
||||
depends=['cashbooks'], required=True)
|
||||
cashbooks = fields.One2Many(
|
||||
string='Cashbooks', field=None,
|
||||
cashbooks = fields.One2Many(string='Cashbooks', field=None,
|
||||
model_name='cashbook.book', readonly=True,
|
||||
states={'invisible': True})
|
||||
owner_cashbook = fields.Function(fields.Many2One(
|
||||
string='Owner', readonly=True,
|
||||
owner_cashbook = fields.Function(fields.Many2One(string='Owner', readonly=True,
|
||||
states={'invisible': True}, model_name='res.user'),
|
||||
'on_change_with_owner_cashbook')
|
||||
currency = fields.Function(fields.Many2One(
|
||||
string='Currency',
|
||||
currency = fields.Function(fields.Many2One(string='Currency',
|
||||
model_name='currency.currency', states={'invisible': True}),
|
||||
'on_change_with_currency')
|
||||
currency_digits = fields.Function(fields.Integer(
|
||||
string='Currency Digits',
|
||||
currency_digits = fields.Function(fields.Integer(string='Currency Digits',
|
||||
readonly=True, states={'invisible': True}),
|
||||
'on_change_with_currency_digits')
|
||||
bookingtype = fields.Selection(
|
||||
string='Type', required=True, selection=sel_booktypewiz)
|
||||
amount = fields.Numeric(
|
||||
string='Amount',
|
||||
bookingtype = fields.Selection(string='Type', required=True,
|
||||
selection=sel_booktypewiz)
|
||||
amount = fields.Numeric(string='Amount',
|
||||
depends=['currency_digits', 'bookingtype'],
|
||||
digits=(16, Eval('currency_digits', 2)), required=True,
|
||||
domain=[('amount', '>=', Decimal('0.0'))])
|
||||
description = fields.Text(
|
||||
string='Description', states={'required': Bool(Eval('fixate'))},
|
||||
depends=['fixate'])
|
||||
category = fields.Many2One(
|
||||
string='Category',
|
||||
description = fields.Text(string='Description')
|
||||
category = fields.Many2One(string='Category',
|
||||
model_name='cashbook.category', depends=['bookingtype'],
|
||||
states={
|
||||
'readonly': ~Bool(Eval('bookingtype')),
|
||||
'readonly': Bool(Eval('bookingtype')) == False,
|
||||
'required': Eval('bookingtype', '').in_(['in', 'out']),
|
||||
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
|
||||
},
|
||||
|
@ -62,12 +53,9 @@ class EnterBookingStart(ModelView):
|
|||
('cattype', '=', 'in'),
|
||||
('cattype', '=', 'out'),
|
||||
)])
|
||||
fixate = fields.Boolean(
|
||||
string='Fixate', help='The booking is fixed immediately.')
|
||||
|
||||
# party or cashbook as counterpart
|
||||
booktransf = fields.Many2One(
|
||||
string='Source/Dest',
|
||||
booktransf = fields.Many2One(string='Source/Dest',
|
||||
model_name='cashbook.book',
|
||||
domain=[
|
||||
('owner.id', '=', Eval('owner_cashbook', -1)),
|
||||
|
@ -77,14 +65,10 @@ class EnterBookingStart(ModelView):
|
|||
'invisible': ~Eval('bookingtype', '').in_(['mvin', 'mvout']),
|
||||
'required': Eval('bookingtype', '').in_(['mvin', 'mvout']),
|
||||
}, depends=['bookingtype', 'owner_cashbook', 'cashbook'])
|
||||
party = fields.Many2One(
|
||||
string='Party', model_name='party.party',
|
||||
party = fields.Many2One(string='Party', model_name='party.party',
|
||||
states={
|
||||
'invisible': ~Eval('bookingtype', '').in_(['in', 'out']),
|
||||
'required': And(
|
||||
Bool(Eval('fixate')),
|
||||
Eval('bookingtype', '').in_(['in', 'out']))},
|
||||
depends=['bookingtype', 'fixate'])
|
||||
}, depends=['bookingtype'])
|
||||
|
||||
@fields.depends('bookingtype', 'category')
|
||||
def on_change_bookingtype(self):
|
||||
|
@ -97,8 +81,7 @@ class EnterBookingStart(ModelView):
|
|||
|
||||
if self.bookingtype:
|
||||
if self.category:
|
||||
if self.bookingtype not in types.get(
|
||||
self.category.cattype, ''):
|
||||
if not self.bookingtype in types.get(self.category.cattype, ''):
|
||||
self.category = None
|
||||
|
||||
@fields.depends('cashbook', '_parent_cashbook.owner')
|
||||
|
@ -132,8 +115,7 @@ class EnterBookingWizard(Wizard):
|
|||
__name__ = 'cashbook.enterbooking'
|
||||
|
||||
start_state = 'start'
|
||||
start = StateView(
|
||||
'cashbook.enterbooking.start',
|
||||
start = StateView('cashbook.enterbooking.start',
|
||||
'cashbook.enterbooking_start_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Save', 'save_', 'tryton-save', default=True),
|
||||
|
@ -157,12 +139,10 @@ class EnterBookingWizard(Wizard):
|
|||
book_ids.append(getattr(cfg1, x, None).id)
|
||||
|
||||
result = {
|
||||
'fixate': cfg1.fixate
|
||||
if cfg1 and cfg1.fixate is not None else False,
|
||||
'cashbooks': [x.id for x in Cashbook.search([
|
||||
('state', '=', 'open'),
|
||||
('btype', '!=', None),
|
||||
('owner', '=', Transaction().user),
|
||||
('owner.id', '=', Transaction().user),
|
||||
('id', 'in', book_ids),
|
||||
])],
|
||||
'bookingtype': getattr(self.start, 'bookingtype', 'out'),
|
||||
|
@ -196,9 +176,7 @@ class EnterBookingWizard(Wizard):
|
|||
elif self.start.bookingtype in ['mvin', 'mvout']:
|
||||
query['booktransf'] = self.start.booktransf.id
|
||||
|
||||
lines = Line.create([query])
|
||||
if self.start.fixate:
|
||||
Line.wfcheck(lines)
|
||||
Line.create([query])
|
||||
return 'end'
|
||||
|
||||
def transition_savenext_(self):
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.pyson import PYSONEncoder
|
||||
from trytond.wizard import Wizard, StateView, StateTransition, \
|
||||
StateAction, Button
|
||||
from trytond.wizard import Wizard, StateView, StateTransition, StateAction, Button
|
||||
from trytond.i18n import gettext
|
||||
from trytond.pool import Pool
|
||||
from trytond.exceptions import UserError
|
||||
|
@ -43,13 +42,10 @@ class OpenCashBookStart(ModelView):
|
|||
'Open Cashbook'
|
||||
__name__ = 'cashbook.open_lines.start'
|
||||
|
||||
cashbook = fields.Many2One(
|
||||
string='Cashbook', model_name='cashbook.book',
|
||||
cashbook = fields.Many2One(string='Cashbook', model_name='cashbook.book',
|
||||
required=True, domain=[('btype', '!=', None)])
|
||||
checked = fields.Boolean(
|
||||
string='Checked', help="Show cashbook lines in Checked-state.")
|
||||
done = fields.Boolean(
|
||||
string='Done', help="Show cashbook lines in Done-state")
|
||||
checked = fields.Boolean(string='Checked', help="Show cashbook lines in Checked-state.")
|
||||
done = fields.Boolean(string='Done', help="Show cashbook lines in Done-state")
|
||||
date_from = fields.Date(string='Start Date')
|
||||
date_to = fields.Date(string='End Date')
|
||||
|
||||
|
@ -70,8 +66,7 @@ class OpenCashBook(OLineMixin, Wizard):
|
|||
|
||||
start_state = 'check'
|
||||
check = StateTransition()
|
||||
askuser = StateView(
|
||||
'cashbook.open_lines.start',
|
||||
askuser = StateView('cashbook.open_lines.start',
|
||||
'cashbook.open_lines_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Open', 'open_', 'tryton-ok', default=True),
|
||||
|
@ -84,7 +79,8 @@ class OpenCashBook(OLineMixin, Wizard):
|
|||
Book = Pool().get('cashbook.book')
|
||||
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
books = Book.search([('btype', '!=', None)])
|
||||
if len(books) == 1:
|
||||
return 'open_'
|
||||
|
@ -119,7 +115,8 @@ class OpenCashBook(OLineMixin, Wizard):
|
|||
book = getattr(self.askuser, 'cashbook', None)
|
||||
if book is None:
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
books = Book.search([('btype', '!=', None)])
|
||||
if len(books) > 0:
|
||||
book = books[0]
|
||||
|
@ -161,7 +158,8 @@ class OpenCashBookTree(OLineMixin, Wizard):
|
|||
book = self.record
|
||||
if book is None:
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
books = Book.search([('btype', '!=', None)])
|
||||
if len(books) > 0:
|
||||
book = books[0]
|
||||
|
@ -169,7 +167,8 @@ class OpenCashBookTree(OLineMixin, Wizard):
|
|||
if book.btype is None:
|
||||
raise UserError(gettext(
|
||||
'cashbook.msg_book_no_type_noopen',
|
||||
bookname=book.rec_name))
|
||||
bookname = book.rec_name,
|
||||
))
|
||||
|
||||
action.update(self.add_action_data(book))
|
||||
return action, {}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# full copyright notices and license terms.
|
||||
|
||||
from trytond.model import ModelView, fields
|
||||
from trytond.pyson import PYSONEncoder
|
||||
from trytond.wizard import Wizard, StateView, StateReport, Button
|
||||
from trytond.pool import Pool
|
||||
from trytond.pyson import Eval, Bool
|
||||
|
@ -14,21 +15,17 @@ class RunCbReportStart(ModelView):
|
|||
'Cashbook Report'
|
||||
__name__ = 'cashbook.runrepbook.start'
|
||||
|
||||
cashbook = fields.Many2One(
|
||||
string='Cashbook', required=True,
|
||||
cashbook = fields.Many2One(string='Cashbook', required=True,
|
||||
model_name='cashbook.book', depends=['cashbooks'],
|
||||
domain=[('id', 'in', Eval('cashbooks', []))])
|
||||
cashbooks = fields.One2Many(
|
||||
string='Cashbooks', model_name='cashbook.book',
|
||||
cashbooks = fields.One2Many(string='Cashbooks', model_name='cashbook.book',
|
||||
field=None, readonly=True, states={'invisible': True})
|
||||
reconciliation = fields.Many2One(
|
||||
string='Reconciliation', required=True,
|
||||
reconciliation = fields.Many2One(string='Reconciliation', required=True,
|
||||
model_name='cashbook.recon', depends=['reconciliations'],
|
||||
states={
|
||||
'readonly': ~Bool(Eval('reconciliations')),
|
||||
}, domain=[('id', 'in', Eval('reconciliations', []))])
|
||||
reconciliations = fields.Function(fields.One2Many(
|
||||
string='Reconciliations',
|
||||
reconciliations = fields.Function(fields.One2Many(string='Reconciliations',
|
||||
model_name='cashbook.recon', field=None, readonly=True,
|
||||
states={'invisible': True}),
|
||||
'on_change_with_reconciliations')
|
||||
|
@ -55,7 +52,7 @@ class RunCbReportStart(ModelView):
|
|||
|
||||
if self.cashbook:
|
||||
recons = Recon2.search([
|
||||
('cashbook', '=', self.cashbook.id),
|
||||
('cashbook.id', '=', self.cashbook.id),
|
||||
], order=[('date_from', 'DESC')])
|
||||
return [x.id for x in recons]
|
||||
|
||||
|
@ -67,14 +64,14 @@ class RunCbReport(Wizard):
|
|||
__name__ = 'cashbook.runrepbook'
|
||||
|
||||
start_state = 'selrecon'
|
||||
selrecon = StateView(
|
||||
'cashbook.runrepbook.start',
|
||||
selrecon = StateView('cashbook.runrepbook.start',
|
||||
'cashbook.runrepbook_view_form', [
|
||||
Button(string='Cancel', state='end', icon='tryton-cancel'),
|
||||
Button(
|
||||
string='Report', state='report_', icon='tryton-ok',
|
||||
default=True,
|
||||
states={'readonly': ~Bool(Eval('reconciliation'))})])
|
||||
Button(string='Report', state='report_', icon='tryton-ok', default=True,
|
||||
states={
|
||||
'readonly': ~Bool(Eval('reconciliation')),
|
||||
}),
|
||||
])
|
||||
report_ = StateReport('cashbook.reprecon')
|
||||
|
||||
def default_selrecon(self, fields):
|
||||
|
@ -94,7 +91,8 @@ class RunCbReport(Wizard):
|
|||
raise ValueError('invalid model')
|
||||
|
||||
with Transaction().set_context({
|
||||
'_check_access': True}):
|
||||
'_check_access': True,
|
||||
}):
|
||||
books = Book.search([])
|
||||
result['cashbooks'] = [x.id for x in books]
|
||||
|
||||
|
@ -103,7 +101,7 @@ class RunCbReport(Wizard):
|
|||
result['cashbook'] = result['cashbooks'][0]
|
||||
|
||||
recons = Recon2.search([
|
||||
('cashbook', '=', result['cashbook']),
|
||||
('cashbook.id', '=', result['cashbook']),
|
||||
], order=[('date_from', 'DESC')])
|
||||
if len(recons) > 0:
|
||||
result['reconciliations'] = [x.id for x in recons]
|
||||
|
|
Loading…
Reference in a new issue