Commit 1ed8face authored by Yusei Tahara's avatar Yusei Tahara

erp5_stock_cache: Fix Inventory reindex bug and add a test class.

SQLCatalog_trimInventoryCacheOnCatalog needs resource category on movement.
parent f65836d0
import unittest
from erp5.component.test.testInventory import TestInventory
class TestInventoryWithStockCache(TestInventory):
"Test Inventory API with erp5_stock_cache"
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestInventoryWithStockCache))
return suite
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testInventoryWithStockCache</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testInventoryWithStockCache</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testInventoryWithStockCache
\ No newline at end of file
erp5_trade
erp5_full_text_myisam_catalog
erp5_core_proxy_field_legacy
erp5_apparel
erp5_project
erp5_configurator_standard_solver
erp5_simulation_test_trade_template
erp5_simulation_test
erp5_administration
erp5_mrp
erp5_accounting
erp5_dummy_movement
erp5_core_test
\ No newline at end of file
...@@ -153,6 +153,8 @@ class Inventory(Delivery): ...@@ -153,6 +153,8 @@ class Inventory(Delivery):
stock_append = stock_object_list.append stock_append = stock_object_list.append
to_delete_stock_uid_set = set() to_delete_stock_uid_set = set()
to_delete_stock_uid_add = to_delete_stock_uid_set.add to_delete_stock_uid_add = to_delete_stock_uid_set.add
to_delete_list = []
to_delete_list_append = to_delete_list.append
for inventory_calculation_dict in default_inventory_calculation_list: for inventory_calculation_dict in default_inventory_calculation_list:
...@@ -204,8 +206,6 @@ class Inventory(Delivery): ...@@ -204,8 +206,6 @@ class Inventory(Delivery):
return value return value
for movement in method(): for movement in method():
# Make sure we remove any any value
to_delete_stock_uid_add(movement.getUid())
if movement.getResourceValue() is not None and \ if movement.getResourceValue() is not None and \
movement.getInventoriatedQuantity() not in (None, ''): movement.getInventoriatedQuantity() not in (None, ''):
...@@ -281,6 +281,10 @@ class Inventory(Delivery): ...@@ -281,6 +281,10 @@ class Inventory(Delivery):
kwd['category_list'] = category_list kwd['category_list'] = category_list
temp_delivery_line.edit(**kwd) temp_delivery_line.edit(**kwd)
stock_append(temp_delivery_line) stock_append(temp_delivery_line)
to_delete_list_append(temp_delivery_line)
else:
# Make sure we remove any any value
to_delete_stock_uid_add(movement.getUid())
# Now create line to remove some subvariation text not present # Now create line to remove some subvariation text not present
# in new inventory # in new inventory
...@@ -334,8 +338,6 @@ class Inventory(Delivery): ...@@ -334,8 +338,6 @@ class Inventory(Delivery):
# Do deletion for everything first, even if there is no need to apply correction, # Do deletion for everything first, even if there is no need to apply correction,
# in case we need to remove previous corrections # in case we need to remove previous corrections
to_delete_stock_uid_add(self.getUid()) to_delete_stock_uid_add(self.getUid())
to_delete_list = []
to_delete_list_append = to_delete_list.append
for uid in to_delete_stock_uid_set: for uid in to_delete_stock_uid_set:
temp_line = temp_constructor(self, inventory_id) temp_line = temp_constructor(self, inventory_id)
temp_line.setUid(uid) temp_line.setUid(uid)
......
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>Inventory</string> </value> <value> <string>Inventory</string> </value>
...@@ -53,13 +59,28 @@ ...@@ -53,13 +59,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -72,7 +93,7 @@ ...@@ -72,7 +93,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -81,7 +102,7 @@ ...@@ -81,7 +102,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
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