From 45a3226645ff9b568c013457b9dcab9ae5adbbf5 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 5 May 2014 10:34:19 +0530 Subject: [PATCH 1/2] minor --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 220929fd440..8ad696ea409 100644 --- a/README.md +++ b/README.md @@ -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: From 648062d071619d3c570e8e40a2664ef8c412568d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 5 May 2014 16:46:14 +0530 Subject: [PATCH 2/2] Fixes in test cases --- erpnext/hooks.py | 3 +++ erpnext/hr/doctype/employee/employee.py | 12 ++++++++++-- .../test_leave_application.py | 18 +++++++++++++++++- .../time_log_batch/test_time_log_batch.py | 4 ++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 4dcfdb0d326..a488b31a5f0 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -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" } } diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py index abda8aeae3e..6846b87bfce 100644 --- a/erpnext/hr/doctype/employee/employee.py +++ b/erpnext/hr/doctype/employee/employee.py @@ -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 diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index fdd8bfee58f..f6faf524219 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -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") diff --git a/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py b/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py index a849ba74cb1..dceaee78ff5 100644 --- a/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py +++ b/erpnext/projects/doctype/time_log_batch/test_time_log_batch.py @@ -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)