Commit 60860972 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_core: support date on line

idea is do a loop for different stop date
parent 78171b2c
Pipeline #38210 failed with stage
in 0 seconds
......@@ -143,12 +143,11 @@ class Inventory(Delivery):
if method is not None:
default_inventory_calculation_list = method()
if temp_constructor is None:
temp_constructor = lambda self, id, *args, **kw: self.newContent(
temp_object=True, portal_type='Movement',
id=id, *args, **kw)
stop_date = self.getStopDate()
#stop_date = self.getStopDate()
stock_object_list = []
stock_append = stock_object_list.append
......@@ -158,6 +157,16 @@ class Inventory(Delivery):
to_delete_list_append = to_delete_list.append
for inventory_calculation_dict in default_inventory_calculation_list:
stop_date_list = []
list_method = inventory_calculation_dict['list_method']
method = getattr(self, list_method)
for movement in method():
if (movement.getResourceValue() is not None) and (movement.getInventoriatedQuantity() not in (None, '')):
stop_date = movement.getStopDate()
if stop_date not in stop_date_list:
stop_date_list.append(stop_date)
stop_date_list = sorted(stop_date_list)
for stop_date in stop_date_list:
# build a dict containing all inventory for this node
# group by resource/variation and then subvariation
......@@ -209,7 +218,8 @@ class Inventory(Delivery):
for movement in method():
if movement.getResourceValue() is not None and \
movement.getInventoriatedQuantity() not in (None, ''):
if movement.getStopDate() != stop_date:
continue
movement_quantity = movement.getInventoriatedQuantity()
# construct key to retrieve inventory into dict
getter_list = [x['getter'] for x in inventory_calculation_dict['first_level']]
......@@ -249,6 +259,7 @@ class Inventory(Delivery):
# Create tmp movement
kwd = {'uid': movement.getUid(),
'start_date': stop_date,
'stop_date': stop_date,
'order_id': getOrderIdCounter(),
'mirror_order_id':getOrderIdCounter()
}
......@@ -300,6 +311,7 @@ class Inventory(Delivery):
kwd = {'uid': inventory_uid,
'start_date': stop_date,
'stop_date': stop_date,
'order_id': getOrderIdCounter(),
'mirror_order_id':getOrderIdCounter()
}
......@@ -358,3 +370,9 @@ class Inventory(Delivery):
portal.portal_catalog.catalogObjectList(
stock_object_list[:], method_id_list=('z_catalog_stock_list_without_delete_for_inventory_virtual_movement', ),
**catalog_kw)
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