fix(setup): use the stored lower-case fieldname in the Sales Person lookup (Postgres)

deactivate_sales_person looks up `frappe.db.get_value("Sales Person",
{"Employee": employee})`. The Sales Person field is `employee` (lower case);
the lookup runs with ignore_permissions, so the capital-cased key reaches the
query as the column `"Employee"`. PostgreSQL matches quoted identifiers
case-sensitively and errors:

    column "Employee" does not exist

MariaDB resolves `Employee` to the `employee` column regardless of case, so
using the stored `{"employee": employee}` selects the same row on MariaDB and
is valid on PostgreSQL.
This commit is contained in:
Mihir Kandoi
2026-06-23 18:45:27 +05:30
parent 54cfeaf357
commit abe9e8becc

View File

@@ -427,7 +427,7 @@ def is_holiday(employee, date=None, raise_exception=True, only_non_weekly=False,
def deactivate_sales_person(status: str, employee: str):
frappe.has_permission("Employee", doc=employee, ptype="write", throw=True)
if status == "Left":
sales_person = frappe.db.get_value("Sales Person", {"Employee": employee})
sales_person = frappe.db.get_value("Sales Person", {"employee": employee})
if sales_person:
frappe.db.set_value("Sales Person", sales_person, "enabled", 0)