Commit facd7811 authored by Łukasz Nowak's avatar Łukasz Nowak

Split locking/unlocking to two alarms.

parent 3949f204
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_managePersonLock</string> </value>
<value> <string>Alarm_lockPerson</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -22,7 +22,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>vifib_manage_person_lock</string> </value>
<value> <string>vifib_lock_person</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Manages person locks</string> </value>
<value> <string>Locks Person if needed</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_unlockPerson</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>vifib_unlock_person</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value> <int>5</int> </value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>946684800.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Unlocks Person if possible</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -58,10 +58,12 @@ method_kw.update(\n
maximum_due_date=(DateTime() - context.portal_preferences.getPreferredMaximumDueDay()).Date(),\n
simulation_state=context.getPortalCurrentInventoryStateList() + context.getPortalTransitInventoryStateList(),\n
ongoing_simulation_state=context.getPortalFutureInventoryStateList() + context.getPortalReservedInventoryStateList(),\n
section_uid=context.restrictedTraverse(\'organisation_module/vifib_internet\').getUid(), \n
section_uid=context.restrictedTraverse(\'organisation_module/vifib_internet\').getUid(),\n
operation=\'lock\'\n
)\n
portal_catalog.searchAndActivate(\n
method_id=\'Person_manageLockByBalance\',\n
payment_state=\'unlocked\',\n
portal_type=\'Person\',\n
activate_kw={\'tag\': tag},\n
method_kw=method_kw\n
......@@ -74,7 +76,7 @@ portal_catalog.searchAndActivate(\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_managePersonLock</string> </value>
<value> <string>Alarm_lockPerson</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</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>portal_catalog = context.getPortalObject().portal_catalog\n
from DateTime import DateTime\n
method_kw = {}\n
method_kw.update(\n
maximum_balance=context.portal_preferences.getPreferredMaximumBalance(),\n
maximum_due_date=(DateTime() - context.portal_preferences.getPreferredMaximumDueDay()).Date(),\n
simulation_state=context.getPortalCurrentInventoryStateList() + context.getPortalTransitInventoryStateList(),\n
ongoing_simulation_state=context.getPortalFutureInventoryStateList() + context.getPortalReservedInventoryStateList(),\n
section_uid=context.restrictedTraverse(\'organisation_module/vifib_internet\').getUid(),\n
operation=\'unlock\'\n
)\n
portal_catalog.searchAndActivate(\n
method_id=\'Person_manageLockByBalance\',\n
payment_state=\'locked\',\n
portal_type=\'Person\',\n
activate_kw={\'tag\': tag},\n
method_kw=method_kw\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_unlockPerson</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -62,9 +62,9 @@ balance = context.portal_simulation.getInventoryAssetPrice(\n
\n
if maximum_balance > balance:\n
# customer reached his balance, shall be locked\n
if not locked:\n
context.lock()\n
return\n
if not locked and operation == \'lock\':\n
context.lock()\n
return\n
\n
# check ongoing payments and check that date if is acceptable, if not lock\n
if context.portal_catalog.countResults(\n
......@@ -75,11 +75,11 @@ if context.portal_catalog.countResults(\n
\'delivery.start_date\': \'<= %s\' % maximum_due_date\n
})[0][0] > 0:\n
# there are ongoing old payments, shall be locked\n
if not locked:\n
context.lock()\n
if not locked and operation == \'lock\':\n
context.lock()\n
else:\n
# there are no ongoing payments and balance is acceptable\n
if locked:\n
if locked and operation == \'unlock\':\n
context.unlock()\n
......@@ -87,7 +87,7 @@ else:\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>maximum_balance, maximum_due_date, simulation_state, section_uid, ongoing_simulation_state</string> </value>
<value> <string>maximum_balance, maximum_due_date, simulation_state, section_uid, ongoing_simulation_state, operation</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
529
\ No newline at end of file
530
\ No newline at end of file
portal_alarms/confirm_ordered_sale_order
portal_alarms/stop_planned_sale_invoice_transaction
portal_alarms/vifib_check_consistency
portal_alarms/vifib_lock_person
portal_alarms/vifib_lock_software_instance
portal_alarms/vifib_manage_person_lock
portal_alarms/vifib_trigger_build
portal_alarms/vifib_unlock_person
portal_alarms/vifib_unlock_software_instance
portal_alarms/vifib_update_open_sale_order_line
\ No newline at end of file
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