fix conflict
This commit is contained in:
commit
dbdf462e56
@ -131,7 +131,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
email_prompt: function() {
|
||||
var me = this;
|
||||
var fields = [{label:__("To"), fieldtype:"Data", reqd: 0, fieldname:"recipients",length:524288},
|
||||
{fieldtype: "Section Break", collapsible: 1, label: "CC & Standard Reply"},
|
||||
{fieldtype: "Section Break", collapsible: 1, label: "CC & Email Template"},
|
||||
{fieldtype: "Section Break"},
|
||||
{label:__("Subject"), fieldtype:"Data", reqd: 1,
|
||||
fieldname:"subject",length:524288},
|
||||
|
@ -22,7 +22,7 @@ frappe.ui.form.on("Request for Quotation",{
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
frm.add_fetch('standard_reply', 'response', 'message_for_supplier');
|
||||
frm.add_fetch('email_template', 'response', 'message_for_supplier');
|
||||
|
||||
if(!frm.doc.message_for_supplier) {
|
||||
frm.set_value("message_for_supplier", __("Please supply the specified items at the best possible rates"))
|
||||
|
@ -43,6 +43,7 @@
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 1,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -77,6 +78,7 @@
|
||||
"reqd": 1,
|
||||
"search_index": 1,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -109,6 +111,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -140,6 +143,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
@ -173,6 +177,7 @@
|
||||
"reqd": 1,
|
||||
"search_index": 1,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -203,6 +208,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -234,6 +240,7 @@
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -264,6 +271,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -296,6 +304,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -329,6 +338,7 @@
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -360,6 +370,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -390,6 +401,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -398,7 +410,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "standard_reply",
|
||||
"fieldname": "email_template",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@ -407,10 +419,10 @@
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Standard Reply",
|
||||
"label": "Email Template",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Standard Reply",
|
||||
"options": "Email Template",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 1,
|
||||
@ -421,6 +433,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -451,6 +464,7 @@
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -484,6 +498,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -517,6 +532,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -549,6 +565,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -579,6 +596,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -612,6 +630,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -645,6 +664,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -677,6 +697,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -710,6 +731,7 @@
|
||||
"reqd": 1,
|
||||
"search_index": 1,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -743,6 +765,7 @@
|
||||
"reqd": 1,
|
||||
"search_index": 1,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -772,6 +795,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
@ -802,6 +826,7 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
@ -816,7 +841,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-10-17 17:27:06.281494",
|
||||
"modified": "2018-04-14 14:28:55.125996",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Request for Quotation",
|
||||
@ -825,7 +850,6 @@
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
@ -845,7 +869,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
@ -865,7 +888,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 0,
|
||||
@ -885,7 +907,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
@ -905,7 +926,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
@ -925,7 +945,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
|
@ -2,7 +2,22 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Department', {
|
||||
refresh: function(frm) {
|
||||
|
||||
onload: function(frm) {
|
||||
frm.set_query("leave_approver", "leave_approvers", function(doc) {
|
||||
return {
|
||||
query:"erpnext.hr.doctype.department_approver.department_approver.get_department_approvers",
|
||||
filters:{
|
||||
user: doc.user_id
|
||||
}
|
||||
};
|
||||
});
|
||||
frm.set_query("expense_approver", "expense_approvers", function(doc) {
|
||||
return {
|
||||
query:"erpnext.hr.doctype.department_approver.department_approver.get_department_approvers",
|
||||
filters:{
|
||||
user: doc.user_id
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -113,7 +113,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "section_break_5",
|
||||
"fieldname": "section_break_4",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
@ -169,6 +169,134 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "leave_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Leave Approvers",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "The first Leave Approver in the list will be set as the default Leave Approver.",
|
||||
"fieldname": "leave_approver",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Leave Approver",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Department Approver",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "expense_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Expense Approvers",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "The first Expense Approver in the list will be set as the default Expense Approver.",
|
||||
"fieldname": "expense_approver",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Expense Approver",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Department Approver",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
@ -274,7 +402,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-04-09 12:54:13.608107",
|
||||
"modified": "2018-04-16 16:46:02.759012",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Department",
|
||||
|
@ -1,63 +1,76 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"autoname": "hash",
|
||||
"beta": 0,
|
||||
"creation": "2013-04-12 06:56:15",
|
||||
"creation": "2018-04-08 16:31:02.433252",
|
||||
"custom": 0,
|
||||
"description": "Users who can approve a specific employee's leave applications",
|
||||
"description": "",
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "leave_approver",
|
||||
"columns": 0,
|
||||
"fieldname": "approver",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 1,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"label": "Leave Approver",
|
||||
"in_standard_filter": 0,
|
||||
"label": "Approver",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "User",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0,
|
||||
"width": "200"
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 1,
|
||||
"idx": 0,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"in_dialog": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-07-11 03:28:00.270787",
|
||||
"modified": "2018-04-17 11:05:46.294340",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Leave Approver",
|
||||
"name": "Department Approver",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"quick_entry": 0,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 0,
|
||||
"track_seen": 0
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
|
||||
class DepartmentApprover(Document):
|
||||
pass
|
||||
|
||||
def get_department_approvers(doctype, txt, searchfield, start, page_len, filters):
|
||||
return get_approver_list(filters.get("user"))
|
||||
|
||||
def get_approver_list(name):
|
||||
return frappe.db.sql("""select user.name, user.first_name, user.last_name from
|
||||
tabUser user where
|
||||
user.enabled and
|
||||
user.name != %s
|
||||
""", name or "")
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_approvers(doctype, txt, searchfield, start, page_len, filters):
|
||||
|
||||
if not filters.get("employee"):
|
||||
frappe.throw(_("Please select Employee Record first."))
|
||||
|
||||
approvers = []
|
||||
employee_department = filters.get("department") or frappe.get_value("Employee", filters.get("employee"), "department")
|
||||
if employee_department:
|
||||
department_details = frappe.db.get_value("Department", {"name": employee_department}, ["lft", "rgt"], as_dict=True)
|
||||
if department_details:
|
||||
department_list = frappe.db.sql("""select name from `tabDepartment` where lft <= %s
|
||||
and rgt >= %s
|
||||
order by lft desc""", (department_details.lft, department_details.rgt), as_list = True)
|
||||
|
||||
if filters.get("doctype") == "Leave Application":
|
||||
parentfield = "leave_approver"
|
||||
else:
|
||||
parentfield = "expense_approver"
|
||||
if department_list:
|
||||
for d in department_list:
|
||||
approvers += frappe.db.sql("""select user.name, user.first_name, user.last_name from
|
||||
tabUser user, `tabDepartment Approver` approver where
|
||||
approver.parent = %s
|
||||
and user.name like %s
|
||||
and approver.parentfield = %s
|
||||
and approver.approver=user.name""",(d, "%" + txt + "%", parentfield), as_list=True)
|
||||
|
||||
return approvers
|
@ -1198,38 +1198,6 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "The first Leave Approver in the list will be set as the default Leave Approver",
|
||||
"fieldname": "leave_approvers",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Leave Approvers",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Leave Approver",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
@ -2702,7 +2670,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-04-05 13:54:36.881449",
|
||||
"modified": "2018-04-16 09:08:06.852604",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee",
|
||||
|
@ -1 +0,0 @@
|
||||
User authorized to approve Leave Application for an Employee.
|
@ -1,24 +0,0 @@
|
||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
class EmployeeLeaveApprover(Document):
|
||||
pass
|
||||
|
||||
def get_approvers(doctype, txt, searchfield, start, page_len, filters):
|
||||
return get_approver_list(filters.get("user"))
|
||||
|
||||
|
||||
def get_approver_list(name):
|
||||
return frappe.db.sql("""select user.name, user.first_name, user.last_name from
|
||||
tabUser user, `tabHas Role` user_role where
|
||||
user_role.role = "Leave Approver"
|
||||
and user_role.parent = user.name and user.enabled and
|
||||
user.name != %s
|
||||
""", name or "")
|
@ -16,7 +16,6 @@ erpnext.hr.ExpenseClaimController = frappe.ui.form.Controller.extend({
|
||||
if(!d.expense_type) {
|
||||
return;
|
||||
}
|
||||
|
||||
return frappe.call({
|
||||
method: "erpnext.hr.doctype.expense_claim.expense_claim.get_expense_claim_account",
|
||||
args: {
|
||||
@ -156,6 +155,18 @@ frappe.ui.form.on("Expense Claim", {
|
||||
});
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
frm.set_query("expense_approver", function() {
|
||||
return {
|
||||
query: "erpnext.hr.doctype.department_approver.department_approver.get_approvers",
|
||||
filters: {
|
||||
employee: frm.doc.employee,
|
||||
doctype: frm.doc.doctype
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
frm.trigger("toggle_fields");
|
||||
|
||||
@ -176,6 +187,11 @@ frappe.ui.form.on("Expense Claim", {
|
||||
frm.add_custom_button(__('Payment'),
|
||||
function() { frm.events.make_payment_entry(frm); }, __("Make"));
|
||||
}
|
||||
frappe.db.get_value('HR Settings', {name: 'HR Settings'}, 'expense_approver_mandatory_in_expense_claim', (r) => {
|
||||
if (frm.doc.docstatus < 1 && (r.expense_approver_mandatory_in_expense_claim == 1)) {
|
||||
frm.toggle_reqd("expense_approver", true);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
make_payment_entry: function(frm) {
|
||||
|
@ -45,6 +45,168 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "employee",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "From Employee",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "employee",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Employee",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 1,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "employee_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Employee Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "employee_name",
|
||||
"oldfieldtype": "Data",
|
||||
"options": "employee.employee_name",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0,
|
||||
"width": "150px"
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "expense_approver",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Expense Approver",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "User",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_5",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Draft",
|
||||
"fieldname": "approval_status",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Approval Status",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"options": "Draft\nApproved\nRejected",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 1,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
@ -272,73 +434,6 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "employee",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "From Employee",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "employee",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Employee",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 1,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "employee_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Employee Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "employee_name",
|
||||
"oldfieldtype": "Data",
|
||||
"options": "employee.employee_name",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0,
|
||||
"width": "150px"
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
@ -990,7 +1085,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2018-03-21 16:44:02.518251",
|
||||
"modified": "2018-04-16 10:29:49.805051",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Expense Claim",
|
||||
@ -999,7 +1094,6 @@
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
@ -1019,7 +1113,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 1,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 0,
|
||||
@ -1040,7 +1133,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
@ -1061,7 +1153,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
|
@ -41,13 +41,14 @@ class ExpenseClaim(AccountsController):
|
||||
}[cstr(self.docstatus or 0)]
|
||||
|
||||
paid_amount = flt(self.total_amount_reimbursed) + flt(self.total_advance_amount)
|
||||
|
||||
if (self.is_paid or (flt(self.total_sanctioned_amount) > 0
|
||||
and flt(self.total_sanctioned_amount) == paid_amount)) \
|
||||
and self.docstatus == 1:
|
||||
and self.docstatus == 1 and self.approval_status == 'Approved':
|
||||
self.status = "Paid"
|
||||
elif flt(self.total_sanctioned_amount) > 0 and self.docstatus == 1:
|
||||
elif flt(self.total_sanctioned_amount) > 0 and self.docstatus == 1 and self.approval_status == 'Approved':
|
||||
self.status = "Unpaid"
|
||||
elif self.docstatus == 1 and self.approval_status == 'Rejected':
|
||||
self.status = 'Rejected'
|
||||
|
||||
def set_payable_account(self):
|
||||
if not self.payable_account and not self.is_paid:
|
||||
@ -58,6 +59,8 @@ class ExpenseClaim(AccountsController):
|
||||
self.cost_center = frappe.db.get_value('Company', self.company, 'cost_center')
|
||||
|
||||
def on_submit(self):
|
||||
if self.approval_status=="Draft":
|
||||
frappe.throw(_("""Approval Status must be 'Approved' or 'Rejected'"""))
|
||||
|
||||
self.update_task_and_project()
|
||||
self.make_gl_entries()
|
||||
@ -183,6 +186,9 @@ class ExpenseClaim(AccountsController):
|
||||
self.total_claimed_amount = 0
|
||||
self.total_sanctioned_amount = 0
|
||||
for d in self.get('expenses'):
|
||||
if self.approval_status == 'Rejected':
|
||||
d.sanctioned_amount = 0.0
|
||||
|
||||
self.total_claimed_amount += flt(d.claim_amount)
|
||||
self.total_sanctioned_amount += flt(d.sanctioned_amount)
|
||||
|
||||
@ -277,7 +283,6 @@ def make_bank_entry(dt, dn):
|
||||
def get_expense_claim_account(expense_claim_type, company):
|
||||
account = frappe.db.get_value("Expense Claim Account",
|
||||
{"parent": expense_claim_type, "company": company}, "default_account")
|
||||
|
||||
if not account:
|
||||
frappe.throw(_("Please set default account in Expense Claim Type {0}")
|
||||
.format(expense_claim_type))
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"beta": 0,
|
||||
@ -11,6 +12,7 @@
|
||||
"editable_grid": 1,
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -21,6 +23,7 @@
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Employee Settings",
|
||||
@ -35,9 +38,11 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -50,6 +55,7 @@
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Retirement Age",
|
||||
@ -65,9 +71,11 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -80,6 +88,7 @@
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Employee Records to be created by",
|
||||
@ -95,9 +104,76 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "",
|
||||
"fieldname": "leave_approval_notification_template",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Leave Approval Notification Template",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Email Template",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "leave_status_notification_template",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Leave Status Notification Template",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Email Template",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -108,6 +184,7 @@
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
@ -122,9 +199,11 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -136,6 +215,7 @@
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Stop Birthday Reminders",
|
||||
@ -150,9 +230,11 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -163,6 +245,7 @@
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Maintain Billing Hours and Working Hours Same on Timesheet",
|
||||
@ -178,9 +261,75 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "1",
|
||||
"fieldname": "leave_approver_mandatory_in_leave_application",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Leave Approver Mandatory In Leave Application",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "1",
|
||||
"fieldname": "expense_approver_mandatory_in_expense_claim",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Expense Approver Mandatory In Expense Claim",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -191,6 +340,7 @@
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Payroll Settings",
|
||||
@ -205,9 +355,11 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -219,6 +371,7 @@
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Include holidays in Total no. of Working Days",
|
||||
@ -233,9 +386,11 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -248,6 +403,7 @@
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Email Salary Slip to Employee",
|
||||
@ -263,9 +419,11 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
@ -276,6 +434,7 @@
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Max working hours against Timesheet",
|
||||
@ -291,29 +450,29 @@
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"icon": "fa fa-cog",
|
||||
"idx": 1,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"in_dialog": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 1,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-01-16 14:01:31.183485",
|
||||
"modified_by": "anastasiadis.st00@gmail.com",
|
||||
"modified": "2018-04-14 17:09:15.904645",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "HR Settings",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 0,
|
||||
@ -321,7 +480,6 @@
|
||||
"export": 0,
|
||||
"if_owner": 0,
|
||||
"import": 0,
|
||||
"is_custom": 0,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
@ -336,6 +494,7 @@
|
||||
"quick_entry": 0,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_order": "ASC",
|
||||
"track_changes": 0,
|
||||
"track_seen": 0
|
||||
|
23
erpnext/hr/doctype/hr_settings/test_hr_settings.js
Normal file
23
erpnext/hr/doctype/hr_settings/test_hr_settings.js
Normal file
@ -0,0 +1,23 @@
|
||||
/* eslint-disable */
|
||||
// rename this file from _test_[name] to test_[name] to activate
|
||||
// and remove above this line
|
||||
|
||||
QUnit.test("test: HR Settings", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new HR Settings
|
||||
() => frappe.tests.make('HR Settings', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
]),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.key, 'value');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
||||
});
|
9
erpnext/hr/doctype/hr_settings/test_hr_settings.py
Normal file
9
erpnext/hr/doctype/hr_settings/test_hr_settings.py
Normal file
@ -0,0 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import unittest
|
||||
|
||||
class TestHRSettings(unittest.TestCase):
|
||||
pass
|
@ -10,8 +10,17 @@ frappe.ui.form.on("Leave Application", {
|
||||
frm.set_value("posting_date", frappe.datetime.get_today());
|
||||
}
|
||||
|
||||
frm.set_query("employee", erpnext.queries.employee);
|
||||
frm.set_query("leave_approver", function() {
|
||||
return {
|
||||
query: "erpnext.hr.doctype.department_approver.department_approver.get_approvers",
|
||||
filters: {
|
||||
employee: frm.doc.employee,
|
||||
doctype: frm.doc.doctype
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("employee", erpnext.queries.employee);
|
||||
},
|
||||
|
||||
validate: function(frm) {
|
||||
@ -26,12 +35,23 @@ frappe.ui.form.on("Leave Application", {
|
||||
if(frm.doc.__islocal && !in_list(frappe.user_roles, "Employee")) {
|
||||
frm.set_intro(__("Fill the form and save it"));
|
||||
}
|
||||
frappe.db.get_value('HR Settings', {name: 'HR Settings'}, 'leave_approver_mandatory_in_leave_application', (r) => {
|
||||
if (frm.doc.docstatus < 1 && (r.leave_approver_mandatory_in_leave_application == 1)) {
|
||||
frm.toggle_reqd("leave_approver", true);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
employee: function(frm) {
|
||||
frm.trigger("get_leave_balance");
|
||||
},
|
||||
|
||||
leave_approver: function(frm) {
|
||||
if(frm.doc.leave_approver){
|
||||
frm.set_value("leave_approver_name", frappe.user.full_name(frm.doc.leave_approver));
|
||||
}
|
||||
},
|
||||
|
||||
leave_type: function(frm) {
|
||||
frm.trigger("get_leave_balance");
|
||||
},
|
||||
|
@ -45,6 +45,97 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "employee",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Employee",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 1,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "employee_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Employee Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_4",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
@ -386,27 +477,28 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "employee",
|
||||
"fieldname": "leave_approver",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Employee",
|
||||
"in_standard_filter": 0,
|
||||
"label": "Leave Approver",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee",
|
||||
"options": "User",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 1,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
@ -417,19 +509,20 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "employee_name",
|
||||
"fieldname": "leave_approver_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Employee Name",
|
||||
"label": "Leave Approver Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
@ -441,6 +534,69 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_18",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Open",
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Status",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
"options": "Open\nApproved\nRejected\nCancelled",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
@ -667,7 +823,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 3,
|
||||
"modified": "2018-03-04 18:24:04.863555",
|
||||
"modified": "2018-04-16 09:46:44.650629",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Leave Application",
|
||||
@ -675,7 +831,6 @@
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 0,
|
||||
@ -696,7 +851,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
@ -716,7 +870,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
@ -736,7 +889,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
@ -757,7 +909,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 0,
|
||||
"delete": 1,
|
||||
@ -778,7 +929,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
@ -798,7 +948,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"delete": 0,
|
||||
|
@ -34,13 +34,26 @@ class LeaveApplication(Document):
|
||||
self.validate_salary_processed_days()
|
||||
self.validate_attendance()
|
||||
|
||||
if hasattr(self, "workflow_state") and self.workflow_state == "Rejected":
|
||||
# notify leave applier about rejection
|
||||
self.notify_employee()
|
||||
def on_update(self):
|
||||
if self.status == "Open" and self.docstatus < 1:
|
||||
# notify leave approver about creation
|
||||
self.notify_leave_approver()
|
||||
|
||||
def on_submit(self):
|
||||
if self.status == "Open":
|
||||
frappe.throw(_("Only Leave Applications with status 'Approved' and 'Rejected' can be submitted"))
|
||||
|
||||
self.validate_back_dated_application()
|
||||
|
||||
# notify leave applier about approval
|
||||
self.notify_employee()
|
||||
self.reload()
|
||||
|
||||
def on_cancel(self):
|
||||
self.status = "Cancelled"
|
||||
# notify leave applier about cancellation
|
||||
self.notify_employee()
|
||||
|
||||
def validate_dates(self):
|
||||
if self.from_date and self.to_date and (getdate(self.to_date) < getdate(self.from_date)):
|
||||
frappe.throw(_("To date cannot be before from date"))
|
||||
@ -110,7 +123,7 @@ class LeaveApplication(Document):
|
||||
block_dates = get_applicable_block_dates(self.from_date, self.to_date,
|
||||
self.employee, self.company)
|
||||
|
||||
if block_dates and self.docstatus == 1:
|
||||
if block_dates and self.status == "Approved":
|
||||
frappe.throw(_("You are not authorized to approve leaves on Block Dates"), LeaveDayBlockedError)
|
||||
|
||||
def validate_balance_leaves(self):
|
||||
@ -125,7 +138,7 @@ class LeaveApplication(Document):
|
||||
self.leave_balance = get_leave_balance_on(self.employee, self.leave_type, self.from_date,
|
||||
consider_all_leaves_in_the_allocation_period=True)
|
||||
|
||||
if self.leave_balance < self.total_leave_days:
|
||||
if self.status != "Rejected" and self.leave_balance < self.total_leave_days:
|
||||
if frappe.db.get_value("Leave Type", self.leave_type, "allow_negative"):
|
||||
frappe.msgprint(_("Note: There is not enough leave balance for Leave Type {0}")
|
||||
.format(self.leave_type))
|
||||
@ -142,7 +155,7 @@ class LeaveApplication(Document):
|
||||
select
|
||||
name, leave_type, posting_date, from_date, to_date, total_leave_days, half_day_date
|
||||
from `tabLeave Application`
|
||||
where employee = %(employee)s and docstatus < 2
|
||||
where employee = %(employee)s and docstatus < 2 and status in ("Open", "Approved")
|
||||
and to_date >= %(from_date)s and from_date <= %(to_date)s
|
||||
and name != %(name)s""", {
|
||||
"employee": self.employee,
|
||||
@ -172,6 +185,7 @@ class LeaveApplication(Document):
|
||||
leave_count_on_half_day_date = frappe.db.sql("""select count(name) from `tabLeave Application`
|
||||
where employee = %(employee)s
|
||||
and docstatus < 2
|
||||
and status in ("Open", "Approved")
|
||||
and half_day = 1
|
||||
and half_day_date = %(half_day_date)s
|
||||
and name != %(name)s""", {
|
||||
@ -200,84 +214,67 @@ class LeaveApplication(Document):
|
||||
if not employee.user_id:
|
||||
return
|
||||
|
||||
def _get_message(url=False):
|
||||
if url:
|
||||
name = get_link_to_form(self.doctype, self.name)
|
||||
else:
|
||||
name = self.name
|
||||
parent_doc = frappe.get_doc('Leave Application', self.name)
|
||||
args = parent_doc.as_dict()
|
||||
|
||||
message = "Leave Application: {name}".format(name=name)+"<br>"
|
||||
message += "Leave Type: {leave_type}".format(leave_type=self.leave_type)+"<br>"
|
||||
message += "From Date: {from_date}".format(from_date=self.from_date)+"<br>"
|
||||
message += "To Date: {to_date}".format(to_date=self.to_date)+"<br>"
|
||||
return message
|
||||
template = frappe.db.get_single_value('HR Settings', 'leave_status_notification_template')
|
||||
if not template:
|
||||
frappe.msgprint(_("Please set default template for Leave Status Notification in HR Settings."))
|
||||
return
|
||||
email_template = frappe.get_doc("Email Template", template)
|
||||
message = frappe.render_template(email_template.response, args)
|
||||
|
||||
self.notify({
|
||||
# for post in messages
|
||||
"message": _get_message(url=True),
|
||||
"message": message,
|
||||
"message_to": employee.user_id,
|
||||
"subject": (_("Leave Application") + ": %s - %s") % (self.name,
|
||||
self.workflow_state if hasattr(self, "workflow_state") else "")
|
||||
# for email
|
||||
"subject": email_template.subject,
|
||||
"notify": "employee"
|
||||
})
|
||||
|
||||
def _get_message(url=False):
|
||||
name = self.name
|
||||
employee_name = cstr(employee.employee_name)
|
||||
if url:
|
||||
name = get_link_to_form(self.doctype, self.name)
|
||||
employee_name = get_link_to_form("Employee", self.employee, label=employee_name)
|
||||
message = (_("Leave Application") + ": %s") % (name)+"<br>"
|
||||
message += (_("Employee") + ": %s") % (employee_name)+"<br>"
|
||||
message += (_("Leave Type") + ": %s") % (self.leave_type)+"<br>"
|
||||
message += (_("From Date") + ": %s") % (self.from_date)+"<br>"
|
||||
message += (_("To Date") + ": %s") % (self.to_date)
|
||||
return message
|
||||
def notify_leave_approver(self):
|
||||
|
||||
parent_doc = frappe.get_doc('Leave Application', self.name)
|
||||
args = parent_doc.as_dict()
|
||||
|
||||
template = frappe.db.get_single_value('HR Settings', 'leave_approval_notification_template')
|
||||
if not template:
|
||||
frappe.msgprint(_("Please set default template for Leave Approval Notification in HR Settings."))
|
||||
return
|
||||
email_template = frappe.get_doc("Email Template", template)
|
||||
message = frappe.render_template(email_template.response, args)
|
||||
|
||||
self.notify({
|
||||
# for post in messages
|
||||
"message": _get_message(url=True),
|
||||
|
||||
"message": message,
|
||||
"message_to": self.leave_approver,
|
||||
# for email
|
||||
"subject": (_("New Leave Application") + ": %s - " + _("Employee") + ": %s") % (self.name, cstr(employee.employee_name))
|
||||
"subject": email_template.subject
|
||||
})
|
||||
|
||||
def notify(self, args):
|
||||
args = frappe._dict(args)
|
||||
# args -> message, message_to, subject
|
||||
|
||||
d = frappe.new_doc('Communication')
|
||||
d.communication_type = 'Notification'
|
||||
d.subject = args.subject
|
||||
d.content = args.message
|
||||
d.reference_doctype = 'User'
|
||||
d.reference_name = args.message_to
|
||||
d.sender = frappe.session.user
|
||||
|
||||
d.insert(ignore_permissions = True)
|
||||
|
||||
if cint(self.follow_via_email):
|
||||
contact = args.message_to
|
||||
if not isinstance(contact, list):
|
||||
contact = [frappe.get_doc('User', contact).email or contact]
|
||||
if not args.notify == "employee":
|
||||
contact = frappe.get_doc('User', contact).email or contact
|
||||
|
||||
sender = dict()
|
||||
sender['email'] = frappe.get_doc('User', frappe.session.user).email
|
||||
sender['full_name'] = frappe.utils.get_fullname(sender['email'])
|
||||
|
||||
try:
|
||||
frappe.sendmail(recipients = contact,
|
||||
frappe.sendmail(
|
||||
recipients = contact,
|
||||
sender = sender['email'],
|
||||
subject = args.subject or _("New Message from {sender}").format(sender = sender['full_name']),
|
||||
template = "new_message",
|
||||
args = {
|
||||
"from": sender['full_name'],
|
||||
"message": args.message,
|
||||
"link": frappe.utils.get_url()
|
||||
},
|
||||
header = [_('New Message'), 'orange']
|
||||
subject = args.subject,
|
||||
message = args.message,
|
||||
)
|
||||
frappe.msgprint(_("Email sent to {0}").format(contact))
|
||||
except frappe.OutgoingEmailError:
|
||||
# Arrey!
|
||||
pass
|
||||
|
||||
@frappe.whitelist()
|
||||
|
@ -0,0 +1,25 @@
|
||||
<h1>Leave Application Notification</h1>
|
||||
<h3>Details:</h3>
|
||||
|
||||
<table class="table table-bordered small" style="max-width: 500px;">
|
||||
<tr>
|
||||
<td>Employee</td>
|
||||
<td>{{employee_name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Leave Type</td>
|
||||
<td>{{leave_type}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>From Date</td>
|
||||
<td>{{from_date}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>To Date</td>
|
||||
<td>{{to_date}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Status</td>
|
||||
<td>{{status}}</td>
|
||||
</tr>
|
||||
</table>
|
@ -518,5 +518,8 @@ erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
|
||||
erpnext.patches.v11_0.add_index_on_nestedset_doctypes
|
||||
erpnext.patches.v11_0.remove_modules_setup_page
|
||||
erpnext.patches.v11_0.update_department_lft_rgt
|
||||
erpnext.patches.v11_0.move_leave_approvers_from_employee
|
||||
erpnext.patches.v11_0.add_default_email_template_for_leave
|
||||
erpnext.patches.v11_0.set_default_email_template_in_hr
|
||||
erpnext.patches.v10_1.transfer_subscription_to_auto_repeat
|
||||
erpnext.patches.v10_1.drop_old_subscription_records
|
||||
|
@ -0,0 +1,29 @@
|
||||
import frappe, os
|
||||
from frappe import _
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("setup", "doctype", "email_template")
|
||||
|
||||
if not frappe.db.exists("Email Template", _('Leave Approval Notification')):
|
||||
base_path = frappe.get_app_path("erpnext", "hr", "doctype")
|
||||
response = frappe.read_file(os.path.join(base_path, "leave_application/leave_application_email_template.html"))
|
||||
frappe.get_doc({
|
||||
'doctype': 'Email Template',
|
||||
'name': _("Leave Approval Notification"),
|
||||
'response': response,
|
||||
'subject': _("Leave Approval Notification"),
|
||||
'owner': frappe.session.user,
|
||||
}).insert(ignore_permissions=True)
|
||||
|
||||
|
||||
if not frappe.db.exists("Email Template", _('Leave Status Notification')):
|
||||
base_path = frappe.get_app_path("erpnext", "hr", "doctype")
|
||||
response = frappe.read_file(os.path.join(base_path, "leave_application/leave_application_email_template.html"))
|
||||
frappe.get_doc({
|
||||
'doctype': 'Email Template',
|
||||
'name': _("Leave Status Notification"),
|
||||
'response': response,
|
||||
'subject': _("Leave Status Notification"),
|
||||
'owner': frappe.session.user,
|
||||
}).insert(ignore_permissions=True)
|
||||
|
18
erpnext/patches/v11_0/move_leave_approvers_from_employee.py
Normal file
18
erpnext/patches/v11_0/move_leave_approvers_from_employee.py
Normal file
@ -0,0 +1,18 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("hr", "doctype", "employee")
|
||||
frappe.reload_doc("hr", "doctype", "department")
|
||||
frappe.reload_doc("hr", "doctype", "employee_leave_approver")
|
||||
|
||||
approvers = frappe.db.sql("""select distinct app.leave_approver, emp.department from
|
||||
`tabEmployee Leave Approver` app, `tabEmployee` emp
|
||||
where app.parenttype = 'Employee'
|
||||
and emp.name = app.parent
|
||||
""", as_dict=True)
|
||||
for record in approvers:
|
||||
if record.department:
|
||||
frappe.db.sql("""update `tabDepartment Approver` app set app.parenttype = '{0}',
|
||||
app.parent = '{1}' and parentfield = 'leave_approver' where app.leave_approver = '{2}'"""
|
||||
.format(_('Department'), record.department, record.leave_approver))
|
@ -0,0 +1,8 @@
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
|
||||
hr_settings = frappe.get_doc("HR Settings")
|
||||
hr_settings.leave_approval_notification_template = "Leave Approval Notification"
|
||||
hr_settings.leave_status_notification_template = "Leave Status Notification"
|
||||
hr_settings.save()
|
@ -118,7 +118,7 @@
|
||||
"label": "Terms and Conditions Help",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "<h4>Standard Terms and Conditions Example</h4>\n\n<pre>Delivery Terms for Order number {{ name }}\n\n-Order Date : {{ transaction_date }} \n-Expected Delivery Date : {{ delivery_date }}\n</pre>\n\n<h4>How to get fieldnames</h4>\n\n<p>The fieldnames you can use in your standard reply are the fields in the document from which you are sending the email. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)</p>\n\n<h4>Templating</h4>\n\n<p>Templates are compiled using the Jinja Templating Langauge. To learn more about Jinja, <a class=\"strong\" href=\"http://jinja.pocoo.org/docs/dev/templates/\">read this documentation.</a></p>",
|
||||
"options": "<h4>Standard Terms and Conditions Example</h4>\n\n<pre>Delivery Terms for Order number {{ name }}\n\n-Order Date : {{ transaction_date }} \n-Expected Delivery Date : {{ delivery_date }}\n</pre>\n\n<h4>How to get fieldnames</h4>\n\n<p>The fieldnames you can use in your email template are the fields in the document from which you are sending the email. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)</p>\n\n<h4>Templating</h4>\n\n<p>Templates are compiled using the Jinja Templating Langauge. To learn more about Jinja, <a class=\"strong\" href=\"http://jinja.pocoo.org/docs/dev/templates/\">read this documentation.</a></p>",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
|
@ -61,6 +61,8 @@ def set_default_settings(args):
|
||||
|
||||
hr_settings = frappe.get_doc("HR Settings")
|
||||
hr_settings.emp_created_by = "Naming Series"
|
||||
hr_settings.leave_approval_notification_template = "Leave Approval Notification"
|
||||
hr_settings.leave_status_notification_template = "Leave Status Notification"
|
||||
hr_settings.save()
|
||||
|
||||
def set_no_copy_fields_in_variant_settings():
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import frappe, os
|
||||
|
||||
from frappe import _
|
||||
|
||||
@ -262,6 +262,15 @@ def install(country=None):
|
||||
|
||||
records += [{'doctype': 'Lead Source', 'source_name': _(d)} for d in default_lead_sources]
|
||||
|
||||
base_path = frappe.get_app_path("erpnext", "hr", "doctype")
|
||||
response = frappe.read_file(os.path.join(base_path, "leave_application/leave_application_email_template.html"))
|
||||
|
||||
records += {'doctype': 'Email Template', 'name': _("Leave Approval Notification"), 'response': response,\
|
||||
'subject': _("Leave Approval Notification"), 'owner': frappe.session.user}
|
||||
|
||||
records += {'doctype': 'Email Template', 'name': _("Leave Status Notification"), 'response': response,\
|
||||
'subject': _("Leave Status Notification"), 'owner': frappe.session.user}
|
||||
|
||||
# Records for the Supplier Scorecard
|
||||
from erpnext.buying.doctype.supplier_scorecard.supplier_scorecard import make_default_records
|
||||
make_default_records()
|
||||
|
@ -500,7 +500,7 @@
|
||||
"label": "Delivery Notification",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Standard Reply",
|
||||
"options": "Email Template",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
@ -556,7 +556,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-02-22 17:36:05.521302",
|
||||
"modified": "2018-04-14 14:24:16.773657",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Delivery Trip",
|
||||
@ -565,7 +565,6 @@
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
@ -585,7 +584,6 @@
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
|
@ -165,7 +165,7 @@ def notify_customers(docname, date, driver, vehicle, sender_email, delivery_noti
|
||||
sender_designation = frappe.db.get_value("Employee", sender_email, ["designation"])
|
||||
|
||||
estimated_arrival = cstr(delivery_stop.estimated_arrival)[:-3]
|
||||
email_template = frappe.get_doc("Standard Reply", delivery_notification)
|
||||
email_template = frappe.get_doc("Email Template", delivery_notification)
|
||||
message = frappe.render_template(email_template.response, args)
|
||||
|
||||
frappe.sendmail(
|
||||
|
@ -49,9 +49,9 @@ def create_driver():
|
||||
driver.insert()
|
||||
|
||||
def create_delivery_notfication():
|
||||
if not frappe.db.exists("Standard Reply", "Delivery Notification"):
|
||||
if not frappe.db.exists("Email Template", "Delivery Notification"):
|
||||
frappe.get_doc({
|
||||
'doctype': 'Standard Reply',
|
||||
'doctype': 'Email Template',
|
||||
'name': 'Delivery Notification',
|
||||
'response': 'Test Delivery Trip',
|
||||
'subject': 'Test Subject',
|
||||
|
Loading…
x
Reference in New Issue
Block a user