mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-12 17:51:20 +00:00
moved directory structure
This commit is contained in:
1
projects/doctype/timesheet/__init__.py
Normal file
1
projects/doctype/timesheet/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
47
projects/doctype/timesheet/timesheet.js
Normal file
47
projects/doctype/timesheet/timesheet.js
Normal file
@@ -0,0 +1,47 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
// ======================= OnLoad =============================================
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
|
||||
if(!doc.timesheet_date) set_multiple(cdt,cdn,{timesheet_date:get_today()});
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){}
|
||||
|
||||
|
||||
cur_frm.fields_dict['timesheet_details'].grid.get_field("project_name").get_query = function(doc,cdt,cdn){
|
||||
var cond=cond1='';
|
||||
var d = locals[cdt][cdn];
|
||||
//if(d.customer_name) cond = 'ifnull(`tabProject`.customer_name, "") = "'+d.customer_name+'" AND';
|
||||
if(d.task_id) cond1 = 'ifnull(`tabTask`.project, "") = `tabProject`.name AND `tabTask`.name = "'+d.task_id+'" AND';
|
||||
|
||||
return repl('SELECT distinct `tabProject`.`name` FROM `tabProject`, `tabTask` WHERE %(cond1)s `tabProject`.`name` LIKE "%s" ORDER BY `tabProject`.`name` ASC LIMIT 50', {cond1:cond1});
|
||||
}
|
||||
|
||||
cur_frm.cscript.task_name = function(doc, cdt, cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.task_name) get_server_fields('get_task_details', d.task_name, 'timesheet_details', doc, cdt, cdn, 1);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['timesheet_details'].grid.get_field("task_name").get_query = function(doc,cdt,cdn){
|
||||
var cond='';
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.project_name) cond = 'ifnull(`tabTask`.project, "") = "'+d.project_name+'" AND';
|
||||
|
||||
return repl('SELECT distinct `tabTask`.`subject` FROM `tabTask` WHERE %(cond)s `tabTask`.`subject` LIKE "%s" ORDER BY `tabTask`.`subject` ASC LIMIT 50', {cond:cond});
|
||||
}
|
||||
98
projects/doctype/timesheet/timesheet.py
Normal file
98
projects/doctype/timesheet/timesheet.py
Normal file
@@ -0,0 +1,98 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def get_customer_details(self, project_name):
|
||||
cust = sql("select customer, customer_name from `tabProject` where name = %s", project_name)
|
||||
if cust:
|
||||
ret = {'customer': cust and cust[0][0] or '', 'customer_name': cust and cust[0][1] or ''}
|
||||
return (ret)
|
||||
|
||||
def get_task_details(self, task_sub):
|
||||
tsk = sql("select name, project, customer, customer_name from `tabTask` where subject = %s", task_sub)
|
||||
if tsk:
|
||||
ret = {'task_id': tsk and tsk[0][0] or '', 'project_name': tsk and tsk[0][1] or '', 'customer_name': tsk and tsk[0][3] or ''}
|
||||
return ret
|
||||
|
||||
def validate(self):
|
||||
if getdate(self.doc.timesheet_date) > getdate(nowdate()):
|
||||
msgprint("You can not prepare timesheet for future date")
|
||||
raise Exception
|
||||
|
||||
chk = sql("select name from `tabTimesheet` where timesheet_date=%s and owner=%s and status!='Cancelled' and name!=%s", (self.doc.timesheet_date, self.doc.owner, self.doc.name))
|
||||
if chk:
|
||||
msgprint("You have already created timesheet "+ cstr(chk and chk[0][0] or '')+" for this date.")
|
||||
raise Exception
|
||||
|
||||
import time
|
||||
for d in getlist(self.doclist, 'timesheet_details'):
|
||||
if d.act_start_time and d.act_end_time:
|
||||
d1 = time.strptime(d.act_start_time, "%H:%M")
|
||||
d2 = time.strptime(d.act_end_time, "%H:%M")
|
||||
|
||||
if d1 > d2:
|
||||
msgprint("Start time can not be greater than end time. Check for Task Id : "+cstr(d.task_id))
|
||||
raise Exception
|
||||
elif d1 == d2:
|
||||
msgprint("Start time and end time can not be same. Check for Task Id : "+cstr(d.task_id))
|
||||
raise Exception
|
||||
|
||||
def calculate_total_hr(self):
|
||||
import datetime
|
||||
import time
|
||||
for d in getlist(self.doclist, 'timesheet_details'):
|
||||
x1 = d.act_start_time.split(":")
|
||||
x2 = d.act_end_time.split(":")
|
||||
|
||||
d1 = datetime.timedelta(minutes=cint(x1[1]), hours=cint(x1[0]))
|
||||
d2 = datetime.timedelta(minutes=cint(x2[1]), hours=cint(x2[0]))
|
||||
d3 = (d2 - d1).seconds
|
||||
d.act_total_hrs = time.strftime("%H:%M", time.gmtime(d3))
|
||||
sql("update `tabTimesheet Detail` set act_total_hrs = %s where parent=%s and name=%s", (d.act_total_hrs,self.doc.name,d.name))
|
||||
|
||||
def on_update(self):
|
||||
self.calculate_total_hr()
|
||||
set(self.doc, 'status', 'Draft')
|
||||
|
||||
def on_submit(self):
|
||||
set(self.doc, 'status', 'Submitted')
|
||||
|
||||
def on_cancel(self):
|
||||
set(self.doc, 'status', 'Cancelled')
|
||||
212
projects/doctype/timesheet/timesheet.txt
Normal file
212
projects/doctype/timesheet/timesheet.txt
Normal file
@@ -0,0 +1,212 @@
|
||||
# DocType, Timesheet
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:07',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 18:47:10',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'ashwini@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'TimeSheet.#####',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'is_submittable': 1,
|
||||
'module': u'Projects',
|
||||
'name': '__common__',
|
||||
'search_fields': u'status, owner, timesheet_date',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'subject': u'%(owner)s',
|
||||
'version': 69
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Timesheet',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Timesheet',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Timesheet
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Timesheet'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Projects User',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Projects User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 1,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'submit': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'timesheet_details_section_break',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Timesheet Details',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'Draft',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'status',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 0,
|
||||
'label': u'Status',
|
||||
'oldfieldname': u'status',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nDraft\nSubmitted\nCancelled',
|
||||
'permlevel': 1,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'Today',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'timesheet_date',
|
||||
'fieldtype': u'Date',
|
||||
'in_filter': 1,
|
||||
'label': u'Timesheet Date',
|
||||
'oldfieldname': u'timesheet_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'owner',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'Timesheet By',
|
||||
'oldfieldname': u'owner',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Profile',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amended_from',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 1,
|
||||
'label': u'Amended From',
|
||||
'oldfieldname': u'amended_from',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'amendment_date',
|
||||
'fieldtype': u'Date',
|
||||
'hidden': 1,
|
||||
'label': u'Amendment Date',
|
||||
'oldfieldname': u'amendment_date',
|
||||
'oldfieldtype': u'Date',
|
||||
'permlevel': 1,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'notes',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Notes',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'section_break0',
|
||||
'fieldtype': u'Section Break',
|
||||
'options': u'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'timesheet_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Timesheet Details',
|
||||
'oldfieldname': u'timesheet_details',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Timesheet Detail',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
35
projects/doctype/timesheet/timesheet_list.js
Normal file
35
projects/doctype/timesheet/timesheet_list.js
Normal file
@@ -0,0 +1,35 @@
|
||||
// render
|
||||
wn.doclistviews['Timesheet'] = wn.views.ListView.extend({
|
||||
init: function(d) {
|
||||
this._super(d);
|
||||
this.fields = this.fields.concat([
|
||||
'`tabTimesheet`.status',
|
||||
'`tabTimesheet`.timesheet_date',
|
||||
'`tabTimesheet`.owner',
|
||||
'`tabTimesheet`.notes',
|
||||
|
||||
]);
|
||||
},
|
||||
|
||||
prepare_data: function(data) {
|
||||
this._super(data);
|
||||
data.timesheet_date = wn.datetime.str_to_user(data.timesheet_date);
|
||||
if(data.notes && data.notes.length > 50) {
|
||||
data.notes = '<span title="'+data.notes+'">' +
|
||||
data.notes.substr(0,50) + '...</span>';
|
||||
}
|
||||
},
|
||||
|
||||
columns: [
|
||||
{width: '3%', content: 'check'},
|
||||
{width: '5%', content: 'avatar'},
|
||||
{width: '3%', content: 'docstatus'},
|
||||
{width: '18%', content: 'name'},
|
||||
{width: '12%', content: 'status'},
|
||||
{width: '27%', content: 'notes+tags', css: {'color': '#777'}},
|
||||
{width: '20%', content: 'owner'},
|
||||
{width: '12%', content:'timesheet_date', css: {
|
||||
'text-align': 'right', 'color':'#777'
|
||||
}},
|
||||
]
|
||||
});
|
||||
Reference in New Issue
Block a user