@@ -890,7 +890,9 @@ def load_invoice_items(self):
890890 (SalesInvoice .is_return == 1 ) & SalesInvoice .return_against .isnotnull ()
891891 )
892892 if self .vouchers_to_ignore :
893- ret_invoice_query = base_query .where (SalesInvoice .return_against .notin (self .vouchers_to_ignore ))
893+ ret_invoice_query = ret_invoice_query .where (
894+ SalesInvoice .return_against .notin (self .vouchers_to_ignore )
895+ )
894896
895897 self .si_list += ret_invoice_query .run (as_dict = True )
896898
@@ -910,7 +912,7 @@ def prepare_invoice_query(self):
910912 .where ((SalesInvoice .docstatus == 1 ) & (SalesInvoice .is_opening != "Yes" ))
911913 )
912914
913- query = self .apply_common_filters (query , SalesInvoice , SalesInvoiceItem , SalesTeam )
915+ query = self .apply_common_filters (query , SalesInvoice , SalesInvoiceItem , SalesTeam , Item )
914916
915917 query = query .select (
916918 SalesInvoiceItem .parenttype ,
@@ -974,7 +976,7 @@ def prepare_invoice_query(self):
974976
975977 return query
976978
977- def apply_common_filters (self , query , SalesInvoice , SalesInvoiceItem , SalesTeam ):
979+ def apply_common_filters (self , query , SalesInvoice , SalesInvoiceItem , SalesTeam , Item ):
978980 if self .filters .company :
979981 query = query .where (SalesInvoice .company == self .filters .company )
980982
@@ -985,7 +987,7 @@ def apply_common_filters(self, query, SalesInvoice, SalesInvoiceItem, SalesTeam)
985987 query = query .where (SalesInvoice .posting_date <= self .filters .to_date )
986988
987989 if self .filters .item_group :
988- query = query .where (get_item_group_condition (self .filters .item_group ))
990+ query = query .where (get_item_group_condition (self .filters .item_group , Item ))
989991
990992 if self .filters .sales_person :
991993 query = query .where (
0 commit comments