Merge branch 'develop' of github.com:frappe/erpnext into develop

This commit is contained in:
Nabin Hait 2014-05-05 18:27:31 +05:30
commit ac1bc212ea
5 changed files with 37 additions and 6 deletions

View File

@ -27,7 +27,7 @@ Use the bench, https://github.com/frappe/frappe-bench.
##### Virtual Image:
- [ERPNext Download](http://erpnext.com/erpnext-download)
- [ERPNext Download](http://erpnext.com/download)
---
@ -35,7 +35,7 @@ Use the bench, https://github.com/frappe/frappe-bench.
GNU/General Public License (see LICENSE.txt)
The ERPNext code is licensed as GNU General Public License (v3) and the Documentation is licensed as Creative Commons (CC-BY-SA-3.0) and the copyright is owned by Web Notes Technologies Pvt Ltd (Web Notes) and Contributors.
The ERPNext code is licensed as GNU General Public License (v3) and the Documentation is licensed as Creative Commons (CC-BY-SA-3.0) and the copyright is owned by Web Notes Technologies Pvt Ltd (Web Notes) and Contributors.
---
@ -60,7 +60,7 @@ We will grant permission to use the ERPNext name and logo for projects that meet
- The primary purpose of your project is to promote the spread and improvement of the ERPNext software.
- Your project is non-commercial in nature (it can make money to cover its costs or contribute to non-profit entities, but it cannot be run as a for-profit project or business).
Your project neither promotes nor is associated with entities that currently fail to comply with the GPL license under which ERPNext is distributed.
- If your project meets these criteria, you will be permitted to use the ERPNext name and logo to promote your project in any way you see fit with one exception: Please do not use ERPNext as part of a domain name.
- If your project meets these criteria, you will be permitted to use the ERPNext name and logo to promote your project in any way you see fit with one exception: Please do not use ERPNext as part of a domain name.
Use of the ERPNext name and logo is additionally allowed in the following situations:

View File

@ -45,6 +45,9 @@ doc_events = {
"Stock Entry": {
"on_submit": "erpnext.stock.doctype.material_request.material_request.update_completed_qty",
"on_cancel": "erpnext.stock.doctype.material_request.material_request.update_completed_qty"
},
"User": {
"on_update": "erpnext.hr.doctype.employee.employee.update_user_default"
}
}

View File

@ -52,8 +52,7 @@ class Employee(Document):
self.validate_duplicate_user_id()
def on_update(self):
if self.user_id and frappe.db.get_value("User", self.user_id, 'docstatus') == 0:
self.restrict_user()
if self.user_id:
self.update_user_default()
self.update_user()
@ -65,6 +64,7 @@ class Employee(Document):
self.add_restriction_if_required("Employee", self.user_id)
def update_user_default(self):
self.restrict_user()
frappe.db.set_default("employee_name", self.employee_name, self.user_id)
frappe.db.set_default("company", self.company, self.user_id)
@ -228,3 +228,11 @@ def make_salary_structure(source_name, target=None):
})
target.make_earn_ded_table()
return target
def update_user_default(doc, method):
# called via User hook
try:
employee = frappe.get_doc("Employee", {"user_id": doc.name})
employee.update_user_default()
except frappe.DoesNotExistError:
pass

View File

@ -5,6 +5,7 @@ import frappe
import unittest
from erpnext.hr.doctype.leave_application.leave_application import LeaveDayBlockedError, OverlapError
from frappe.core.page.user_properties.user_properties import clear_restrictions
test_dependencies = ["Leave Allocation", "Leave Block List"]
@ -67,6 +68,18 @@ class TestLeaveApplication(unittest.TestCase):
employee.save()
frappe.set_user(temp_session_user)
def _remove_employee_leave_approver(self, employee, leave_approver):
temp_session_user = frappe.session.user
frappe.set_user("Administrator")
employee = frappe.get_doc("Employee", employee)
d = employee.get("employee_leave_approvers", {
"leave_approver": leave_approver
})
if d:
employee.get("employee_leave_approvers").remove(d[0])
employee.save()
frappe.set_user(temp_session_user)
def get_application(self, doc):
application = frappe.copy_doc(doc)
application.from_date = "2013-01-01"
@ -78,6 +91,7 @@ class TestLeaveApplication(unittest.TestCase):
from frappe.utils.user import add_role
add_role("test1@example.com", "HR User")
clear_restrictions("Employee")
frappe.db.set_value("Department", "_Test Department",
"leave_block_list", "_Test Leave Block List")
@ -154,6 +168,8 @@ class TestLeaveApplication(unittest.TestCase):
def _test_leave_approval_basic_case(self):
self._clear_applications()
self._add_employee_leave_approver("_T-Employee-0001", "test1@example.com")
# create leave application as Employee
frappe.set_user("test@example.com")
application = self.get_application(_test_records[0])
@ -175,8 +191,8 @@ class TestLeaveApplication(unittest.TestCase):
# add a different leave approver in the employee's list
# should raise exception if not a valid leave approver
self._add_employee_leave_approver("_T-Employee-0001", "test2@example.com")
self._remove_employee_leave_approver("_T-Employee-0001", "test1@example.com")
# TODO - add test2@example.com leave approver in employee's leave approvers list
application = self.get_application(_test_records[0])
frappe.set_user("test@example.com")

View File

@ -5,6 +5,10 @@ import frappe, unittest
class TimeLogBatchTest(unittest.TestCase):
def setUp(self):
for name in frappe.db.sql_list("select name from `tabTime Log Batch` where docstatus=1"):
frappe.get_doc("Time Log Batch", name).cancel()
frappe.delete_doc("Time Log Batch", name)
for name in frappe.db.sql_list("select name from `tabTime Log` where docstatus=1"):
frappe.get_doc("Time Log", name).cancel()
frappe.delete_doc("Time Log", name)