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