mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 03:01:22 +00:00
added time log batch
This commit is contained in:
@@ -11,8 +11,19 @@ class DocType:
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def validate(self):
|
||||
self.set_status()
|
||||
self.validate_overlap()
|
||||
|
||||
|
||||
def set_status(self):
|
||||
if self.doc.docstatus==0:
|
||||
self.doc.status = "Draft"
|
||||
elif self.doc.docstatus==1:
|
||||
self.doc.status = "Submitted"
|
||||
elif self.doc.docstatus==2:
|
||||
self.doc.status = "Cancelled"
|
||||
|
||||
# billed will be set directly
|
||||
|
||||
def validate_overlap(self):
|
||||
existing = webnotes.conn.sql_list("""select name from `tabTime Log` where owner=%s and
|
||||
((from_time between %s and %s) or (to_time between %s and %s)) and name!=%s""",
|
||||
@@ -22,6 +33,7 @@ class DocType:
|
||||
if existing:
|
||||
webnotes.msgprint(_("This Time Log conflicts with") + ":" + ', '.join(existing),
|
||||
raise_exception=True)
|
||||
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_events(start, end):
|
||||
|
||||
@@ -2,15 +2,17 @@
|
||||
{
|
||||
"creation": "2013-02-26 14:58:28",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-02-26 16:09:53",
|
||||
"modified": "2013-02-28 18:41:40",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"autoname": "TL-.######",
|
||||
"description": "Log of Activities performed by users against Tasks that can be used for tracking time, billing.",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Master",
|
||||
"is_submittable": 1,
|
||||
"module": "Projects",
|
||||
"name": "__common__"
|
||||
},
|
||||
@@ -19,8 +21,7 @@
|
||||
"name": "__common__",
|
||||
"parent": "Time Log",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
"parenttype": "DocType"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
@@ -30,30 +31,47 @@
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Time Log"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 1,
|
||||
"label": "Status",
|
||||
"options": "Draft\nSubmitted\nBatched for Billing\nBilled\nCancelled",
|
||||
"permlevel": 0,
|
||||
"read_only": 1,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "from_time",
|
||||
"fieldtype": "Datetime",
|
||||
"in_list_view": 1,
|
||||
"label": "From Time",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "to_time",
|
||||
"fieldtype": "Datetime",
|
||||
"in_list_view": 0,
|
||||
"label": "To Time",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Column Break"
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -62,6 +80,7 @@
|
||||
"in_list_view": 1,
|
||||
"label": "Activity Type",
|
||||
"options": "Activity Type",
|
||||
"permlevel": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
@@ -69,29 +88,35 @@
|
||||
"fieldname": "task",
|
||||
"fieldtype": "Link",
|
||||
"label": "Task",
|
||||
"options": "Task"
|
||||
"options": "Task",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "billable",
|
||||
"fieldtype": "Check",
|
||||
"label": "Billable"
|
||||
"in_list_view": 1,
|
||||
"label": "Billable",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_7",
|
||||
"fieldtype": "Section Break"
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "note",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Note"
|
||||
"label": "Note",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "section_break_9",
|
||||
"fieldtype": "Section Break"
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -99,23 +124,42 @@
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Project",
|
||||
"options": "Project"
|
||||
"options": "Project",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sales_invoice",
|
||||
"fieldtype": "Link",
|
||||
"label": "Sales Invoice",
|
||||
"options": "Sales Invoice"
|
||||
"fieldname": "file_list",
|
||||
"fieldtype": "Text",
|
||||
"hidden": 1,
|
||||
"label": "File List",
|
||||
"no_copy": 1,
|
||||
"permlevel": 0,
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"label": "Amended From",
|
||||
"no_copy": 1,
|
||||
"options": "Sales Invoice",
|
||||
"permlevel": 1,
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"match": "owner",
|
||||
"role": "Projects User"
|
||||
"role": "Projects User",
|
||||
"submit": 1
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"cancel": 1,
|
||||
"doctype": "DocPerm",
|
||||
"role": "Projects Manager"
|
||||
"role": "Projects Manager",
|
||||
"submit": 0
|
||||
}
|
||||
]
|
||||
28
projects/doctype/time_log/time_log_list.js
Normal file
28
projects/doctype/time_log/time_log_list.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// render
|
||||
wn.listview_settings['Time Log'] = {
|
||||
selectable: true,
|
||||
onload: function(me) {
|
||||
me.appframe.add_button(wn._("Make Time Log Batch"), function() {
|
||||
var selected = me.get_checked_items() || [];
|
||||
|
||||
if(!selected.length) {
|
||||
msgprint(wn._("Please select Time Logs."))
|
||||
}
|
||||
|
||||
// select only billable time logs
|
||||
for(var i in selected) {
|
||||
var d = selected[i];
|
||||
if(!d.billable) {
|
||||
msgprint(wn._("Time Log is not billable") + ": " + d.name);
|
||||
return;
|
||||
}
|
||||
if(d.sales_invoice) {
|
||||
msgprint(wn._("Time Log has been Invoiced") + ": " + d.name);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
}, "icon-file-alt");
|
||||
}
|
||||
};
|
||||
0
projects/doctype/time_log_batch/__init__.py
Normal file
0
projects/doctype/time_log_batch/__init__.py
Normal file
18
projects/doctype/time_log_batch/time_log_batch.js
Normal file
18
projects/doctype/time_log_batch/time_log_batch.js
Normal file
@@ -0,0 +1,18 @@
|
||||
cur_frm.add_fetch("time_log", "activity_type", "activity_type");
|
||||
cur_frm.add_fetch("time_log", "owner", "created_by");
|
||||
|
||||
cur_frm.set_query("time_log", "time_log_batch_details", function(doc) {
|
||||
return {
|
||||
query: "projects.utils.get_time_log_list",
|
||||
filters: {
|
||||
"billable": 1,
|
||||
"status": "Submitted"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.extend(cur_frm.cscript, {
|
||||
refresh: function() {
|
||||
|
||||
}
|
||||
})
|
||||
11
projects/doctype/time_log_batch/time_log_batch.py
Normal file
11
projects/doctype/time_log_batch/time_log_batch.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def on_submit(self):
|
||||
# update time logs as batched
|
||||
88
projects/doctype/time_log_batch/time_log_batch.txt
Normal file
88
projects/doctype/time_log_batch/time_log_batch.txt
Normal file
@@ -0,0 +1,88 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-28 17:57:33",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-02-28 18:36:28",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"autoname": "naming_series:",
|
||||
"description": "Batch Time Logs for Billing.",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Transaction",
|
||||
"is_submittable": 1,
|
||||
"module": "Projects",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Time Log Batch",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Time Log Batch",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Projects User",
|
||||
"submit": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Time Log Batch"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "naming_series",
|
||||
"fieldtype": "Select",
|
||||
"label": "Naming Series",
|
||||
"options": "TLB-",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"description": "For Sales Invoice",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "rate",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Rate"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "time_log_batch_details",
|
||||
"fieldtype": "Table",
|
||||
"label": "Time Log Batch Details",
|
||||
"options": "Time Log Batch Detail"
|
||||
},
|
||||
{
|
||||
"description": "In Hours",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "total_time",
|
||||
"fieldtype": "Float",
|
||||
"label": "Total Time",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"label": "Amended From",
|
||||
"no_copy": 1,
|
||||
"options": "Time Log Batch",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
||||
0
projects/doctype/time_log_batch_detail/__init__.py
Normal file
0
projects/doctype/time_log_batch_detail/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
@@ -0,0 +1,51 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-02-28 17:56:12",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-02-28 17:56:12",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"istable": 1,
|
||||
"module": "Projects",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Time Log Batch Detail",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Time Log Batch Detail"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "time_log",
|
||||
"fieldtype": "Link",
|
||||
"label": "Time Log",
|
||||
"options": "Time Log",
|
||||
"reqd": 1,
|
||||
"width": "200px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "created_by",
|
||||
"fieldtype": "Link",
|
||||
"label": "Created By",
|
||||
"options": "Profile",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "activity_type",
|
||||
"fieldtype": "Data",
|
||||
"label": "Activity Type",
|
||||
"read_only": 1
|
||||
}
|
||||
]
|
||||
@@ -21,7 +21,10 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
if(!doc.timesheet_date) set_multiple(cdt,cdn,{timesheet_date:get_today()});
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){}
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
cur_frm.set_intro("Timesheets will soon be removed. Please create a new Time Log. To create \
|
||||
a new Time Log, to to Projects > Time Log > New Time Log. This will be removed in a few days.")
|
||||
}
|
||||
|
||||
|
||||
cur_frm.fields_dict['timesheet_details'].grid.get_field("project_name").get_query = function(doc,cdt,cdn){
|
||||
|
||||
@@ -51,6 +51,8 @@ class DocType:
|
||||
return time.strptime(timestr, format)
|
||||
|
||||
def validate(self):
|
||||
msgprint("Please create a new Time Log", raise_exception=True)
|
||||
|
||||
if getdate(self.doc.timesheet_date) > getdate(nowdate()):
|
||||
msgprint("You can not prepare timesheet for future date")
|
||||
raise Exception
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
[
|
||||
"Projects Home",
|
||||
"Projects"
|
||||
]
|
||||
@@ -16,16 +16,22 @@ wn.module_page["Projects"] = [
|
||||
description: wn._("Project master."),
|
||||
doctype:"Project"
|
||||
},
|
||||
{
|
||||
label: wn._("Timesheet"),
|
||||
description: wn._("Timesheet for tasks."),
|
||||
doctype:"Timesheet"
|
||||
},
|
||||
{
|
||||
label: wn._("Time Log"),
|
||||
description: wn._("Time Log for tasks."),
|
||||
doctype:"Time Log"
|
||||
},
|
||||
{
|
||||
label: wn._("Time Log Batch"),
|
||||
description: wn._("Batch Time Logs for billing."),
|
||||
doctype:"Time Log Batch"
|
||||
},
|
||||
{
|
||||
label: wn._("Timesheet"),
|
||||
description: wn._("[DEPRECATED] Timesheet for tasks."),
|
||||
doctype:"Timesheet"
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
8
projects/utils.py
Normal file
8
projects/utils.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_time_log_list(doctype, txt, searchfield, start, page_len, filters):
|
||||
return webnotes.conn.get_values("Time Log", filters, ["name", "activity_type", "owner"], debug=True)
|
||||
Reference in New Issue
Block a user