mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-27 13:55:19 +00:00
sync ref file
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
// 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/>.
|
||||
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn){
|
||||
$c('runserverobj', args={'method':'cal_tot_exp','docs':compress_doclist (make_doclist (doc.doctype,doc.name))},
|
||||
function(r, rt) { refresh_many(['year','months']); });
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
|
||||
cur_frm.cscript.employee = function(doc, cdt, cdn){
|
||||
$c('runserverobj', args={'method':'get_doj','docs':compress_doclist (make_doclist (doc.doctype,doc.name))},
|
||||
function(r, rt) { refresh_many(['employee_name','date_of_joining']); });
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
|
||||
cur_frm.cscript.country1 = function(doc, cdt, cdn) {
|
||||
var mydoc=doc;
|
||||
$c('runserverobj', args={'method':'check_state','arg':doc.country1, 'docs':compress_doclist([doc])},
|
||||
function(r,rt){
|
||||
|
||||
if(r.message) {
|
||||
var doc = locals[mydoc.doctype][mydoc.name];
|
||||
doc.state1 = '';
|
||||
get_field(doc.doctype, 'state1' , doc.name).options = r.message;
|
||||
refresh_field('state1');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
cur_frm.cscript.country2 = function(doc, cdt, cdn) {
|
||||
var mydoc=doc;
|
||||
$c('runserverobj', args={'method':'check_state', 'arg':doc.country2,'docs':compress_doclist([doc])},
|
||||
function(r,rt){
|
||||
|
||||
if(r.message) {
|
||||
var doc = locals[mydoc.doctype][mydoc.name];
|
||||
doc.state2 = '';
|
||||
get_field(doc.doctype, 'state2' , doc.name).options = r.message;
|
||||
refresh_field('state2');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
# 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
|
||||
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:
|
||||
#init function
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
|
||||
#=============================================================
|
||||
def autoname(self):
|
||||
self.doc.name = make_autoname('EMP-'+self.doc.employee)
|
||||
|
||||
#=============================================================
|
||||
def validate(self):
|
||||
if self.doc.personal_email:
|
||||
if not validate_email_add(self.doc.personal_email):
|
||||
msgprint("Please enter valid Personal Email")
|
||||
raise Exception
|
||||
ret = sql("select name from `tabEmployee Profile` where employee = '%s' and name !='%s'"%(self.doc.employee,self.doc.name))
|
||||
if ret:
|
||||
msgprint("Employee Profile is already created for Employee : '%s'"%self.doc.employee)
|
||||
raise Exception
|
||||
|
||||
#=============================================================
|
||||
def get_doj(self):
|
||||
ret_doj = sql("select employee_name,date_of_joining from `tabEmployee` where name = '%s'"%self.doc.employee)
|
||||
if ret_doj:
|
||||
set(self.doc, 'employee_name', cstr(ret_doj[0][0]))
|
||||
set(self.doc,'date_of_joining', ret_doj[0][1].strftime('%Y-%m-%d'))
|
||||
|
||||
#=============================================================
|
||||
#calculate total experience in company - total year and month
|
||||
def cal_tot_exp(self):
|
||||
if not self.doc.date_of_joining:
|
||||
self.get_doj()
|
||||
|
||||
import datetime
|
||||
today = nowdate()
|
||||
|
||||
diff = (getdate(today) - getdate(self.doc.date_of_joining)).days
|
||||
diff1 = cint(diff)/365
|
||||
a = cint(diff)%365
|
||||
diff2 = cint(a)/30
|
||||
if(cint(diff1)<0):
|
||||
set(self.doc,'year', 0)
|
||||
else:
|
||||
set(self.doc,'year', cint(diff1))
|
||||
if(cint(diff1)<0):
|
||||
set(self.doc,'months', 0)
|
||||
else:
|
||||
set(self.doc,'months', cint(diff2))
|
||||
|
||||
#=============================================================
|
||||
def check_state(self,country):
|
||||
return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " %country)])
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user