Sourced wnframework-modules from Google Code as erpnext

This commit is contained in:
Pratik Vyas
2011-06-08 14:37:15 +05:30
commit c1e6e4c752
1680 changed files with 162635 additions and 0 deletions

View File

View File

@@ -0,0 +1,31 @@
// ======================= 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(`tabTicket`.project, "") = `tabProject`.name AND `tabTicket`.name = "'+d.task_id+'" AND';
return repl('SELECT distinct `tabProject`.`name` FROM `tabProject`, `tabTicket` 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(`tabTicket`.project, "") = "'+d.project_name+'" AND';
return repl('SELECT distinct `tabTicket`.`subject` FROM `tabTicket` WHERE %(cond)s `tabTicket`.`subject` LIKE "%s" ORDER BY `tabTicket`.`subject` ASC LIMIT 50', {cond:cond});
}

View File

@@ -0,0 +1,81 @@
# Please edit this list and import only required elements
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, removechild, getchildren, make_autoname, SuperDocType
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 `tabTicket` 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 cstr(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')

View File

@@ -0,0 +1,510 @@
[
{
'_last_update': '1300962490',
'allow_attach': None,
'allow_copy': None,
'allow_email': None,
'allow_print': None,
'allow_rename': None,
'allow_trash': None,
'autoname': 'TimeSheet.#####',
'change_log': None,
'client_script': None,
'client_script_core': None,
'client_string': None,
'colour': 'White:FFF',
'creation': '2010-12-14 10:33:07',
'description': None,
'docstatus': 0,
'doctype': 'DocType',
'document_type': None,
'dt_template': None,
'hide_heading': None,
'hide_toolbar': None,
'idx': None,
'in_create': None,
'in_dialog': None,
'is_transaction_doc': None,
'issingle': None,
'istable': None,
'max_attachments': None,
'menu_index': None,
'modified': '2011-03-05 17:16:43',
'modified_by': 'Administrator',
'module': 'Projects',
'name': 'Timesheet',
'name_case': None,
'owner': 'ashwini@webnotestech.com',
'parent': None,
'parent_node': None,
'parentfield': None,
'parenttype': None,
'print_outline': None,
'read_only': None,
'read_only_onload': None,
'search_fields': 'status, owner, timesheet_date',
'section_style': 'Simple',
'server_code': None,
'server_code_compiled': None,
'server_code_core': None,
'server_code_error': ' ',
'show_in_menu': None,
'smallicon': None,
'subject': '%(owner)s',
'tag_fields': '',
'use_template': None,
'version': 68
},
{
'amend': 1,
'cancel': 1,
'create': 1,
'creation': '2010-12-23 11:48:49',
'docstatus': 0,
'doctype': 'DocPerm',
'execute': None,
'idx': None,
'match': None,
'modified': '2010-12-23 11:48:49',
'modified_by': 'Administrator',
'name': 'PERM00769',
'owner': 'Administrator',
'parent': 'Timesheet',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'Projects User',
'submit': 1,
'write': 1
},
{
'amend': None,
'cancel': None,
'create': None,
'creation': '2010-12-23 11:48:49',
'docstatus': 0,
'doctype': 'DocPerm',
'execute': None,
'idx': None,
'match': None,
'modified': '2010-12-23 11:48:49',
'modified_by': 'Administrator',
'name': 'PERM00770',
'owner': 'Administrator',
'parent': 'Timesheet',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 1,
'read': 1,
'role': 'Projects User',
'submit': None,
'write': None
},
{
'amend': 1,
'cancel': 1,
'create': 1,
'creation': '2010-12-14 10:33:07',
'docstatus': 0,
'doctype': 'DocPerm',
'execute': None,
'idx': 1,
'match': None,
'modified': '2010-12-14 10:33:07',
'modified_by': 'Administrator',
'name': 'PERM00739',
'owner': 'ashwini@webnotestech.com',
'parent': 'Timesheet',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'Administrator',
'submit': 1,
'write': 1
},
{
'amend': None,
'cancel': None,
'create': None,
'creation': '2010-12-14 10:33:07',
'docstatus': 0,
'doctype': 'DocPerm',
'execute': None,
'idx': 2,
'match': None,
'modified': '2010-12-14 10:33:07',
'modified_by': 'Administrator',
'name': 'PERM00740',
'owner': 'ashwini@webnotestech.com',
'parent': 'Timesheet',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 1,
'read': 1,
'role': 'Administrator',
'submit': None,
'write': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-03-05 17:16:42',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': None,
'fieldtype': 'Section Break',
'hidden': None,
'icon': None,
'idx': 1,
'in_filter': None,
'label': 'Timesheet Details',
'modified': '2011-03-05 17:16:42',
'modified_by': 'Administrator',
'name': 'FL04673',
'no_column': None,
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Timesheet',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': 'White:FFF',
'creation': '2010-12-14 10:33:07',
'default': 'Draft',
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'status',
'fieldtype': 'Select',
'hidden': None,
'icon': None,
'idx': 2,
'in_filter': 0,
'label': 'Status',
'modified': '2010-12-14 10:33:07',
'modified_by': 'Administrator',
'name': 'FL04235',
'no_column': None,
'no_copy': None,
'oldfieldname': 'status',
'oldfieldtype': 'Select',
'options': '\nDraft\nSubmitted\nCancelled',
'owner': 'ashwini@webnotestech.com',
'parent': 'Timesheet',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': None,
'report_hide': None,
'reqd': 1,
'search_index': 1,
'trigger': '',
'width': None
},
{
'allow_on_submit': None,
'colour': 'White:FFF',
'creation': '2010-12-14 10:33:07',
'default': 'Today',
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'timesheet_date',
'fieldtype': 'Date',
'hidden': None,
'icon': None,
'idx': 3,
'in_filter': 1,
'label': 'Timesheet Date',
'modified': '2010-12-14 10:33:07',
'modified_by': 'Administrator',
'name': 'FL04236',
'no_column': None,
'no_copy': None,
'oldfieldname': 'timesheet_date',
'oldfieldtype': 'Date',
'options': None,
'owner': 'ashwini@webnotestech.com',
'parent': 'Timesheet',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': 1,
'search_index': 1,
'trigger': '',
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-12-14 10:33:07',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'owner',
'fieldtype': 'Link',
'hidden': None,
'icon': None,
'idx': 4,
'in_filter': 1,
'label': 'Timesheet By',
'modified': '2010-12-14 10:33:07',
'modified_by': 'Administrator',
'name': 'FL04237',
'no_column': None,
'no_copy': None,
'oldfieldname': 'owner',
'oldfieldtype': 'Link',
'options': 'Profile',
'owner': 'ashwini@webnotestech.com',
'parent': 'Timesheet',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': 1,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-12-14 10:33:07',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'amended_from',
'fieldtype': 'Data',
'hidden': 1,
'icon': None,
'idx': 5,
'in_filter': None,
'label': 'Amended From',
'modified': '2010-12-14 10:33:07',
'modified_by': 'Administrator',
'name': 'FL04238',
'no_column': None,
'no_copy': None,
'oldfieldname': 'amended_from',
'oldfieldtype': 'Data',
'options': None,
'owner': 'ashwini@webnotestech.com',
'parent': 'Timesheet',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': 1,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-12-14 10:33:07',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'amendment_date',
'fieldtype': 'Date',
'hidden': 1,
'icon': None,
'idx': 6,
'in_filter': None,
'label': 'Amendment Date',
'modified': '2010-12-14 10:33:07',
'modified_by': 'Administrator',
'name': 'FL04239',
'no_column': None,
'no_copy': None,
'oldfieldname': 'amendment_date',
'oldfieldtype': 'Date',
'options': None,
'owner': 'ashwini@webnotestech.com',
'parent': 'Timesheet',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': 1,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-03-05 17:16:42',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': None,
'fieldtype': 'Column Break',
'hidden': None,
'icon': None,
'idx': 7,
'in_filter': None,
'label': None,
'modified': '2011-03-05 17:16:42',
'modified_by': 'Administrator',
'name': 'FL04674',
'no_column': None,
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Timesheet',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-03-05 17:16:42',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'notes',
'fieldtype': 'Text',
'hidden': None,
'icon': None,
'idx': 8,
'in_filter': None,
'label': 'Notes',
'modified': '2011-03-05 17:16:42',
'modified_by': 'Administrator',
'name': 'FL04672',
'no_column': None,
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Timesheet',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-03-05 17:16:42',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': None,
'fieldtype': 'Section Break',
'hidden': None,
'icon': None,
'idx': 9,
'in_filter': None,
'label': None,
'modified': '2011-03-05 17:16:42',
'modified_by': 'Administrator',
'name': 'FL04675',
'no_column': None,
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': 'Simple',
'owner': 'Administrator',
'parent': 'Timesheet',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-12-14 10:33:07',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'timesheet_details',
'fieldtype': 'Table',
'hidden': None,
'icon': None,
'idx': 10,
'in_filter': None,
'label': 'Timesheet Details',
'modified': '2010-12-14 10:33:07',
'modified_by': 'Administrator',
'name': 'FL04240',
'no_column': None,
'no_copy': None,
'oldfieldname': 'timesheet_details',
'oldfieldtype': 'Table',
'options': 'Timesheet Detail',
'owner': 'ashwini@webnotestech.com',
'parent': 'Timesheet',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
}
]