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
Pipeline #19967 failed with stage
in 0 seconds
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):
stock_append = stock_object_list.append
to_delete_stock_uid_set = set()
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:
......@@ -204,8 +206,6 @@ class Inventory(Delivery):
return value
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 \
movement.getInventoriatedQuantity() not in (None, ''):
......@@ -281,6 +281,10 @@ class Inventory(Delivery):
kwd['category_list'] = category_list
temp_delivery_line.edit(**kwd)
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
# in new inventory
......@@ -334,8 +338,6 @@ class Inventory(Delivery):
# Do deletion for everything first, even if there is no need to apply correction,
# in case we need to remove previous corrections
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:
temp_line = temp_constructor(self, inventory_id)
temp_line.setUid(uid)
......
......@@ -6,6 +6,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>Inventory</string> </value>
......@@ -53,13 +59,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</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/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -72,7 +93,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -81,7 +102,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</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