Merge branch 'wsgi' of https://github.com/webnotes/erpnext into i18n

Conflicts:
	accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
	accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
	public/js/complete_setup.js
	selling/doctype/opportunity/opportunity.js
	selling/doctype/quotation/quotation.js
This commit is contained in:
Bárbara Perretti
2013-10-16 15:09:18 -03:00
250 changed files with 5061 additions and 2506 deletions

View File

@@ -7,7 +7,6 @@ import webnotes
from webnotes.utils import getdate, nowdate
from webnotes import msgprint, _
sql = webnotes.conn.sql
class DocType:
def __init__(self, doc, doclist=[]):
@@ -15,7 +14,7 @@ class DocType:
self.doclist = doclist
def validate_duplicate_record(self):
res = sql("""select name from `tabAttendance` where employee = %s and att_date = %s
res = webnotes.conn.sql("""select name from `tabAttendance` where employee = %s and att_date = %s
and name != %s and docstatus = 1""",
(self.doc.employee, self.doc.att_date, self.doc.name))
if res:
@@ -24,7 +23,7 @@ class DocType:
def check_leave_record(self):
if self.doc.status == 'Present':
leave = sql("""select name from `tabLeave Application`
leave = webnotes.conn.sql("""select name from `tabLeave Application`
where employee = %s and %s between from_date and to_date and status = 'Approved'
and docstatus = 1""", (self.doc.employee, self.doc.att_date))
@@ -42,7 +41,7 @@ class DocType:
msgprint(_("Attendance can not be marked for future dates"), raise_exception=1)
def validate_employee(self):
emp = sql("select name from `tabEmployee` where name = %s and status = 'Active'",
emp = webnotes.conn.sql("select name from `tabEmployee` where name = %s and status = 'Active'",
self.doc.employee)
if not emp:
msgprint(_("Employee: ") + self.doc.employee +

View File

@@ -4,7 +4,6 @@
wn.provide("erpnext.hr");
erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
setup: function() {
this.setup_leave_approver_select();
this.frm.fields_dict.user_id.get_query = function(doc,cdt,cdn) {
return { query:"core.doctype.profile.profile.profile_query"} }
this.frm.fields_dict.reports_to.get_query = function(doc,cdt,cdn) {
@@ -12,6 +11,7 @@ erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({
},
onload: function() {
this.setup_leave_approver_select();
this.frm.toggle_display(["esic_card_no", "gratuity_lic_id", "pan_number", "pf_number"],
wn.control_panel.country==="India");
if(this.frm.doc.__islocal) this.frm.set_value("employee_name", "");

View File

@@ -4,11 +4,10 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import getdate, validate_email_add, cstr
from webnotes.utils import getdate, validate_email_add, cstr, cint
from webnotes.model.doc import make_autoname
from webnotes import msgprint, _
sql = webnotes.conn.sql
class DocType:
def __init__(self,doc,doclist=[]):
@@ -40,12 +39,12 @@ class DocType:
self.validate_email()
self.validate_status()
self.validate_employee_leave_approver()
self.update_dob_event()
def on_update(self):
if self.doc.user_id:
self.update_user_default()
self.update_profile()
self.update_dob_event()
def update_user_default(self):
webnotes.conn.set_default("employee", self.doc.name, self.doc.user_id)
@@ -156,10 +155,11 @@ class DocType:
raise_exception=InvalidLeaveApproverError)
def update_dob_event(self):
if self.doc.status == "Active" and self.doc.date_of_birth:
if self.doc.status == "Active" and self.doc.date_of_birth \
and not cint(webnotes.conn.get_value("HR Settings", None, "stop_birthday_reminders")):
birthday_event = webnotes.conn.sql("""select name from `tabEvent` where repeat_on='Every Year'
and ref_type='Employee' and ref_name=%s""", self.doc.name)
starts_on = self.doc.date_of_birth + " 00:00:00"
ends_on = self.doc.date_of_birth + " 00:15:00"

View File

@@ -2,12 +2,13 @@
{
"creation": "2013-03-07 09:04:18",
"docstatus": 0,
"modified": "2013-08-08 14:22:11",
"modified": "2013-10-11 10:52:53",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
"allow_rename": 1,
"autoname": "naming_series:",
"doctype": "DocType",
"document_type": "Master",

View File

@@ -10,7 +10,6 @@ from webnotes.model.doc import addchild, make_autoname
from webnotes.model.bean import copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql
import datetime

View File

@@ -6,6 +6,24 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
self.doc, self.doclist = d, dl
def validate(self):
self.original_stop_birthday_reminders = cint(webnotes.conn.get_value("HR Settings",
None, "stop_birthday_reminders"))
def on_update(self):
# reset birthday reminders
if cint(self.doc.stop_birthday_reminders) != self.original_stop_birthday_reminders:
webnotes.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and ref_type='Employee'""")
if not self.doc.stop_birthday_reminders:
for employee in webnotes.conn.sql_list("""select name from `tabEmployee` where status='Active' and
ifnull(date_of_birth, '')!=''"""):
webnotes.get_obj("Employee", employee).update_dob_event()
webnotes.msgprint(webnotes._("Updated Birthday Reminders"))

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-08-02 13:45:23",
"docstatus": 0,
"modified": "2013-08-02 14:22:26",
"modified": "2013-10-02 15:44:38",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -38,6 +38,12 @@
"doctype": "DocType",
"name": "HR Settings"
},
{
"doctype": "DocField",
"fieldname": "employee_settings",
"fieldtype": "Section Break",
"label": "Employee Settings"
},
{
"description": "Employee record is created using selected field. ",
"doctype": "DocField",
@@ -46,6 +52,19 @@
"label": "Employee Records to be created by",
"options": "Naming Series\nEmployee Number"
},
{
"description": "Don't send Employee Birthday Reminders",
"doctype": "DocField",
"fieldname": "stop_birthday_reminders",
"fieldtype": "Check",
"label": "Stop Birthday Reminders"
},
{
"doctype": "DocField",
"fieldname": "payroll_settings",
"fieldtype": "Section Break",
"label": "Payroll Settings"
},
{
"description": "If checked, Total no. of Working Days will include holidays, and this will reduce the value of Salary Per Day",
"doctype": "DocField",

View File

@@ -37,7 +37,7 @@ class JobsMailbox(POP3Mailbox):
mail.save_attachments_in_doc(applicant.doc)
make(content=mail.content, sender=mail.from_email,
doctype="Job Applicant", name=applicant.doc.name)
doctype="Job Applicant", name=applicant.doc.name, sent_or_received="Received")
def get_job_applications():
if cint(webnotes.conn.get_value('Jobs Email Settings', None, 'extract_emails')):

View File

@@ -11,14 +11,9 @@ from webnotes.utils import extract_email_id
class DocType(TransactionBase):
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def get_sender(self, comm):
return webnotes.conn.get_value('Jobs Email Settings',None,'email_id')
def on_communication(self, comm):
if webnotes.conn.get_value("Profile", extract_email_id(comm.sender), "user_type")=="System User":
status = "Replied"
else:
status = "Open"
webnotes.conn.set(self.doc, 'status', status)
return webnotes.conn.get_value('Jobs Email Settings',None,'email_id')
def validate(self):
self.set_status()

View File

@@ -5,7 +5,6 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, flt
from webnotes import msgprint
sql = webnotes.conn.sql
class DocType:
def __init__(self, doc, doclist):
@@ -37,7 +36,7 @@ class DocType:
def check_existing_leave_allocation(self):
"""check whether leave for same type is already allocated or not"""
leave_allocation = sql("""select name from `tabLeave Allocation`
leave_allocation = webnotes.conn.sql("""select name from `tabLeave Allocation`
where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1""",
(self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
if leave_allocation:
@@ -64,14 +63,14 @@ class DocType:
return self.get_leaves_allocated(prev_fyear) - self.get_leaves_applied(prev_fyear)
def get_leaves_applied(self, fiscal_year):
leaves_applied = sql("""select SUM(ifnull(total_leave_days, 0))
leaves_applied = webnotes.conn.sql("""select SUM(ifnull(total_leave_days, 0))
from `tabLeave Application` where employee=%s and leave_type=%s
and fiscal_year=%s and docstatus=1""",
(self.doc.employee, self.doc.leave_type, fiscal_year))
return leaves_applied and flt(leaves_applied[0][0]) or 0
def get_leaves_allocated(self, fiscal_year):
leaves_allocated = sql("""select SUM(ifnull(total_leaves_allocated, 0))
leaves_allocated = webnotes.conn.sql("""select SUM(ifnull(total_leaves_allocated, 0))
from `tabLeave Allocation` where employee=%s and leave_type=%s
and fiscal_year=%s and docstatus=1 and name!=%s""",
(self.doc.employee, self.doc.leave_type, fiscal_year, self.doc.name))
@@ -79,7 +78,7 @@ class DocType:
def allow_carry_forward(self):
"""check whether carry forward is allowed or not for this leave type"""
cf = sql("""select is_carry_forward from `tabLeave Type` where name = %s""",
cf = webnotes.conn.sql("""select is_carry_forward from `tabLeave Type` where name = %s""",
self.doc.leave_type)
cf = cf and cint(cf[0][0]) or 0
if not cf:
@@ -110,7 +109,7 @@ class DocType:
webnotes.conn.set(self.doc,'total_leaves_allocated',flt(leave_det['total_leaves_allocated']))
def check_for_leave_application(self):
exists = sql("""select name from `tabLeave Application`
exists = webnotes.conn.sql("""select name from `tabLeave Application`
where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1""",
(self.doc.employee, self.doc.leave_type, self.doc.fiscal_year))
if exists:

View File

@@ -7,6 +7,9 @@ import unittest
from hr.doctype.leave_application.leave_application import LeaveDayBlockedError, OverlapError
class TestLeaveApplication(unittest.TestCase):
def tearDown(self):
webnotes.session.user = "Administrator"
def _clear_roles(self):
webnotes.conn.sql("""delete from `tabUserRole` where parent in
("test@example.com", "test1@example.com", "test2@example.com")""")
@@ -15,6 +18,7 @@ class TestLeaveApplication(unittest.TestCase):
webnotes.conn.sql("""delete from `tabLeave Application`""")
def _add_employee_leave_approver(self, employee, leave_approver):
temp_session_user = webnotes.session.user
webnotes.session.user = "Administrator"
employee = webnotes.bean("Employee", employee)
employee.doclist.append({
@@ -23,6 +27,7 @@ class TestLeaveApplication(unittest.TestCase):
"leave_approver": leave_approver
})
employee.save()
webnotes.session.user = temp_session_user
def get_application(self, doclist):
application = webnotes.bean(copy=doclist)
@@ -31,7 +36,6 @@ class TestLeaveApplication(unittest.TestCase):
return application
def test_block_list(self):
webnotes.session.user = "Administrator"
self._clear_roles()
from webnotes.profile import add_role
@@ -54,7 +58,6 @@ class TestLeaveApplication(unittest.TestCase):
self.assertTrue(application.insert())
def test_overlap(self):
webnotes.session.user = "Administrator"
self._clear_roles()
self._clear_applications()
@@ -72,7 +75,6 @@ class TestLeaveApplication(unittest.TestCase):
self.assertRaises(OverlapError, application.insert)
def test_global_block_list(self):
webnotes.session.user = "Administrator"
self._clear_roles()
from webnotes.profile import add_role
@@ -98,7 +100,6 @@ class TestLeaveApplication(unittest.TestCase):
"applies_to_all_departments", 0)
def test_leave_approval(self):
webnotes.session.user = "Administrator"
self._clear_roles()
from webnotes.profile import add_role

View File

@@ -7,6 +7,9 @@ import unittest
from hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates
class TestLeaveBlockList(unittest.TestCase):
def tearDown(self):
webnotes.session.user = "Administrator"
def test_get_applicable_block_dates(self):
webnotes.session.user = "test@example.com"
webnotes.conn.set_value("Department", "_Test Department", "leave_block_list",

View File

@@ -9,7 +9,6 @@ from webnotes.model.doc import Document
from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
@@ -34,7 +33,7 @@ class DocType:
emp_query = "select name from `tabEmployee` "
if flag == 1:
emp_query += condition
e = sql(emp_query)
e = webnotes.conn.sql(emp_query)
return e
# ----------------

View File

@@ -11,7 +11,6 @@ from webnotes.model.bean import getlist, copy_doclist
from webnotes.model.code import get_obj
from webnotes import msgprint
sql = webnotes.conn.sql
@@ -30,7 +29,7 @@ class DocType:
cond = self.get_filter_condition()
cond += self.get_joining_releiving_condition()
emp_list = sql("""
emp_list = webnotes.conn.sql("""
select t1.name
from `tabEmployee` t1, `tabSalary Structure` t2
where t1.docstatus!=2 and t2.docstatus != 2
@@ -68,7 +67,7 @@ class DocType:
def get_month_details(self, year, month):
ysd = sql("select year_start_date from `tabFiscal Year` where name ='%s'"%year)[0][0]
ysd = webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name ='%s'"%year)[0][0]
if ysd:
from dateutil.relativedelta import relativedelta
import calendar, datetime
@@ -96,7 +95,7 @@ class DocType:
emp_list = self.get_emp_list()
ss_list = []
for emp in emp_list:
if not sql("""select name from `tabSalary Slip`
if not webnotes.conn.sql("""select name from `tabSalary Slip`
where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s
""", (emp[0], self.doc.month, self.doc.fiscal_year, self.doc.company)):
ss = webnotes.bean({
@@ -127,7 +126,7 @@ class DocType:
which are not submitted
"""
cond = self.get_filter_condition()
ss_list = sql("""
ss_list = webnotes.conn.sql("""
select t1.name from `tabSalary Slip` t1
where t1.docstatus = 0 and month = '%s' and fiscal_year = '%s' %s
""" % (self.doc.month, self.doc.fiscal_year, cond))
@@ -189,7 +188,7 @@ class DocType:
Get total salary amount from submitted salary slip based on selected criteria
"""
cond = self.get_filter_condition()
tot = sql("""
tot = webnotes.conn.sql("""
select sum(rounded_total) from `tabSalary Slip` t1
where t1.docstatus = 1 and month = '%s' and fiscal_year = '%s' %s
""" % (self.doc.month, self.doc.fiscal_year, cond))
@@ -202,7 +201,7 @@ class DocType:
get default bank account,default salary acount from company
"""
amt = self.get_total_salary()
com = sql("select default_bank_account from `tabCompany` where name = '%s'" % self.doc.company)
com = webnotes.conn.sql("select default_bank_account from `tabCompany` where name = '%s'" % self.doc.company)
if not com[0][0] or not com[0][1]:
msgprint("You can set Default Bank Account in Company master.")

View File

@@ -9,7 +9,7 @@ test_records = []
# from webnotes.model.doc import Document
# from webnotes.model.code import get_obj
# sql = webnotes.conn.sql
# webnotes.conn.sql = webnotes.conn.sql
#
# class TestSalaryManager(unittest.TestCase):
# def setUp(self):
@@ -20,15 +20,15 @@ test_records = []
# ss1[0].employee = emp1.name
# for s in ss1: s.save(1)
# for s in ss1[1:]:
# sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
# sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
# webnotes.conn.sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
# webnotes.conn.sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
#
#
# ss2[0].employee = emp2.name
# for s in ss2: s.save(1)
# for s in ss2[1:]:
# sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
# sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
# webnotes.conn.sql("update `tabSalary Structure Earning` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
# webnotes.conn.sql("update `tabSalary Structure Deduction` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
#
# sman.save()
# self.sm = get_obj('Salary Manager')
@@ -36,7 +36,7 @@ test_records = []
# self.sm.create_sal_slip()
#
# def test_creation(self):
# ssid = sql("""
# ssid = webnotes.conn.sql("""
# select name, department
# from `tabSalary Slip`
# where month = '08' and fiscal_year='2011-2012'""")
@@ -46,7 +46,7 @@ test_records = []
#
#
# def test_lwp_calc(self):
# ss = sql("""
# ss = webnotes.conn.sql("""
# select payment_days
# from `tabSalary Slip`
# where month = '08' and fiscal_year='2011-2012' and employee = '%s'

View File

@@ -11,7 +11,6 @@ from webnotes.model.code import get_obj
from webnotes import msgprint, _
from setup.utils import get_company_currency
sql = webnotes.conn.sql
from utilities.transaction_base import TransactionBase
@@ -32,7 +31,7 @@ class DocType(TransactionBase):
def check_sal_struct(self):
struct = sql("select name from `tabSalary Structure` where employee ='%s' and is_active = 'Yes' "%self.doc.employee)
struct = webnotes.conn.sql("select name from `tabSalary Structure` where employee ='%s' and is_active = 'Yes' "%self.doc.employee)
if not struct:
msgprint("Please create Salary Structure for employee '%s'"%self.doc.employee)
self.doc.employee = ''
@@ -100,13 +99,13 @@ class DocType(TransactionBase):
return payment_days
def get_holidays_for_employee(self, m):
holidays = sql("""select t1.holiday_date
holidays = webnotes.conn.sql("""select t1.holiday_date
from `tabHoliday` t1, tabEmployee t2
where t1.parent = t2.holiday_list and t2.name = %s
and t1.holiday_date between %s and %s""",
(self.doc.employee, m['month_start_date'], m['month_end_date']))
if not holidays:
holidays = sql("""select t1.holiday_date
holidays = webnotes.conn.sql("""select t1.holiday_date
from `tabHoliday` t1, `tabHoliday List` t2
where t1.parent = t2.name and ifnull(t2.is_default, 0) = 1
and t2.fiscal_year = %s
@@ -120,7 +119,7 @@ class DocType(TransactionBase):
for d in range(m['month_days']):
dt = add_days(cstr(m['month_start_date']), d)
if dt not in holidays:
leave = sql("""
leave = webnotes.conn.sql("""
select t1.name, t1.half_day
from `tabLeave Application` t1, `tabLeave Type` t2
where t2.name = t1.leave_type
@@ -134,7 +133,7 @@ class DocType(TransactionBase):
return lwp
def check_existing(self):
ret_exist = sql("""select name from `tabSalary Slip`
ret_exist = webnotes.conn.sql("""select name from `tabSalary Slip`
where month = %s and fiscal_year = %s and docstatus != 2
and employee = %s and name != %s""",
(self.doc.month, self.doc.fiscal_year, self.doc.employee, self.doc.name))
@@ -201,9 +200,9 @@ class DocType(TransactionBase):
receiver = webnotes.conn.get_value("Employee", self.doc.employee, "company_email")
if receiver:
subj = 'Salary Slip - ' + cstr(self.doc.month) +'/'+cstr(self.doc.fiscal_year)
earn_ret=sql("""select e_type, e_modified_amount from `tabSalary Slip Earning`
earn_ret=webnotes.conn.sql("""select e_type, e_modified_amount from `tabSalary Slip Earning`
where parent = %s""", self.doc.name)
ded_ret=sql("""select d_type, d_modified_amount from `tabSalary Slip Deduction`
ded_ret=webnotes.conn.sql("""select d_type, d_modified_amount from `tabSalary Slip Deduction`
where parent = %s""", self.doc.name)
earn_table = ''

View File

@@ -8,7 +8,6 @@ from webnotes.utils import cstr, flt
from webnotes.model.doc import addchild, make_autoname
from webnotes import msgprint, _
sql = webnotes.conn.sql
class DocType:
def __init__(self,doc,doclist=[]):
@@ -20,7 +19,7 @@ class DocType:
def get_employee_details(self):
ret = {}
det = sql("""select employee_name, branch, designation, department, grade
det = webnotes.conn.sql("""select employee_name, branch, designation, department, grade
from `tabEmployee` where name = %s""", self.doc.employee)
if det:
ret = {
@@ -34,7 +33,7 @@ class DocType:
return ret
def get_ss_values(self,employee):
basic_info = sql("""select bank_name, bank_ac_no, esic_card_no, pf_number
basic_info = webnotes.conn.sql("""select bank_name, bank_ac_no, esic_card_no, pf_number
from `tabEmployee` where name =%s""", employee)
ret = {'bank_name': basic_info and basic_info[0][0] or '',
'bank_ac_no': basic_info and basic_info[0][1] or '',
@@ -43,7 +42,7 @@ class DocType:
return ret
def make_table(self, doct_name, tab_fname, tab_name):
list1 = sql("select name from `tab%s` where docstatus != 2" % doct_name)
list1 = webnotes.conn.sql("select name from `tab%s` where docstatus != 2" % doct_name)
for li in list1:
child = addchild(self.doc, tab_fname, tab_name, self.doclist)
if(tab_fname == 'earning_details'):
@@ -58,7 +57,7 @@ class DocType:
self.make_table('Deduction Type','deduction_details', 'Salary Structure Deduction')
def check_existing(self):
ret = sql("""select name from `tabSalary Structure` where is_active = 'Yes'
ret = webnotes.conn.sql("""select name from `tabSalary Structure` where is_active = 'Yes'
and employee = %s and name!=%s""", (self.doc.employee,self.doc.name))
if ret and self.doc.is_active=='Yes':
msgprint(_("""Another Salary Structure '%s' is active for employee '%s'.

View File

@@ -9,7 +9,8 @@ from webnotes.utils import cstr, add_days, date_diff
from webnotes import msgprint, _
from webnotes.utils.datautils import UnicodeWriter
doclist = None
# doclist = None
doclist = webnotes.local('uploadattendance_doclist')
class DocType():
def __init__(self, doc, doclist=[]):
@@ -21,9 +22,8 @@ def get_template():
if not webnotes.has_permission("Attendance", "create"):
raise webnotes.PermissionError
args = webnotes.form_dict
global doclist
doclist = webnotes.model.doctype.get("Attendance")
args = webnotes.local.form_dict
webnotes.local.uploadattendance_doclist = webnotes.model.doctype.get("Attendance")
w = UnicodeWriter()
w = add_header(w)
@@ -144,4 +144,4 @@ def upload():
webnotes.conn.rollback()
else:
webnotes.conn.commit()
return {"messages": ret, "error": error}
return {"messages": ret, "error": error}