Commit 62337a87 authored by Yusei Tahara's avatar Yusei Tahara

Implement getRemainingQuantity method.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19987 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent aec2f121
...@@ -102,4 +102,15 @@ class Item(XMLObject, Amount, ImmobilisableItem): ...@@ -102,4 +102,15 @@ class Item(XMLObject, Amount, ImmobilisableItem):
local_price = resource.getPrice(self.asContext( context=context, **kw)) local_price = resource.getPrice(self.asContext( context=context, **kw))
return local_price return local_price
security.declareProtected(Permissions.ModifyPortalContent, 'getRemainingQuantity')
def getRemainingQuantity(self):
"""
Computes the quantity of an item minus quantity of all sub_items
"""
sub_quantity = 0
sub_item_list = [document
for document in self.objectValues()
if document.isItem()]
for sub_item in sub_item_list :
sub_quantity += sub_item.getQuantity()
return self.getQuantity() - sub_quantity
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment