Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
d97664b4
Commit
d97664b4
authored
Feb 05, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reimplement PackingList.isPacked using ZODB (to get rid of movement table dependancy)
parent
e2e4f433
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
23 deletions
+38
-23
product/ERP5/Document/PackingList.py
product/ERP5/Document/PackingList.py
+34
-19
product/ERP5/tests/testPackingList.py
product/ERP5/tests/testPackingList.py
+4
-4
No files found.
product/ERP5/Document/PackingList.py
View file @
d97664b4
...
...
@@ -86,25 +86,40 @@ class PackingList(Delivery):
'isPacked'
)
def
isPacked
(
self
):
"""
Returns 0 if all quantity resource on packing list line
are not in container.
It works only if a Resource is not on 2 PackingListLine.
Returns true if all quantities for all variations of resources are in
containers.
FIXME: this method does not support packing list with 2 movements of
same resource.
"""
# build a mapping of
# (resource, variation_text) -> quantity
container_dict
=
dict
()
for
container
in
self
.
contentValues
(
portal_type
=
self
.
getPortalContainerTypeList
()):
for
container_line
in
container
.
contentValues
(
portal_type
=
self
.
getPortalContainerLineTypeList
(),):
if
container_line
.
hasCellContent
(
base_id
=
'movement'
):
for
container_cell
in
container_line
.
contentValues
(
portal_type
=
self
.
getPortalContainerLineTypeList
(),):
key
=
(
container_cell
.
getResource
(),
container_cell
.
getVariationText
())
container_dict
[
key
]
=
container_dict
.
get
(
key
,
0
)
+
\
container_cell
.
getQuantity
()
else
:
key
=
(
container_line
.
getResource
(),
container_line
.
getVariationText
())
container_dict
[
key
]
=
container_dict
.
get
(
key
,
0
)
+
\
container_line
.
getQuantity
()
if
not
container_dict
:
return
False
# Check that all movements are packed.
for
movement
in
self
.
getMovementList
():
key
=
(
movement
.
getResource
(),
movement
.
getVariationText
())
if
container_dict
.
get
(
key
,
None
)
!=
movement
.
getQuantity
():
return
False
return
True
quantity
=
movement
.
getQuantity
()
query_kw
=
{
'portal_type'
:
self
.
getPortalContainerLineTypeList
(),
'movement.explanation_uid'
:
self
.
getUid
(),
'movement.resource_uid'
:
movement
.
getResourceUid
(),
'movement.variation_text'
:
movement
.
getVariationText
(),
'has_cell_content'
:
0
,
}
container_mvt_list
=
self
.
portal_catalog
(
**
query_kw
)
packed_quantity
=
sum
([
x
.
getQuantity
()
for
x
in
container_mvt_list
\
if
x
.
getQuantity
()
is
not
None
])
if
quantity
!=
packed_quantity
:
return
0
return
1
product/ERP5/tests/testPackingList.py
View file @
d97664b4
...
...
@@ -932,8 +932,8 @@ class TestPackingListMixin(TestOrderMixin):
not equals to the quantity of the packing list
"""
packing_list
=
sequence
.
get
(
'packing_list'
)
self
.
assert
Equals
(
0
,
packing_list
.
isPacked
())
self
.
assertEquals
(
'missing'
,
packing_list
.
getContainerState
())
self
.
assert
False
(
packing_list
.
isPacked
())
self
.
assertEquals
(
'missing'
,
packing_list
.
getContainerState
())
def
stepCheckPackingListIsPacked
(
self
,
sequence
=
None
,
sequence_list
=
None
,
packing_list
=
None
,
**
kw
):
...
...
@@ -944,8 +944,8 @@ class TestPackingListMixin(TestOrderMixin):
if
packing_list
is
None
:
packing_list
=
sequence
.
get
(
'packing_list'
)
self
.
commit
()
self
.
assert
Equals
(
1
,
packing_list
.
isPacked
())
self
.
assertEquals
(
'packed'
,
packing_list
.
getContainerState
())
self
.
assert
True
(
packing_list
.
isPacked
())
self
.
assertEquals
(
'packed'
,
packing_list
.
getContainerState
())
def
stepCheckNewPackingListIsPacked
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment