Commit 377c1836 authored by Sebastien Robin's avatar Sebastien Robin

add temp_constructor parameter to immediateReindexObject, this will be used in ERP5Banking

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11922 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 183169f4
...@@ -67,15 +67,21 @@ class Inventory(Delivery): ...@@ -67,15 +67,21 @@ class Inventory(Delivery):
""" """
return self.immediateReindexObject(**kw) return self.immediateReindexObject(**kw)
def immediateReindexObject(self,**kw): def immediateReindexObject(self,temp_constructor=None,**kw):
""" """
Rewrite reindexObject so that we can insert lines in stock table Rewrite reindexObject so that we can insert lines in stock table
to make sure all stock values for resources in this inventory to make sure all stock values for resources in this inventory
is equal to null before the date of this inventory is equal to null before the date of this inventory
temp_constructor is used in some particular cases where we want
to have our own temp object constructor, this is usefull if we
want to use some classes with some particular methods
""" """
resource_and_variation_list = [] resource_and_variation_list = []
stock_object_list = [] stock_object_list = []
from Products.ERP5Type.Document import newTempDeliveryLine if temp_constructor is None:
from Products.ERP5Type.Document import newTempDeliveryLine
temp_constructor = newTempDeliveryLine
start_date = self.getStartDate() start_date = self.getStartDate()
node = self.getDestination() node = self.getDestination()
for movement in self.getMovementList(): for movement in self.getMovementList():
...@@ -101,8 +107,8 @@ class Inventory(Delivery): ...@@ -101,8 +107,8 @@ class Inventory(Delivery):
sub_variation_list = inventory.sub_variation_text.split('\n') sub_variation_list = inventory.sub_variation_text.split('\n')
category_list = self.getCategoryList() category_list = self.getCategoryList()
if inventory.total_quantity != 0: if inventory.total_quantity != 0:
temp_delivery_line = newTempDeliveryLine(self, temp_delivery_line = temp_constructor(self,
self.getId()) self.getId())
kwd['quantity'] = - inventory.total_quantity kwd['quantity'] = - inventory.total_quantity
category_list.append('resource/%s' % inventory.resource_relative_url) category_list.append('resource/%s' % inventory.resource_relative_url)
category_list.extend(variation_list) category_list.extend(variation_list)
...@@ -115,7 +121,7 @@ class Inventory(Delivery): ...@@ -115,7 +121,7 @@ class Inventory(Delivery):
if len(stock_object_list)==0: if len(stock_object_list)==0:
# Make sure to remove all lines # Make sure to remove all lines
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
stock_object_list.append(newTempDeliveryLine(self,self.getId(), stock_object_list.append(temp_constructor(self,self.getId(),
uid=self.getUid())) uid=self.getUid()))
self.portal_catalog.catalogObjectList(stock_object_list, self.portal_catalog.catalogObjectList(stock_object_list,
method_id_list=('z_catalog_stock_list',), method_id_list=('z_catalog_stock_list',),
......
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