mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-27 02:28:30 +00:00
* fix(dashboard-trends): set default fiscal year and company before val… (#54339)
* fix(dashboard-trends): set default fiscal year and company before validating filters Ensure and are populated with default values
* fix(dashboard-trends): ensure fiscal_year and company are properly set before validation to avoid empty filter issues
* Update erpnext/controllers/trends.py
---------
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
(cherry picked from commit d61b5fd5f6)
# Conflicts:
# erpnext/controllers/trends.py
* chore: fix conflicts
---------
Co-authored-by: Ahmed AbuKhatwa <82771130+AhmedAbokhatwa@users.noreply.github.com>
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
This commit is contained in:
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import getdate
|
from frappe.utils import DateTimeLikeObject, getdate, today
|
||||||
|
|
||||||
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
|
|
||||||
|
|
||||||
def get_columns(filters, trans):
|
def get_columns(filters, trans):
|
||||||
@@ -45,6 +47,10 @@ def get_columns(filters, trans):
|
|||||||
|
|
||||||
|
|
||||||
def validate_filters(filters):
|
def validate_filters(filters):
|
||||||
|
if not filters.get("fiscal_year"):
|
||||||
|
filters["fiscal_year"] = get_fiscal_year(today())[0]
|
||||||
|
if not filters.get("company"):
|
||||||
|
filters["company"] = frappe.defaults.get_user_default("Company")
|
||||||
for f in ["Fiscal Year", "Based On", "Period", "Company"]:
|
for f in ["Fiscal Year", "Based On", "Period", "Company"]:
|
||||||
if not filters.get(f.lower().replace(" ", "_")):
|
if not filters.get(f.lower().replace(" ", "_")):
|
||||||
frappe.throw(_("{0} is mandatory").format(_(f)))
|
frappe.throw(_("{0} is mandatory").format(_(f)))
|
||||||
|
|||||||
Reference in New Issue
Block a user