fix: consistency of datetime field for query report while exporting
This commit is contained in:
parent
a9eea222fa
commit
60a7d1f7e9
1 changed files with 19 additions and 5 deletions
|
|
@ -16,7 +16,7 @@ from frappe.model.utils import render_include
|
|||
from frappe.modules import get_module_path, scrub
|
||||
from frappe.monitor import add_data_to_monitor
|
||||
from frappe.permissions import get_role_permissions, get_roles, has_permission
|
||||
from frappe.utils import cint, cstr, flt, format_duration, get_html_format, sbool
|
||||
from frappe.utils import cint, cstr, flt, format_datetime, format_duration, formatdate, get_html_format, sbool
|
||||
from frappe.utils.caching import request_cache
|
||||
|
||||
|
||||
|
|
@ -469,13 +469,27 @@ def format_fields(data: frappe._dict) -> None:
|
|||
if col.get("fieldtype") == "Duration":
|
||||
for row in data.result:
|
||||
index = col.get("fieldname") if isinstance(row, dict) else i
|
||||
if row[index]:
|
||||
row[index] = format_duration(row[index])
|
||||
val = row.get(index) if isinstance(row, dict) else row[index]
|
||||
if val:
|
||||
row[index] = format_duration(val)
|
||||
elif col.get("fieldtype") == "Currency" and col.get("precision"):
|
||||
for row in data.result:
|
||||
index = col.get("fieldname") if isinstance(row, dict) else i
|
||||
if row[index]:
|
||||
row[index] = round(row[index], col.get("precision"))
|
||||
val = row.get(index) if isinstance(row, dict) else row[index]
|
||||
if val:
|
||||
row[index] = round(val, col.get("precision"))
|
||||
elif col.get("fieldtype") == "Date":
|
||||
for row in data.result:
|
||||
index = col.get("fieldname") if isinstance(row, dict) else i
|
||||
val = row.get(index) if isinstance(row, dict) else row[index]
|
||||
if val:
|
||||
row[index] = formatdate(val)
|
||||
elif col.get("fieldtype") == "Datetime":
|
||||
for row in data.result:
|
||||
index = col.get("fieldname") if isinstance(row, dict) else i
|
||||
val = row.get(index) if isinstance(row, dict) else row[index]
|
||||
if val:
|
||||
row[index] = format_datetime(val)
|
||||
|
||||
|
||||
def build_xlsx_data(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue