Skip to content

Commit

Permalink
fix: return if field is not found (+ minor refactor) (#563) (#569)
Browse files Browse the repository at this point in the history
Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
(cherry picked from commit 6e3b0ed)

Co-authored-by: Sagar Vora <sagar@resilient.tech>
  • Loading branch information
mergify[bot] and sagarvora committed Jun 2, 2023
1 parent d5f79d8 commit 7158402
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions hrms/hr/utils.py
Expand Up @@ -146,17 +146,25 @@ def update_to_date_in_work_history(employee, cancel):

@frappe.whitelist()
def get_employee_field_property(employee, fieldname):
if employee and fieldname:
field = frappe.get_meta("Employee").get_field(fieldname)
value = frappe.db.get_value("Employee", employee, fieldname)
options = field.options
if field.fieldtype == "Date":
value = formatdate(value)
elif field.fieldtype == "Datetime":
value = format_datetime(value)
return {"value": value, "datatype": field.fieldtype, "label": field.label, "options": options}
else:
return False
if not (employee and fieldname):
return

field = frappe.get_meta("Employee").get_field(fieldname)
if not field:
return

value = frappe.db.get_value("Employee", employee, fieldname)
if field.fieldtype == "Date":
value = formatdate(value)
elif field.fieldtype == "Datetime":
value = format_datetime(value)

return {
"value": value,
"datatype": field.fieldtype,
"label": field.label,
"options": field.options,
}


def validate_dates(doc, from_date, to_date):
Expand Down

0 comments on commit 7158402

Please sign in to comment.