From 021aa63e24443625ff0621eaf1148ac075f637db Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Fri, 20 Feb 2026 15:20:47 +0530 Subject: [PATCH] fix: incorrect type hint --- erpnext/controllers/accounts_controller.py | 5 ++-- erpnext/controllers/queries.py | 28 ++++++++++++++----- erpnext/controllers/stock_controller.py | 2 +- .../controllers/subcontracting_controller.py | 4 +-- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 494fc1ab44c..8223ab55c57 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -3139,7 +3139,7 @@ def get_default_taxes_and_charges( @frappe.whitelist() -def get_taxes_and_charges(master_doctype: str, master_name: str): +def get_taxes_and_charges(master_doctype: str, master_name: str | None = None): if not master_name: return from frappe.model import child_table_fields, default_fields @@ -3564,6 +3564,7 @@ def get_payment_terms( schedule = [] for d in terms_doc.get("terms"): + d = frappe._dict(d.as_dict()) term_details = get_payment_term_details(d, posting_date, grand_total, base_grand_total, bill_date) schedule.append(term_details) @@ -3612,7 +3613,7 @@ def get_payment_term_details( term_details.due_date = get_due_date(term, posting_date) term_details.discount_date = get_discount_date(term, posting_date) - if getdate(term_details.due_date) < getdate(posting_date): + if posting_date and getdate(term_details.due_date) < getdate(posting_date): term_details.due_date = posting_date return term_details diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 11216712a4e..c3503da61a4 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -27,7 +27,7 @@ def employee_query( searchfield: str, start: int, page_len: int, - filters: dict, + filters: dict | str | None = None, reference_doctype: str | None = None, ignore_user_permissions: bool = False, ): @@ -91,7 +91,9 @@ def has_ignored_field(reference_doctype, doctype): # searches for leads which are not converted @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs -def lead_query(doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict): +def lead_query( + doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict | None = None +): doctype = "Lead" fields = get_fields(doctype, ["name", "lead_name", "company_name"]) @@ -175,7 +177,13 @@ def tax_account_query(doctype: str, txt: str, searchfield: str, start: int, page @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs def item_query( - doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict, as_dict: bool = False + doctype: str, + txt: str, + searchfield: str, + start: int, + page_len: int, + filters: dict | str | None = None, + as_dict: bool = False, ): doctype = "Item" conditions = [] @@ -282,7 +290,9 @@ def item_query( @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs -def bom(doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict): +def bom( + doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict | str | None = None +): doctype = "BOM" conditions = [] fields = get_fields(doctype, ["name", "item"]) @@ -314,7 +324,9 @@ def bom(doctype: str, txt: str, searchfield: str, start: int, page_len: int, fil @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs -def get_project_name(doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict): +def get_project_name( + doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict | None = None +): proj = qb.DocType("Project") qb_filter_and_conditions = [] qb_filter_or_conditions = [] @@ -563,7 +575,9 @@ def get_batches_from_serial_and_batch_bundle(searchfields, txt, filters, start=0 @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs -def get_account_list(doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict): +def get_account_list( + doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict | list +): doctype = "Account" filter_list = [] @@ -740,7 +754,7 @@ def get_expense_account(doctype: str, txt: str, searchfield: str, start: int, pa @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs -def warehouse_query(doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: dict): +def warehouse_query(doctype: str, txt: str, searchfield: str, start: int, page_len: int, filters: list): # Should be used when item code is passed in filters. doctype = "Warehouse" conditions, bin_conditions = [], [] diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 4bd0a804597..ea356f2a21e 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -2087,7 +2087,7 @@ def check_item_quality_inspection(doctype: str, items: str | list[dict]): @frappe.whitelist() -def make_quality_inspections(doctype: str, docname: str, items: str | list[dict], inspection_type: str): +def make_quality_inspections(doctype: str, docname: str, items: str | list, inspection_type: str): if isinstance(items, str): items = json.loads(items) diff --git a/erpnext/controllers/subcontracting_controller.py b/erpnext/controllers/subcontracting_controller.py index f214501c5b1..79b78b5544a 100644 --- a/erpnext/controllers/subcontracting_controller.py +++ b/erpnext/controllers/subcontracting_controller.py @@ -1369,7 +1369,7 @@ def get_pending_subcontracted_quantity(doctype, name): @frappe.whitelist() def make_rm_stock_entry( subcontract_order: str, - rm_items: str | list[dict], + rm_items: str | list | None = None, order_doctype: str = "Subcontracting Order", target_doc: dict | None = None, ): @@ -1559,7 +1559,7 @@ def make_return_stock_entry_for_subcontract( @frappe.whitelist() def get_materials_from_supplier( - subcontract_order: str, rm_details: str | list[dict], order_doctype: str = "Subcontracting Order" + subcontract_order: str, rm_details: str | list, order_doctype: str = "Subcontracting Order" ): if isinstance(rm_details, str): rm_details = json.loads(rm_details)