Commit 51a71e19 authored by Kevin Deldycke's avatar Kevin Deldycke

factory-type informations deleted;

some methods deleted, because of redundandy with DeliveryCell;


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3192 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ec94f526
...@@ -26,15 +26,12 @@ ...@@ -26,15 +26,12 @@
# #
############################################################################## ##############################################################################
from Globals import InitializeClass, PersistentMapping from Acquisition import aq_base
from Acquisition import aq_base, aq_inner, aq_parent, aq_self
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.CMFCore.WorkflowCore import WorkflowAction from Products.ERP5Type import Permissions, PropertySheet, Interface
from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
from Products.ERP5.Document.DeliveryCell import DeliveryCell from Products.ERP5.Document.DeliveryCell import DeliveryCell
from Products.ERP5.Document.Movement import Movement
class InventoryCell(DeliveryCell): class InventoryCell(DeliveryCell):
...@@ -71,60 +68,6 @@ class InventoryCell(DeliveryCell): ...@@ -71,60 +68,6 @@ class InventoryCell(DeliveryCell):
, PropertySheet.ItemAggregation , PropertySheet.ItemAggregation
) )
# Factory Type Information
factory_type_information = \
{ 'id' : portal_type
, 'meta_type' : meta_type
, 'description' : """An Inventory Cell."""
, 'icon' : 'order_line_icon.gif'
, 'product' : 'ERP5'
, 'factory' : 'addInventoryCell'
, 'immediate_view' : 'inventory_cell_view'
, 'allow_discussion' : 1
, 'allowed_content_types': ('',
)
, 'filter_content_types' : 1
, 'global_allow' : 1
, 'actions' :
( { 'id' : 'view'
, 'name' : 'View'
, 'category' : 'object_view'
, 'action' : 'inventory_cell_view'
, 'permissions' : (
Permissions.View, )
}
, { 'id' : 'list'
, 'name' : 'Object Contents'
, 'category' : 'object_action'
, 'action' : 'folder_contents'
, 'permissions' : (
Permissions.View, )
}
, { 'id' : 'print'
, 'name' : 'Print'
, 'category' : 'object_print'
, 'action' : 'inventory_cell_print'
, 'permissions' : (
Permissions.View, )
}
, { 'id' : 'metadata'
, 'name' : 'Metadata'
, 'category' : 'object_view'
, 'action' : 'metadata_edit'
, 'permissions' : (
Permissions.View, )
}
, { 'id' : 'translate'
, 'name' : 'Translate'
, 'category' : 'object_action'
, 'action' : 'translation_template_view'
, 'permissions' : (
Permissions.TranslateContent, )
}
)
}
def _edit(self, REQUEST=None, force_update = 0, **kw): def _edit(self, REQUEST=None, force_update = 0, **kw):
kw = kw.copy() kw = kw.copy()
item_id_list = kw.get('item_id_list', None) item_id_list = kw.get('item_id_list', None)
...@@ -142,13 +85,6 @@ class InventoryCell(DeliveryCell): ...@@ -142,13 +85,6 @@ class InventoryCell(DeliveryCell):
if consumed_item_id_list is not None : if consumed_item_id_list is not None :
self._setConsumedItemIdList(consumed_item_id_list) self._setConsumedItemIdList(consumed_item_id_list)
security.declareProtected( Permissions.ModifyPortalContent, 'hasCellContent' )
def hasCellContent(self, base_id='movement'):
"""
This method can be overriden
"""
return 0
security.declareProtected(Permissions.AccessContentsInformation, 'getQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getQuantity')
def getQuantity(self): def getQuantity(self):
""" """
...@@ -171,9 +107,11 @@ class InventoryCell(DeliveryCell): ...@@ -171,9 +107,11 @@ class InventoryCell(DeliveryCell):
delattr(self, 'consumption_quantity') delattr(self, 'consumption_quantity')
if hasattr(self, 'mapped_value_property_list'): if hasattr(self, 'mapped_value_property_list'):
if 'consumption_quantity' in self.mapped_value_property_list: if 'consumption_quantity' in self.mapped_value_property_list:
self.mapped_value_property_list = filter(lambda s: s!='consumption_quantity',self.mapped_value_property_list) self.mapped_value_property_list = filter(lambda s: s != 'consumption_quantity'
, self.mapped_value_property_list)
if 'production_quantity' in self.mapped_value_property_list: if 'production_quantity' in self.mapped_value_property_list:
self.mapped_value_property_list = filter(lambda s: s!='production_quantity',self.mapped_value_property_list) self.mapped_value_property_list = filter(lambda s: s != 'production_quantity'
, self.mapped_value_property_list)
if 'quantity' not in self.mapped_value_property_list: if 'quantity' not in self.mapped_value_property_list:
self.mapped_value_property_list = list(self.mapped_value_property_list) + ['quantity'] self.mapped_value_property_list = list(self.mapped_value_property_list) + ['quantity']
# First check if quantity already exists # First check if quantity already exists
...@@ -188,12 +126,13 @@ class InventoryCell(DeliveryCell): ...@@ -188,12 +126,13 @@ class InventoryCell(DeliveryCell):
if resource_value is not None: if resource_value is not None:
# Inventories can only be done in "real" locations / sectinos, not categories thereof # Inventories can only be done in "real" locations / sectinos, not categories thereof
# -> therefore we use node and section # -> therefore we use node and section
current_inventory = resource_value.getInventory( current_inventory = resource_value.getInventory( \
at_date = self.getStartDate(), at_date = self.getStartDate()
variation_text = self.getVariationText(), , variation_text = self.getVariationText()
node = self.getDestination(), , node = self.getDestination()
section_category = self.getDestinationSection(), # We want to consolidate , section_category = self.getDestinationSection() # We want to consolidate
simulation_state = self.getPortalCurrentInventoryStateList()) , simulation_state = self.getPortalCurrentInventoryStateList()
)
inventory = self.getInventory() inventory = self.getInventory()
if current_inventory in (None, ''): if current_inventory in (None, ''):
current_inventory = 0.0 current_inventory = 0.0
...@@ -215,94 +154,77 @@ class InventoryCell(DeliveryCell): ...@@ -215,94 +154,77 @@ class InventoryCell(DeliveryCell):
Computes total_quantity of all given items and stores this total_quantity Computes total_quantity of all given items and stores this total_quantity
in the inventory attribute of the cell in the inventory attribute of the cell
""" """
if value is None:
return
previous_item_list = self.getAggregateValueList() previous_item_list = self.getAggregateValueList()
given_item_id_list = value given_item_id_list = value
item_object_list = [] item_object_list = []
for item in given_item_id_list : for item in given_item_id_list:
item_result_list = self.portal_catalog(id = item, portal_type="Piece Tissu") item_result_list = self.portal_catalog(id=item, portal_type="Piece Tissu")
if len(item_result_list) == 1 : if len(item_result_list) == 1:
try : try:
object = item_result_list[0].getObject() object = item_result_list[0].getObject()
except : except:
object = None object = None
else : else:
object = None object = None
if object is not None:
if object is not None :
# if item was in previous_item_list keep it # if item was in previous_item_list keep it
if object in previous_item_list : if object in previous_item_list:
# we can add this item to the list of aggregated items # we can add this item to the list of aggregated items
item_object_list.append(object) item_object_list.append(object)
# if new item verify if variated_resource of item == variated_resource of movement # if new item verify if variated_resource of item == variated_resource of movement
elif (self.getResource() == object.getResource()) and (self.getVariationCategoryList() == object.getVariationCategoryList()) : elif (self.getResource() == object.getResource()) \
and (self.getVariationCategoryList() == object.getVariationCategoryList()):
# we can add this item to the list of aggregated items # we can add this item to the list of aggregated items
item_object_list.append(object) item_object_list.append(object)
# update item_id_list and build relation # update item_id_list and build relation
self.setAggregateValueList(item_object_list) self.setAggregateValueList(item_object_list)
# update inventory if needed # update inventory if needed
if len(item_object_list)>0 : if len(item_object_list) > 0:
quantity = 0 quantity = 0
for object_item in item_object_list : for object_item in item_object_list:
quantity += object_item.getRemainingQuantity() quantity += object_item.getRemainingQuantity()
self.setInventory(quantity) self.setInventory(quantity)
# Required for indexing
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoriatedQuantity')
def getInventoriatedQuantity(self):
"""
Take into account efficiency in converted target quantity
"""
return Movement.getInventoriatedQuantity(self)
security.declareProtected(Permissions.AccessContentsInformation, 'getStartDate')
def getStartDate(self):
"""
Take into account efficiency in converted target quantity
"""
return Movement.getStartDate(self)
security.declareProtected(Permissions.AccessContentsInformation, 'getStopDate')
def getStopDate(self):
"""
Take into account efficiency in converted target quantity
"""
return Movement.getStopDate(self)
def _setProducedItemIdList(self, value): def _setProducedItemIdList(self, value):
""" """
Computes total_quantity of all given items and stores this total_quantity Computes total_quantity of all given items and stores this total_quantity
in the quantity attribute of the cell in the quantity attribute of the cell
""" """
if value is None:
return
previous_item_list = self.getAggregateValueList() previous_item_list = self.getAggregateValueList()
given_item_id_list = value given_item_id_list = value
item_object_list = [] item_object_list = []
for item in given_item_id_list : for item in given_item_id_list:
item_result_list = self.portal_catalog(id = item, portal_type="Piece Tissu") item_result_list = self.portal_catalog(id=item, portal_type="Piece Tissu")
if len(item_result_list) == 1 : if len(item_result_list) == 1:
try : try:
object = item_result_list[0].getObject() object = item_result_list[0].getObject()
except : except:
object = None object = None
else : else:
object = None object = None
if object is not None : if object is not None:
# if item was in previous_item_list keep it # if item was in previous_item_list keep it
if object in previous_item_list : if object in previous_item_list:
# we can add this item to the list of aggregated items # we can add this item to the list of aggregated items
item_object_list.append(object) item_object_list.append(object)
# if new item verify if variated_resource of item == variated_resource of movement # if new item verify if variated_resource of item == variated_resource of movement
elif (self.getResource() == object.getResource()) and (self.getVariationCategoryList() == object.getVariationCategoryList()) : elif (self.getResource() == object.getResource()) \
and (self.getVariationCategoryList() == object.getVariationCategoryList()):
# now verify if item can be moved (not already done) # now verify if item can be moved (not already done)
last_location_title = object.getLastLocationTitle() last_location_title = object.getLastLocationTitle()
if self.getDestinationTitle() != last_location_title or last_location_title == '' : if self.getDestinationTitle() != last_location_title or last_location_title == '':
# we can add this item to the list of aggregated items # we can add this item to the list of aggregated items
item_object_list.append(object) item_object_list.append(object)
# update item_id_list and build relation # update item_id_list and build relation
self.setAggregateValueList(item_object_list) self.setAggregateValueList(item_object_list)
# update inventory if needed # update inventory if needed
if len(item_object_list)>0 : if len(item_object_list) > 0:
quantity = 0 quantity = 0
for object_item in item_object_list : for object_item in item_object_list:
quantity += object_item.getQuantity() quantity += object_item.getQuantity()
self.setProductionQuantity(quantity) self.setProductionQuantity(quantity)
...@@ -311,36 +233,39 @@ class InventoryCell(DeliveryCell): ...@@ -311,36 +233,39 @@ class InventoryCell(DeliveryCell):
Computes total_quantity of all given items and stores this total_quantity Computes total_quantity of all given items and stores this total_quantity
in the quantity attribute of the cell in the quantity attribute of the cell
""" """
if value is None:
return
previous_item_list = self.getAggregateValueList() previous_item_list = self.getAggregateValueList()
given_item_id_list = value given_item_id_list = value
item_object_list = [] item_object_list = []
for item in given_item_id_list : for item in given_item_id_list:
item_result_list = self.portal_catalog(id = item, portal_type="Piece Tissu") item_result_list = self.portal_catalog(id=item, portal_type="Piece Tissu")
if len(item_result_list) == 1 : if len(item_result_list) == 1:
try : try :
object = item_result_list[0].getObject() object = item_result_list[0].getObject()
except : except :
object = None object = None
else : else :
object = None object = None
if object is not None : if object is not None:
# if item was in previous_item_list keep it # if item was in previous_item_list keep it
if object in previous_item_list : if object in previous_item_list:
# we can add this item to the list of aggregated items # we can add this item to the list of aggregated items
item_object_list.append(object) item_object_list.append(object)
# if new item verify if variated_resource of item == variated_resource of movement # if new item verify if variated_resource of item == variated_resource of movement
elif (self.getResource() == object.getResource()) and (self.getVariationCategoryList() == object.getVariationCategoryList()) : elif (self.getResource() == object.getResource()) \
and (self.getVariationCategoryList() == object.getVariationCategoryList()):
# now verify if item can be moved (not already done) # now verify if item can be moved (not already done)
last_location_title = object.getLastLocationTitle() last_location_title = object.getLastLocationTitle()
if self.getDestinationTitle() == last_location_title or last_location_title == '' : if self.getDestinationTitle() == last_location_title or last_location_title == '':
# we can add this item to the list of aggregated items # we can add this item to the list of aggregated items
item_object_list.append(object) item_object_list.append(object)
# update item_id_list and build relation # update item_id_list and build relation
self.setAggregateValueList(item_object_list) self.setAggregateValueList(item_object_list)
# update inventory if needed # update inventory if needed
if len(item_object_list)>0 : if len(item_object_list) > 0:
quantity = 0 quantity = 0
for object_item in item_object_list : for object_item in item_object_list:
quantity += object_item.getRemainingQuantity() quantity += object_item.getRemainingQuantity()
# we reset the location of the item # we reset the location of the item
object_item.setLocation('') object_item.setLocation('')
...@@ -350,18 +275,18 @@ class InventoryCell(DeliveryCell): ...@@ -350,18 +275,18 @@ class InventoryCell(DeliveryCell):
""" """
Returns list of items if production_quantity != 0.0 Returns list of items if production_quantity != 0.0
""" """
if self.getProductionQuantity() != 0.0 : if self.getProductionQuantity() != 0.0:
return self.getItemIdList() return self.getItemIdList()
else : else:
return [] return []
def getConsumedItemIdList(self): def getConsumedItemIdList(self):
""" """
Returns list of items if consumption_quantity != 0.0 Returns list of items if consumption_quantity != 0.0
""" """
if self.getConsumptionQuantity() != 0.0 : if self.getConsumptionQuantity() != 0.0:
return self.getItemIdList() return self.getItemIdList()
else : else:
return [] return []
# Inventory cataloging # Inventory cataloging
......
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