Commit b7bdf466 authored by Kevin Deldycke's avatar Kevin Deldycke

_setVariationCategoryList() deleted;

newCellContent() redefined


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3184 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c10fb67e
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2002-2005 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets-Solanes <jp@nexedi.com> # Jean-Paul Smets-Solanes <jp@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
...@@ -41,11 +41,7 @@ from zLOG import LOG ...@@ -41,11 +41,7 @@ from zLOG import LOG
class InventoryLine(DeliveryLine): class InventoryLine(DeliveryLine):
""" """
A DeliveryLine object allows to implement lines in An Inventory Line describe the inventory of a resource, by variations.
Deliveries (packing list, order, invoice, etc.)
It may include a price (for insurance, for customs, for invoices,
for orders)
""" """
meta_type = 'ERP5 Inventory Line' meta_type = 'ERP5 Inventory Line'
...@@ -78,8 +74,7 @@ class InventoryLine(DeliveryLine): ...@@ -78,8 +74,7 @@ class InventoryLine(DeliveryLine):
factory_type_information = \ factory_type_information = \
{ 'id' : portal_type { 'id' : portal_type
, 'meta_type' : meta_type , 'meta_type' : meta_type
, 'description' : """\ , 'description' : """An Inventory Line"""
Une ligne tarifaire."""
, 'icon' : 'inventory_line_icon.gif' , 'icon' : 'inventory_line_icon.gif'
, 'product' : 'ERP5' , 'product' : 'ERP5'
, 'factory' : 'addInventoryLine' , 'factory' : 'addInventoryLine'
...@@ -157,7 +152,6 @@ Une ligne tarifaire.""" ...@@ -157,7 +152,6 @@ Une ligne tarifaire."""
aggregate = self.InventoryLine_zGetTotal()[0] aggregate = self.InventoryLine_zGetTotal()[0]
return aggregate.total_inventory return aggregate.total_inventory
security.declareProtected(Permissions.AccessContentsInformation, 'getQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getQuantity')
def getQuantity(self): def getQuantity(self):
""" """
...@@ -176,12 +170,13 @@ Une ligne tarifaire.""" ...@@ -176,12 +170,13 @@ Une ligne tarifaire."""
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(), , section_category = self.getDestinationSection()
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
...@@ -190,56 +185,15 @@ Une ligne tarifaire.""" ...@@ -190,56 +185,15 @@ Une ligne tarifaire."""
else: else:
return None return None
# Cell Related ### (kev) This method can't be deleted as long as Delivery.newCellContent() has its own
security.declareProtected( Permissions.ModifyPortalContent, 'newCellContent' ) # XMLMatrix.newCellContent() method. The latter is kept because we fear its deletion will
def newCellContent(self, id,**kw): # break existing scripts and code in ERP5. (kev)
""" security.declareProtected(Permissions.ModifyPortalContent, 'newCellContent')
This method can be overriden newCellContent = XMLMatrix.newCellContent
"""
self.invokeFactory(type_name="Inventory Cell",id=id)
return self.get(id)
# For generation of matrix lines ### (kev) No more setVariationCategoryList to create cells
security.declareProtected( Permissions.ModifyPortalContent, '_setVariationCategoryList' ) # If you want to create cells you have to use an InteractiveWorkflow or a python script instead
def _setVariationCategoryList(self, value): # def _setVariationCategoryList(self, value)
"""
Define the indices provided
one list per index (kw)
Any number of list can be provided
"""
LOG('setCellRange',0,'')
Movement._setVariationCategoryList(self, value)
# Update the cell range automatically
# This is far from easy and requires some specific wizzardry
base_id = 'movement'
kwd = {'base_id': base_id}
new_range = self.DeliveryLine_asCellRange() # This is a site dependent script
self._setCellRange(*new_range, **kwd )
cell_range_key_list = self.getCellRangeKeyList(base_id = base_id)
if cell_range_key_list <> [[None, None]] :
for k in cell_range_key_list:
LOG('new cell',0,str(k))
c = self.newCell(*k, **kwd)
c.edit( domain_base_category_list = self.getVariationBaseCategoryList(),
mapped_value_property_list = ('inventory', 'price',),
predicate_operator = 'SUPERSET_OF',
predicate_value = filter(lambda k_item: k_item is not None, k),
variation_category_list = filter(lambda k_item: k_item is not None, k),
force_update = 1
)
c.flushActivity(invoke=1)
else:
# If only one cell, delete it
cell_range_id_list = self.getCellRangeIdList(base_id = base_id)
for k in cell_range_id_list:
if self.get(k) is not None:
self[k].flushActivity(invoke=0)
self[k].immediateReindexObject() # We are forced to do this is url is changed (not uid)
self._delObject(k)
# TO BE DONE XXX
# reindex cells when price, quantity or source/dest changes
def _setItemIdList(self, value): def _setItemIdList(self, value):
""" """
...@@ -258,7 +212,6 @@ Une ligne tarifaire.""" ...@@ -258,7 +212,6 @@ Une ligne tarifaire."""
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 :
...@@ -268,18 +221,13 @@ Une ligne tarifaire.""" ...@@ -268,18 +221,13 @@ Une ligne tarifaire."""
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.getQuantity() quantity += object_item.getQuantity()
self.setInventory(quantity) self.setInventory(quantity)
def _setProducedItemIdList(self, value): def _setProducedItemIdList(self, value):
...@@ -299,7 +247,6 @@ Une ligne tarifaire.""" ...@@ -299,7 +247,6 @@ Une ligne tarifaire."""
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 :
...@@ -312,18 +259,13 @@ Une ligne tarifaire.""" ...@@ -312,18 +259,13 @@ Une ligne tarifaire."""
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)
def _setConsumedItemIdList(self, value): def _setConsumedItemIdList(self, value):
...@@ -343,7 +285,6 @@ Une ligne tarifaire.""" ...@@ -343,7 +285,6 @@ Une ligne tarifaire."""
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 :
...@@ -356,20 +297,15 @@ Une ligne tarifaire.""" ...@@ -356,20 +297,15 @@ Une ligne tarifaire."""
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('')
self.setConsumptionQuantity(quantity) self.setConsumptionQuantity(quantity)
def getProducedItemIdList(self): def getProducedItemIdList(self):
...@@ -420,4 +356,3 @@ Une ligne tarifaire.""" ...@@ -420,4 +356,3 @@ Une ligne tarifaire."""
Take into account efficiency in converted target quantity Take into account efficiency in converted target quantity
""" """
return Movement.getStopDate(self) return Movement.getStopDate(self)
\ No newline at end of file
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