refactor: use or_filters for customer and customer_name
This commit is contained in:
@@ -344,14 +344,11 @@ def get_past_order_list(search_term, status, limit=20):
|
||||
if search_term and status:
|
||||
pos_invoices_by_customer = frappe.db.get_list(
|
||||
"POS Invoice",
|
||||
filters=get_invoice_filters("POS Invoice", status, customer=search_term),
|
||||
fields=fields,
|
||||
page_length=limit,
|
||||
)
|
||||
|
||||
pos_invoices_by_customer_name = frappe.db.get_list(
|
||||
"POS Invoice",
|
||||
filters=get_invoice_filters("POS Invoice", status, customer_name=search_term),
|
||||
filters=get_invoice_filters("POS Invoice", status),
|
||||
or_filters={
|
||||
"customer_name": ["like", f"%{search_term}%"],
|
||||
"customer": ["like", f"%{search_term}%"],
|
||||
},
|
||||
fields=fields,
|
||||
page_length=limit,
|
||||
)
|
||||
@@ -364,18 +361,16 @@ def get_past_order_list(search_term, status, limit=20):
|
||||
)
|
||||
|
||||
pos_invoice_list = add_doctype_to_results(
|
||||
"POS Invoice", pos_invoices_by_customer + pos_invoices_by_name + pos_invoices_by_customer_name
|
||||
"POS Invoice", pos_invoices_by_customer + pos_invoices_by_name
|
||||
)
|
||||
|
||||
sales_invoices_by_customer = frappe.db.get_list(
|
||||
"Sales Invoice",
|
||||
filters=get_invoice_filters("Sales Invoice", status, customer=search_term),
|
||||
fields=fields,
|
||||
page_length=limit,
|
||||
)
|
||||
sales_invoices_by_customer_name = frappe.db.get_list(
|
||||
"Sales Invoice",
|
||||
filters=get_invoice_filters("Sales Invoice", status, customer_name=search_term),
|
||||
filters=get_invoice_filters("Sales Invoice", status),
|
||||
or_filters={
|
||||
"customer_name": ["like", f"%{search_term}%"],
|
||||
"customer": ["like", f"%{search_term}%"],
|
||||
},
|
||||
fields=fields,
|
||||
page_length=limit,
|
||||
)
|
||||
@@ -387,8 +382,7 @@ def get_past_order_list(search_term, status, limit=20):
|
||||
)
|
||||
|
||||
sales_invoice_list = add_doctype_to_results(
|
||||
"Sales Invoice",
|
||||
sales_invoices_by_customer + sales_invoices_by_name + sales_invoices_by_customer_name,
|
||||
"Sales Invoice", sales_invoices_by_customer + sales_invoices_by_name
|
||||
)
|
||||
|
||||
elif status:
|
||||
@@ -482,15 +476,11 @@ def order_results_by_posting_date(results):
|
||||
)
|
||||
|
||||
|
||||
def get_invoice_filters(doctype, status, name=None, customer=None, customer_name=None):
|
||||
def get_invoice_filters(doctype, status, name=None):
|
||||
filters = {}
|
||||
|
||||
if name:
|
||||
filters["name"] = ["like", f"%{name}%"]
|
||||
if customer:
|
||||
filters["customer"] = ["like", f"%{customer}%"]
|
||||
if customer_name:
|
||||
filters["customer_name"] = ["like", f"%{customer_name}%"]
|
||||
if doctype == "POS Invoice":
|
||||
filters["status"] = status
|
||||
if status == "Partly Paid":
|
||||
|
||||
Reference in New Issue
Block a user