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:
|
if search_term and status:
|
||||||
pos_invoices_by_customer = frappe.db.get_list(
|
pos_invoices_by_customer = frappe.db.get_list(
|
||||||
"POS Invoice",
|
"POS Invoice",
|
||||||
filters=get_invoice_filters("POS Invoice", status, customer=search_term),
|
filters=get_invoice_filters("POS Invoice", status),
|
||||||
fields=fields,
|
or_filters={
|
||||||
page_length=limit,
|
"customer_name": ["like", f"%{search_term}%"],
|
||||||
)
|
"customer": ["like", f"%{search_term}%"],
|
||||||
|
},
|
||||||
pos_invoices_by_customer_name = frappe.db.get_list(
|
|
||||||
"POS Invoice",
|
|
||||||
filters=get_invoice_filters("POS Invoice", status, customer_name=search_term),
|
|
||||||
fields=fields,
|
fields=fields,
|
||||||
page_length=limit,
|
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_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_invoices_by_customer = frappe.db.get_list(
|
||||||
"Sales Invoice",
|
"Sales Invoice",
|
||||||
filters=get_invoice_filters("Sales Invoice", status, customer=search_term),
|
filters=get_invoice_filters("Sales Invoice", status),
|
||||||
fields=fields,
|
or_filters={
|
||||||
page_length=limit,
|
"customer_name": ["like", f"%{search_term}%"],
|
||||||
)
|
"customer": ["like", f"%{search_term}%"],
|
||||||
sales_invoices_by_customer_name = frappe.db.get_list(
|
},
|
||||||
"Sales Invoice",
|
|
||||||
filters=get_invoice_filters("Sales Invoice", status, customer_name=search_term),
|
|
||||||
fields=fields,
|
fields=fields,
|
||||||
page_length=limit,
|
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_list = add_doctype_to_results(
|
||||||
"Sales Invoice",
|
"Sales Invoice", sales_invoices_by_customer + sales_invoices_by_name
|
||||||
sales_invoices_by_customer + sales_invoices_by_name + sales_invoices_by_customer_name,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
elif status:
|
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 = {}
|
filters = {}
|
||||||
|
|
||||||
if name:
|
if name:
|
||||||
filters["name"] = ["like", f"%{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":
|
if doctype == "POS Invoice":
|
||||||
filters["status"] = status
|
filters["status"] = status
|
||||||
if status == "Partly Paid":
|
if status == "Partly Paid":
|
||||||
|
|||||||
Reference in New Issue
Block a user