Commit c5269014 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Eteri

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 10128055
<?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 @@
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
<tuple>
<string>contributor/person_module/2</string>
</tuple>
</value>
</item>
<item>
......@@ -108,7 +110,7 @@
<value> <string encoding="cdata"><![CDATA[
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
# images/ajax-loader.gif\n
# version 1.0\n
......@@ -334,7 +336,7 @@ NETWORK:\n
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>supercedriclen</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -348,7 +350,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.54751.3513.37683</string> </value>
<value> <string>957.20828.35466.8669</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -366,7 +368,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1486474400.78</float>
<float>1490349225.88</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,6 +3,7 @@
(function (window, rJS, RSVP, jIO, UriTemplate, alertify, indexedDB) {
"use strict";
// xxxxxxxxxxxxxxxxx overwrite
/*
function openIndexedDB(jio_storage) {
var db_name = jio_storage._database_name;
function resolver(resolve, reject) {
......@@ -79,7 +80,7 @@
return handleRequest(transaction
.objectStore("metadata")["delete"](id));
});
};
};*/
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
......@@ -300,7 +301,7 @@
limit: [0, 1234567890]
},
use_remote_post: true,
conflict_handling: 3,
conflict_handling: 2,
check_local_modification: false,
check_local_creation: true,
check_local_deletion: false,
......
......@@ -224,7 +224,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>supercedriclen</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.57376.32743.11895</string> </value>
<value> <string>956.57502.32307.34304</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1485348028.59</float>
<float>1490349163.71</float>
<string>UTC</string>
</tuple>
</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 @@
portal = context.getPortalObject()
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
# Is it the only new record
......
image_module/marker-icon
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_record_list
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