Time Log Batch creation from time log list

This commit is contained in:
Nabin Hait 2014-05-06 11:58:00 +05:30
parent cea4cd4e5f
commit b1285f9fce
2 changed files with 14 additions and 12 deletions

View File

@ -2,7 +2,7 @@
"allow_attach": 1, "allow_attach": 1,
"allow_import": 1, "allow_import": 1,
"autoname": "naming_series:", "autoname": "naming_series:",
"creation": "2013-04-03 16:38:41.000000", "creation": "2013-04-03 16:38:41",
"description": "Log of Activities performed by users against Tasks that can be used for tracking time, billing.", "description": "Log of Activities performed by users against Tasks that can be used for tracking time, billing.",
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
@ -29,7 +29,7 @@
{ {
"fieldname": "to_time", "fieldname": "to_time",
"fieldtype": "Datetime", "fieldtype": "Datetime",
"in_list_view": 0, "in_list_view": 1,
"label": "To Time", "label": "To Time",
"permlevel": 0, "permlevel": 0,
"read_only": 0, "read_only": 0,
@ -38,6 +38,7 @@
{ {
"fieldname": "hours", "fieldname": "hours",
"fieldtype": "Float", "fieldtype": "Float",
"in_list_view": 1,
"label": "Hours", "label": "Hours",
"permlevel": 0, "permlevel": 0,
"read_only": 1 "read_only": 1
@ -151,7 +152,7 @@
"icon": "icon-time", "icon": "icon-time",
"idx": 1, "idx": 1,
"is_submittable": 1, "is_submittable": 1,
"modified": "2014-01-22 16:05:35.000000", "modified": "2014-05-06 11:53:04.133874",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Projects", "module": "Projects",
"name": "Time Log", "name": "Time Log",

View File

@ -10,7 +10,8 @@ frappe.listview_settings['Time Log'] = {
var selected = me.get_checked_items() || []; var selected = me.get_checked_items() || [];
if(!selected.length) { if(!selected.length) {
msgprint(__("Please select Time Logs.")) msgprint(__("Please select Time Logs."));
return;
} }
// select only billable time logs // select only billable time logs
@ -22,6 +23,7 @@ frappe.listview_settings['Time Log'] = {
} }
if(d.status!="Submitted") { if(d.status!="Submitted") {
msgprint(__("Time Log Status must be Submitted.")); msgprint(__("Time Log Status must be Submitted."));
return
} }
} }
@ -29,15 +31,14 @@ frappe.listview_settings['Time Log'] = {
frappe.model.with_doctype("Time Log Batch", function() { frappe.model.with_doctype("Time Log Batch", function() {
var tlb = frappe.model.get_new_doc("Time Log Batch"); var tlb = frappe.model.get_new_doc("Time Log Batch");
$.each(selected, function(i, d) { $.each(selected, function(i, d) {
var detail = frappe.model.get_new_doc("Time Log Batch Detail"); var detail = frappe.model.get_new_doc("Time Log Batch Detail", tlb,
"time_log_batch_details");
$.extend(detail, { $.extend(detail, {
"parenttype": "Time Log Batch",
"parentfield": "time_log_batch_details",
"parent": tlb.name,
"time_log": d.name, "time_log": d.name,
"activity_type": d.activity_type, "activity_type": d.activity_type,
"created_by": d.owner, "created_by": d.owner,
"idx": i+1 "hours": d.hours
}); });
}) })
frappe.set_route("Form", "Time Log Batch", tlb.name); frappe.set_route("Form", "Time Log Batch", tlb.name);