Set Employee Name if missing
This commit is contained in:
@@ -9,12 +9,14 @@ from frappe.utils import flt, getdate
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from erpnext.hr.utils import set_employee_name
|
||||||
|
|
||||||
class Appraisal(Document):
|
class Appraisal(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not self.status:
|
if not self.status:
|
||||||
self.status = "Draft"
|
self.status = "Draft"
|
||||||
|
|
||||||
|
set_employee_name(self)
|
||||||
self.validate_dates()
|
self.validate_dates()
|
||||||
self.validate_existing_appraisal()
|
self.validate_existing_appraisal()
|
||||||
self.calculate_total()
|
self.calculate_total()
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import frappe
|
|||||||
from frappe.utils import getdate, nowdate
|
from frappe.utils import getdate, nowdate
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from erpnext.hr.utils import set_employee_name
|
||||||
|
|
||||||
class Attendance(Document):
|
class Attendance(Document):
|
||||||
def validate_duplicate_record(self):
|
def validate_duplicate_record(self):
|
||||||
@@ -16,6 +17,8 @@ class Attendance(Document):
|
|||||||
if res:
|
if res:
|
||||||
frappe.throw(_("Attendance for employee {0} is already marked").format(self.employee))
|
frappe.throw(_("Attendance for employee {0} is already marked").format(self.employee))
|
||||||
|
|
||||||
|
set_employee_name(self)
|
||||||
|
|
||||||
def check_leave_record(self):
|
def check_leave_record(self):
|
||||||
if self.status == 'Present':
|
if self.status == 'Present':
|
||||||
leave = frappe.db.sql("""select name from `tabLeave Application`
|
leave = frappe.db.sql("""select name from `tabLeave Application`
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from erpnext.hr.utils import set_employee_name
|
||||||
|
|
||||||
class ExpenseClaim(Document):
|
class ExpenseClaim(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_fiscal_year()
|
self.validate_fiscal_year()
|
||||||
self.validate_exp_details()
|
self.validate_exp_details()
|
||||||
|
set_employee_name(self)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
if self.approval_status=="Draft":
|
if self.approval_status=="Draft":
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cint, flt
|
from frappe.utils import cint, flt
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from erpnext.hr.utils import set_employee_name
|
||||||
|
|
||||||
class LeaveAllocation(Document):
|
class LeaveAllocation(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@@ -15,6 +15,8 @@ class LeaveAllocation(Document):
|
|||||||
if not self.total_leaves_allocated:
|
if not self.total_leaves_allocated:
|
||||||
self.total_leaves_allocated = self.new_leaves_allocated
|
self.total_leaves_allocated = self.new_leaves_allocated
|
||||||
|
|
||||||
|
set_employee_name(self)
|
||||||
|
|
||||||
def on_update_after_submit(self):
|
def on_update_after_submit(self):
|
||||||
self.validate_new_leaves_allocated_value()
|
self.validate_new_leaves_allocated_value()
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from frappe import _
|
|||||||
from frappe.utils import cint, cstr, date_diff, flt, formatdate, getdate, get_url_to_form, \
|
from frappe.utils import cint, cstr, date_diff, flt, formatdate, getdate, get_url_to_form, \
|
||||||
comma_or, get_fullname
|
comma_or, get_fullname
|
||||||
from frappe import msgprint
|
from frappe import msgprint
|
||||||
|
from erpnext.hr.utils import set_employee_name
|
||||||
|
|
||||||
class LeaveDayBlockedError(frappe.ValidationError): pass
|
class LeaveDayBlockedError(frappe.ValidationError): pass
|
||||||
class OverlapError(frappe.ValidationError): pass
|
class OverlapError(frappe.ValidationError): pass
|
||||||
@@ -22,6 +23,8 @@ class LeaveApplication(Document):
|
|||||||
else:
|
else:
|
||||||
self.previous_doc = None
|
self.previous_doc = None
|
||||||
|
|
||||||
|
set_employee_name(self)
|
||||||
|
|
||||||
self.validate_to_date()
|
self.validate_to_date()
|
||||||
self.validate_balance_leaves()
|
self.validate_balance_leaves()
|
||||||
self.validate_leave_overlap()
|
self.validate_leave_overlap()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from frappe.model.naming import make_autoname
|
|||||||
|
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from erpnext.setup.utils import get_company_currency
|
from erpnext.setup.utils import get_company_currency
|
||||||
|
from erpnext.hr.utils import set_employee_name
|
||||||
|
|
||||||
from erpnext.utilities.transaction_base import TransactionBase
|
from erpnext.utilities.transaction_base import TransactionBase
|
||||||
|
|
||||||
@@ -146,6 +146,8 @@ class SalarySlip(TransactionBase):
|
|||||||
company_currency = get_company_currency(self.company)
|
company_currency = get_company_currency(self.company)
|
||||||
self.total_in_words = money_in_words(self.rounded_total, company_currency)
|
self.total_in_words = money_in_words(self.rounded_total, company_currency)
|
||||||
|
|
||||||
|
set_employee_name(self)
|
||||||
|
|
||||||
def calculate_earning_total(self):
|
def calculate_earning_total(self):
|
||||||
self.gross_pay = flt(self.arrear_amount) + flt(self.leave_encashment_amount)
|
self.gross_pay = flt(self.arrear_amount) + flt(self.leave_encashment_amount)
|
||||||
for d in self.get("earning_details"):
|
for d in self.get("earning_details"):
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from frappe.model.naming import make_autoname
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from erpnext.hr.utils import set_employee_name
|
||||||
|
|
||||||
class SalaryStructure(Document):
|
class SalaryStructure(Document):
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
@@ -63,6 +64,7 @@ class SalaryStructure(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.check_existing()
|
self.check_existing()
|
||||||
self.validate_amount()
|
self.validate_amount()
|
||||||
|
set_employee_name(self)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_salary_slip(source_name, target_doc=None):
|
def make_salary_slip(source_name, target_doc=None):
|
||||||
|
|||||||
@@ -22,3 +22,7 @@ def get_expense_approver_list():
|
|||||||
if not roles:
|
if not roles:
|
||||||
frappe.msgprint(_("No Expense Approvers. Please assign 'Expense Approver' Role to atleast one user"))
|
frappe.msgprint(_("No Expense Approvers. Please assign 'Expense Approver' Role to atleast one user"))
|
||||||
return roles
|
return roles
|
||||||
|
|
||||||
|
def set_employee_name(doc):
|
||||||
|
if doc.employee and not doc.employee_name:
|
||||||
|
doc.employee_name = frappe.db.get_value("Employee", doc.employee, "employee_name")
|
||||||
|
|||||||
Reference in New Issue
Block a user