fix: advance journal fetching logic in Advances section
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index c543dfc..9499c47 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -2707,14 +2707,20 @@
else:
q = q.where(journal_acc.debit_in_account_currency > 0)
+ reference_or_condition = []
+
if include_unallocated:
- q = q.where((journal_acc.reference_name.isnull()) | (journal_acc.reference_name == ""))
+ reference_or_condition.append(journal_acc.reference_name.isnull())
+ reference_or_condition.append(journal_acc.reference_name == "")
if order_list:
- q = q.where(
+ reference_or_condition.append(
(journal_acc.reference_type == order_doctype) & ((journal_acc.reference_name).isin(order_list))
)
+ if reference_or_condition:
+ q = q.where(Criterion.any(reference_or_condition))
+
q = q.orderby(journal_entry.posting_date)
journal_entries = q.run(as_dict=True)