fix: escape for format and msg for working hours if not set

This commit is contained in:
pateljannat 2021-04-22 11:19:44 +05:30
parent 485464d1f4
commit ba6ad7f5be
2 changed files with 10 additions and 5 deletions

View File

@ -25,6 +25,11 @@ def get_data(filters):
def get_rows(filters): def get_rows(filters):
conditions = get_conditions(filters) conditions = get_conditions(filters)
standard_working_hours = frappe.db.get_single_value("HR Settings", "standard_working_hours") standard_working_hours = frappe.db.get_single_value("HR Settings", "standard_working_hours")
if not standard_working_hours:
hr_settings = "<a href='/app/hr-settings'>HR Settings</a>"
frappe.msgprint(_("The metrics for this report are calculated based on the Standard Working Hours. Please set Standard Working Hours in {0}.").format(hr_settings))
return []
sql = """ sql = """
SELECT SELECT
* *
@ -89,7 +94,7 @@ def get_conditions(filters):
conditions = [] conditions = []
if filters.get("company"): if filters.get("company"):
conditions.append("tabTimesheet.company='{0}'".format(filters.get("company"))) conditions.append("tabTimesheet.company={0}".format(frappe.db.escape(filters.get("company"))))
if filters.get("start_date"): if filters.get("start_date"):
conditions.append("tabTimesheet.start_date>='{0}'".format(filters.get("start_date"))) conditions.append("tabTimesheet.start_date>='{0}'".format(filters.get("start_date")))
@ -98,13 +103,13 @@ def get_conditions(filters):
conditions.append("tabTimesheet.end_date<='{0}'".format(filters.get("end_date"))) conditions.append("tabTimesheet.end_date<='{0}'".format(filters.get("end_date")))
if filters.get("customer_name"): if filters.get("customer_name"):
conditions.append("si.customer_name='{0}'".format(filters.get("customer_name"))) conditions.append("si.customer_name={0}".format(frappe.db.escape(filters.get("customer_name"))))
if filters.get("employee"): if filters.get("employee"):
conditions.append("tabTimesheet.employee='{0}'".format(filters.get("employee"))) conditions.append("tabTimesheet.employee={0}".format(frappe.db.escape(filters.get("employee"))))
if filters.get("project"): if filters.get("project"):
conditions.append("tabTimesheet.parent_project='{0}'".format(filters.get("project"))) conditions.append("tabTimesheet.parent_project={0}".format(frappe.db.escape(filters.get("project"))))
conditions = " and ".join(conditions) conditions = " and ".join(conditions)
return conditions return conditions

View File

@ -161,7 +161,7 @@ def validate_document_name(doc, method=None):
# Date was chosen as start of next FY to avoid irritating current users. # Date was chosen as start of next FY to avoid irritating current users.
if country != "India" or getdate(doc.posting_date) < getdate("2021-04-01"): if country != "India" or getdate(doc.posting_date) < getdate("2021-04-01"):
return return
print(doc.name)
if len(doc.name) > 16: if len(doc.name) > 16:
frappe.throw(_("Maximum length of document number should be 16 characters as per GST rules. Please change the naming series.")) frappe.throw(_("Maximum length of document number should be 16 characters as per GST rules. Please change the naming series."))