diff --git a/product/ERP5/bootstrap/erp5_core/PathTemplateItem/portal_alarms/check_stock.xml b/bt5/erp5_administration/PathTemplateItem/portal_alarms/check_stock.xml similarity index 92% rename from product/ERP5/bootstrap/erp5_core/PathTemplateItem/portal_alarms/check_stock.xml rename to bt5/erp5_administration/PathTemplateItem/portal_alarms/check_stock.xml index 7b5e127746e57c1bb9984edc52c216d012d2f01f..a2ba0b1e82aea0d56f065a27e1e5b7cc012542f0 100644 --- a/product/ERP5/bootstrap/erp5_core/PathTemplateItem/portal_alarms/check_stock.xml +++ b/bt5/erp5_administration/PathTemplateItem/portal_alarms/check_stock.xml @@ -29,7 +29,15 @@ </item> <item> <key> <string>active_sense_method_id</string> </key> - <value> <string>Alarm_activateCheckStockTable</string> </value> + <value> <string>Alarm_checkStockTable</string> </value> + </item> + <item> + <key> <string>alarm_notification_mode</string> </key> + <value> + <tuple> + <string>problem</string> + </tuple> + </value> </item> <item> <key> <string>description</string> </key> diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_activateCheckStockTable.xml b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_activateCheckStockTable.xml deleted file mode 100644 index 391dc205d24962a4fdec9616326e41c002452f36..0000000000000000000000000000000000000000 --- a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_activateCheckStockTable.xml +++ /dev/null @@ -1,126 +0,0 @@ -<?xml version="1.0"?> -<ZopeData> - <record id="1" aka="AAAAAAAAAAE="> - <pickle> - <tuple> - <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> - <tuple/> - </tuple> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>Script_magic</string> </key> - <value> <int>3</int> </value> - </item> - <item> - <key> <string>_bind_names</string> </key> - <value> - <object> - <klass> - <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> - </klass> - <tuple/> - <state> - <dictionary> - <item> - <key> <string>_asgns</string> </key> - <value> - <dictionary> - <item> - <key> <string>name_container</string> </key> - <value> <string>container</string> </value> - </item> - <item> - <key> <string>name_context</string> </key> - <value> <string>context</string> </value> - </item> - <item> - <key> <string>name_m_self</string> </key> - <value> <string>script</string> </value> - </item> - <item> - <key> <string>name_subpath</string> </key> - <value> <string>traverse_subpath</string> </value> - </item> - </dictionary> - </value> - </item> - </dictionary> - </state> - </object> - </value> - </item> - <item> - <key> <string>_body</string> </key> - <value> <string>active_process = context.newActiveProcess()\n -result = context.Alarm_checkStockTable(active_process=\'/\'.join(active_process.getPhysicalPath()))\n -active_process.postResult(result)\n -</string> </value> - </item> - <item> - <key> <string>_code</string> </key> - <value> - <none/> - </value> - </item> - <item> - <key> <string>_params</string> </key> - <value> <string></string> </value> - </item> - <item> - <key> <string>errors</string> </key> - <value> - <tuple/> - </value> - </item> - <item> - <key> <string>func_code</string> </key> - <value> - <object> - <klass> - <global name="FuncCode" module="Shared.DC.Scripts.Signature"/> - </klass> - <tuple/> - <state> - <dictionary> - <item> - <key> <string>co_argcount</string> </key> - <value> <int>0</int> </value> - </item> - <item> - <key> <string>co_varnames</string> </key> - <value> - <tuple> - <string>_getattr_</string> - <string>context</string> - <string>active_process</string> - <string>result</string> - </tuple> - </value> - </item> - </dictionary> - </state> - </object> - </value> - </item> - <item> - <key> <string>func_defaults</string> </key> - <value> - <none/> - </value> - </item> - <item> - <key> <string>id</string> </key> - <value> <string>Alarm_activateCheckStockTable</string> </value> - </item> - <item> - <key> <string>warnings</string> </key> - <value> - <tuple/> - </value> - </item> - </dictionary> - </pickle> - </record> -</ZopeData> diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkCatalogTable.xml b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkCatalogTable.xml index dd46c19deab808ea12f0cf443b0772dbaed6e4f2..ad90426d1588f69a5f01a5d4516a21429c3dc13b 100644 --- a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkCatalogTable.xml +++ b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkCatalogTable.xml @@ -53,8 +53,10 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>context.ERP5Site_checkCatalogTable(\n + <value> <string>return context.ERP5Site_checkCatalogTable(\n active_process=context.newActiveProcess().getPath(),\n + activity_count=activity_count,\n + bundle_object_count=bundle_object_count,\n **kw)\n </string> </value> </item> @@ -66,7 +68,7 @@ </item> <item> <key> <string>_params</string> </key> - <value> <string>**kw</string> </value> + <value> <string>activity_count=1, bundle_object_count=100, **kw</string> </value> </item> <item> <key> <string>errors</string> </key> @@ -86,12 +88,14 @@ <dictionary> <item> <key> <string>co_argcount</string> </key> - <value> <int>0</int> </value> + <value> <int>2</int> </value> </item> <item> <key> <string>co_varnames</string> </key> <value> <tuple> + <string>activity_count</string> + <string>bundle_object_count</string> <string>kw</string> <string>_apply_</string> <string>_getattr_</string> @@ -107,7 +111,10 @@ <item> <key> <string>func_defaults</string> </key> <value> - <none/> + <tuple> + <int>1</int> + <int>100</int> + </tuple> </value> </item> <item> diff --git a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkStockTable.xml b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkStockTable.xml index 87712528e187d70704850b638a6bb4d53863264d..5ad80c8365be2d821dedb25f46588f5a657df132 100644 --- a/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkStockTable.xml +++ b/bt5/erp5_administration/SkinTemplateItem/portal_skins/erp5_administration/Alarm_checkStockTable.xml @@ -54,11 +54,13 @@ <item> <key> <string>_body</string> </key> <value> <string>catalog_kw = {\'select_dict\': {\'quantity\':\'stock.quantity\'}, \'stock.quantity\': \'!=0\' }\n -return context.ERP5Site_checkCatalogTable(bundle_object_count=bundle_object_count,\n - bundle_offset=bundle_offset,\n - property_override_method_id=\'ERP5Site_getStockTableFilterDict\',\n - active_process=active_process,\n - catalog_kw=catalog_kw)\n +return context.ERP5Site_checkCatalogTable(\n + active_process=context.newActiveProcess().getPath(),\n + activity_count=activity_count,\n + bundle_object_count=bundle_object_count,\n + catalog_kw=catalog_kw,\n + property_override_method_id=\'ERP5Site_getStockTableFilterDict\',\n + **kw)\n </string> </value> </item> <item> @@ -69,7 +71,7 @@ return context.ERP5Site_checkCatalogTable(bundle_object_count=bundle_object_coun </item> <item> <key> <string>_params</string> </key> - <value> <string>bundle_object_count=100, bundle_offset=0, active_process=None</string> </value> + <value> <string>activity_count=1, bundle_object_count=100, **kw</string> </value> </item> <item> <key> <string>errors</string> </key> @@ -89,16 +91,17 @@ return context.ERP5Site_checkCatalogTable(bundle_object_count=bundle_object_coun <dictionary> <item> <key> <string>co_argcount</string> </key> - <value> <int>3</int> </value> + <value> <int>2</int> </value> </item> <item> <key> <string>co_varnames</string> </key> <value> <tuple> + <string>activity_count</string> <string>bundle_object_count</string> - <string>bundle_offset</string> - <string>active_process</string> + <string>kw</string> <string>catalog_kw</string> + <string>_apply_</string> <string>_getattr_</string> <string>context</string> </tuple> @@ -113,9 +116,8 @@ return context.ERP5Site_checkCatalogTable(bundle_object_count=bundle_object_coun <key> <string>func_defaults</string> </key> <value> <tuple> + <int>1</int> <int>100</int> - <int>0</int> - <none/> </tuple> </value> </item> diff --git a/bt5/erp5_administration/bt/revision b/bt5/erp5_administration/bt/revision index b2412e34dff05e77952f3f930772631cac5a3be7..4e9e288487445d1193130dba3e3c6af29b242115 100644 --- a/bt5/erp5_administration/bt/revision +++ b/bt5/erp5_administration/bt/revision @@ -1 +1 @@ -62 \ No newline at end of file +63 \ No newline at end of file diff --git a/bt5/erp5_administration/bt/template_path_list b/bt5/erp5_administration/bt/template_path_list index 1ef70fc5427d21686f5bc02b62b32445d23b8fe8..cd8179e7f2f2633ae339bc3eae8696d3a887d176 100644 --- a/bt5/erp5_administration/bt/template_path_list +++ b/bt5/erp5_administration/bt/template_path_list @@ -1,2 +1,3 @@ portal_alarms/check_catalog -portal_alarms/check_folder_handler \ No newline at end of file +portal_alarms/check_folder_handler +portal_alarms/check_stock \ No newline at end of file diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index 77e48ce77545528902c5cadd7e7b90278fec4f56..51b4bee7939beeb705f44a0ca01cc6f596f334a8 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -1193 \ No newline at end of file +1194 \ No newline at end of file diff --git a/product/ERP5/bootstrap/erp5_core/bt/template_path_list b/product/ERP5/bootstrap/erp5_core/bt/template_path_list index 24a918cd62a56b87fbf3953a61540f8b91d2ade5..26396cd21ea558832c673fc0c09d2913daabbdd9 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/template_path_list +++ b/product/ERP5/bootstrap/erp5_core/bt/template_path_list @@ -1,4 +1,3 @@ -portal_alarms/check_stock portal_alarms/expired_password_alarm portal_caches/erp5_content_long portal_caches/erp5_content_long/default_ram_cache diff --git a/product/ERP5/tests/testERP5Administration.py b/product/ERP5/tests/testERP5Administration.py index 35b373253969def188c7779fb93da466103ad352..4044c4f3227adfa1ad55d0736f6a684a34d8efce 100644 --- a/product/ERP5/tests/testERP5Administration.py +++ b/product/ERP5/tests/testERP5Administration.py @@ -28,7 +28,7 @@ ############################################################################## import unittest - +import transaction from Products.ERP5.tests.testInventoryAPI import InventoryAPITestCase class TestERP5Administration(InventoryAPITestCase): @@ -49,21 +49,35 @@ class TestERP5Administration(InventoryAPITestCase): between the predicate table and zodb objects """ portal = self.getPortal() - mvt = self._makeMovement(quantity=100) - get_transaction().commit() - self.tic() + sql_test = portal.erp5_sql_connection.manage_test alarm = portal.portal_alarms.check_stock - alarm.activeSense() - get_transaction().commit() + + def checkActiveProcess(failed): + transaction.get().commit() + self.tic() + self.assertEqual(alarm.getLastActiveProcess().ActiveProcess_sense(), + failed) + def checkStock(row_count): + alarm.activeSense() + checkActiveProcess(1) + alarm.solve() + checkActiveProcess(1) + alarm.activeSense() + checkActiveProcess(0) + self.assertEqual(row_count, sql_test("select count(*) from stock")[0][0]) + + alarm.setAlarmNotificationMode('never') + mvt = self._makeMovement(quantity=1.23) + transaction.get().commit() self.tic() - last_active_process = alarm.getLastActiveProcess() - self.assertFalse(last_active_process.ActiveProcess_sense()) - portal.erp5_sql_connection.manage_test("update stock set quantity=5") alarm.activeSense() - get_transaction().commit() - self.tic() - last_active_process = alarm.getLastActiveProcess() - self.assertTrue(last_active_process.ActiveProcess_sense()) + checkActiveProcess(0) + + row_count = sql_test("select count(*) from stock")[0][0] + sql_test("update stock set quantity=5") + checkStock(row_count) # alarm.solve will reindex 'mvt' + mvt.getParentValue()._delOb(mvt.getId()) + checkStock(row_count-2) # alarm.solve will unindex 'mvt' def test_suite(): suite = unittest.TestSuite()