From b2a6ebf4bdd82424e10794cd7a40f723f61e6a84 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Tue, 12 Mar 2024 15:44:17 +0100 Subject: [PATCH] fix: Logic to fetch advance payments not linked to a subscription or sales order --- erpnext/controllers/accounts_controller.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index ce18d005ebe..fff1f962d21 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2808,13 +2808,20 @@ def get_advance_journal_entries( else: q = q.where(journal_acc.debit_in_account_currency > 0) + order_list_query = (journal_acc.reference_type == order_doctype) & ( + (journal_acc.reference_name).isin(order_list) + ) if include_unallocated: - q = q.where((journal_acc.reference_name.isnull()) | (journal_acc.reference_name == "")) - - if order_list: - q = q.where( - (journal_acc.reference_type == order_doctype) & ((journal_acc.reference_name).isin(order_list)) + include_unallocated_query = (journal_acc.reference_name.isnull()) | ( + journal_acc.reference_name == "" ) + if order_list: + q = q.where(include_unallocated_query | order_list_query) + else: + q = q.where(include_unallocated_query) + + elif order_list: + q = q.where(order_list_query) q = q.orderby(journal_entry.posting_date) -- GitLab