Commit e6e617ff authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_travel_expense: Improve Record processing

* Only process Expense records with a date set (avoid processing records with no data)
* Add garbage collect on empty draft records
* Change jIO configuration to resolve conflict with remote as the reference
* Comment indexxedDB patch XXX code should be added for Safari to use websqlstorage
parent 5eb00a9d
<?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_garbageCollectDraftExpenseRecordList</string> </value>
</item>
<item>
<key> <string>automatic_solve</string> </key>
<value> <int>0</int> </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>alarm_garbage_collect_draft_expense_record_list</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_hour_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_minute_frequency</string> </key>
<value>
<none/>
</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>1435665600.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>Process Draft Record List</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -66,7 +66,9 @@ ...@@ -66,7 +66,9 @@
<item> <item>
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple/> <tuple>
<string>contributor/person_module/2</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -108,7 +110,7 @@ ...@@ -108,7 +110,7 @@
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
CACHE MANIFEST\n CACHE MANIFEST\n
# generated on Fri, 09 Jun 2016 11:45:33 +0000\n # generated on Fri, 24 March 2017 11:45:33 +0000\n
# XXX + fonts\n # XXX + fonts\n
# images/ajax-loader.gif\n # images/ajax-loader.gif\n
# version 1.0\n # version 1.0\n
...@@ -334,7 +336,7 @@ NETWORK:\n ...@@ -334,7 +336,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>supercedriclen</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -348,7 +350,7 @@ NETWORK:\n ...@@ -348,7 +350,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.54751.3513.37683</string> </value> <value> <string>957.20828.35466.8669</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -366,7 +368,7 @@ NETWORK:\n ...@@ -366,7 +368,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1486474400.78</float> <float>1490349225.88</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
(function (window, rJS, RSVP, jIO, UriTemplate, alertify, indexedDB) { (function (window, rJS, RSVP, jIO, UriTemplate, alertify, indexedDB) {
"use strict"; "use strict";
// xxxxxxxxxxxxxxxxx overwrite // xxxxxxxxxxxxxxxxx overwrite
/*
function openIndexedDB(jio_storage) { function openIndexedDB(jio_storage) {
var db_name = jio_storage._database_name; var db_name = jio_storage._database_name;
function resolver(resolve, reject) { function resolver(resolve, reject) {
...@@ -79,7 +80,7 @@ ...@@ -79,7 +80,7 @@
return handleRequest(transaction return handleRequest(transaction
.objectStore("metadata")["delete"](id)); .objectStore("metadata")["delete"](id));
}); });
}; };*/
function endsWith(str, suffix) { function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1; return str.indexOf(suffix, str.length - suffix.length) !== -1;
...@@ -300,7 +301,7 @@ ...@@ -300,7 +301,7 @@
limit: [0, 1234567890] limit: [0, 1234567890]
}, },
use_remote_post: true, use_remote_post: true,
conflict_handling: 3, conflict_handling: 2,
check_local_modification: false, check_local_modification: false,
check_local_creation: true, check_local_creation: true,
check_local_deletion: false, check_local_deletion: false,
......
...@@ -224,7 +224,7 @@ ...@@ -224,7 +224,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>supercedriclen</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.57376.32743.11895</string> </value> <value> <string>956.57502.32307.34304</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485348028.59</float> <float>1490349163.71</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate(
portal_type=(
"Expense Record",
),
simulation_state=["draft"],
method_id='ExpenseRecord_garbageCollectDraftRecord',
)
<?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>_params</string> </key>
<value> <string>tag, fixit, params</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_garbageCollectDraftExpenseRecordList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
if context.ExpenseRecord_isRecordReadyForProcess():
if context.getSimulationState() == "draft" and context.getModificationDate() < DateTime() - 1:
context.cancel()
<?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>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ExpenseRecord_garbageCollectDraftRecord</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
return context.getSimulationState() not in ("draft", "started") or not context.getDate()
<?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>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ExpenseRecord_isRecordReadyForProcess</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Record_isRecordReadyForProcess</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
portal = context.getPortalObject() portal = context.getPortalObject()
record = context record = context
if record.getSimulationState() not in ("draft", "started"): is_record_ready_method = record.getTypeBasedMethod(
"isRecordReadyForProcess",
fallback_script_id="Record_isRecordReadyForProcess"
)
if is_record_ready_method():
return return
# Is it the only new record # Is it the only new record
......
image_module/marker-icon image_module/marker-icon
image_module/marker-shadow image_module/marker-shadow
portal_alarms/alarm_garbage_collect_draft_expense_record_list
portal_alarms/alarm_process_draft_localisation_record portal_alarms/alarm_process_draft_localisation_record
portal_alarms/alarm_process_draft_record_list portal_alarms/alarm_process_draft_record_list
portal_alarms/create_representative_record_for_expense_validation_request portal_alarms/create_representative_record_for_expense_validation_request
......
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