Commit 3c2de7e5 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Xiaowu Zhang

erp5_travel_expense: Add dynamic Leave request type using services

parent 4aad72e4
......@@ -26,6 +26,34 @@
};
function getResouceSelectList(gadget, doc) {
return new RSVP.Queue()
.push(function (){
return gadget.allDocs({
query: 'portal_type:"Service" AND use:"hr/leave%"',
select_list: ['relative_url', 'title'],
limit: [0, 100]
});
})
.push(function (result) {
var i = 0,
tmp,
ops,
select_options = [];
for (i = 0; i < result.data.total_rows; i += 1) {
tmp = {
title: result.data.rows[i].value.title,
value: result.data.rows[i].value.relative_url
};
if (doc.resource === result.data.rows[i].value.relative_url) {
tmp.is_selected = true;
}
select_options.push(tmp);
}
return select_options;
});
}
gadget_klass
.ready(function (g) {
return g.getElement()
......@@ -64,48 +92,12 @@
return new RSVP.Queue()
.push (function () {
return {
data: {
total_rows: 14,
rows: [
{title: "Congés Payés Annuels", relative_url: "1"},
{title: "Congés d'ancienneté", relative_url: "2"},
{title: "Congé ancienneté demi journée", relative_url: "3"},
{title: "Congé RTT individuel", relative_url: "4"},
{title: "Congé révision examen apprenti", relative_url: "5"},
{title: "Congé naissance adoption", relative_url: "6"},
{title: "Congé déménagement personnel", relative_url: "7"},
{title: "Congé Mariage/PACS du salarié", relative_url: "8"},
{title: "Congé Mariage/PACS famille", relative_url: "9"},
{title: "Congé Maladie Enfant", relative_url: "10"},
{title: "Hospitalisation CONJ. Enfant", relative_url: "11"},
{title: "Amenag. Hor. PDT Grossesse", relative_url: "12"},
{title: "Congé décès Famille", relative_url: "13"},
{title: "Congé déménagement mutation", relative_url: "14"},
]
}
}
/*gadget.allDocs({
query: 'portal_type:"Currency"',
select_list: ['relative_url', 'title'],
limit: [0, 100]
});*/
return getResouceSelectList(gadget, options.doc);
})
.push(function (result) {
.push(function (select_options) {
var i = 0,
tmp,
ops,
select_options = [];
for (i = 0; i < result.data.total_rows; i += 1) {
tmp = {
title: result.data.rows[i].title,
value: result.data.rows[i].relative_url
};
if (options.doc.resource === result.data.rows[i].relative_url) {
tmp.is_selected = true;
}
select_options.push(tmp);
}
ops;
if (options.doc.sync_flag === '1') {
sync_checked = 'checked';
} else {
......@@ -260,9 +252,10 @@
if ((submit_event.target[i].type == "radio" || submit_event.target[i].type == "checkbox") && !submit_event.target[i].checked){
continue
}
if (submit_event.target[i].name === "resource"){
if (submit_event.target[i].nodeName === "SELECT"){
doc[submit_event.target[i].name] = submit_event.target[i].value;
doc["resource_title"] = resource_type[submit_event.target[i].value].title;
doc[submit_event.target[i].name + "_title"] =
submit_event.target[i].options[submit_event.target[i].selectedIndex].text;
}
if (submit_event.target[i].name === "photo") {
continue
......
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.44329.14852.21316</string> </value>
<value> <string>956.54639.50122.42052</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1484576839.9</float>
<float>1485178593.24</float>
<string>UTC</string>
</tuple>
</state>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Preferred resource value for Expense Validation Requests</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_leave_request_period_resource_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python: []</string> </value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/lines</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Use values to filter list of resource for Expense Validation Requests</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_leave_request_period_use_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -46,6 +46,7 @@ else:
line.edit(
start_date=DateTime(record.getStartDate()),
stop_date=DateTime(record.getStopDate()),
resource=record.getResource(),
)
record.deliver()
......
......@@ -29,7 +29,8 @@ new_record.edit(
start_date=line.getStartDate(),
stop_date=line.getStopDate(),
comment=context.getDescription(),
resource=line.getResource(),
resource_tilte=line.getResourceTitle(),
)
new_record.stop()
new_record.Record_archivePreviousVersions()
......@@ -91,21 +91,23 @@
</item>
<item>
<key> <string>left</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list>
<string>my_preferred_expense_validation_request_use_list</string>
<string>my_preferred_expense_validation_request_resource</string>
<string>my_preferred_travel_request_use_list</string>
<string>my_preferred_travel_request_resource</string>
<string>my_preferred_leave_request_period_use_list</string>
<string>my_preferred_leave_request_period_resource</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_leave_request_period_resource</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Preferred Resource for Leave Requests Periods</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [(\'\', \'\')] + [(resource.getTitle(), resource.getRelativeUrl()) for resource in here.getPortalObject().portal_catalog(portal_type=here.getPortalObject().getPortalResourceTypeList(), validation_state=\'validated\', use_uid=here.getPortalObject().portal_categories.getCategoryUid(here.getPreference(field.getId().replace(\'my_\', \'\').replace(\'_resource\', \'_use\')), base_category=\'use\'))]</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_leave_request_period_use_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_multi_list_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Leave Request Period Uses</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: getattr(here.portal_categories.use, preferences.getPreference(\'preferred_category_child_item_list_method_id\', \'getCategoryChildCompactLogicalPathItemList\'))(local_sort_id=(\'int_index\', \'translated_title\'), checked_permission=\'View\')</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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