mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 04:09:11 +00:00
refactor(sales_invoice): replace sql with qb in get_warehouse (#55381)
This commit is contained in:
@@ -1364,19 +1364,28 @@ class SalesInvoice(SellingController):
|
|||||||
self.total_billing_hours = timesheet_sum("billing_hours")
|
self.total_billing_hours = timesheet_sum("billing_hours")
|
||||||
|
|
||||||
def get_warehouse(self):
|
def get_warehouse(self):
|
||||||
user_pos_profile = frappe.db.sql(
|
POSProfile = frappe.qb.DocType("POS Profile")
|
||||||
"""select name, warehouse from `tabPOS Profile`
|
|
||||||
where ifnull(user,'') = %s and company = %s""",
|
user_query = (
|
||||||
(frappe.session["user"], self.company),
|
frappe.qb.from_(POSProfile)
|
||||||
|
.select(POSProfile.name, POSProfile.warehouse)
|
||||||
|
.where(POSProfile.company == self.company)
|
||||||
|
.where(
|
||||||
|
(POSProfile.user == frappe.session["user"])
|
||||||
|
| ((POSProfile.user.isnull() | (POSProfile.user == "")) & (frappe.session["user"] == ""))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
user_pos_profile = user_query.run()
|
||||||
warehouse = user_pos_profile[0][1] if user_pos_profile else None
|
warehouse = user_pos_profile[0][1] if user_pos_profile else None
|
||||||
|
|
||||||
if not warehouse:
|
if not warehouse:
|
||||||
global_pos_profile = frappe.db.sql(
|
global_query = (
|
||||||
"""select name, warehouse from `tabPOS Profile`
|
frappe.qb.from_(POSProfile)
|
||||||
where (user is null or user = '') and company = %s""",
|
.select(POSProfile.name, POSProfile.warehouse)
|
||||||
self.company,
|
.where(POSProfile.company == self.company)
|
||||||
|
.where(POSProfile.user.isnull() | (POSProfile.user == ""))
|
||||||
)
|
)
|
||||||
|
global_pos_profile = global_query.run()
|
||||||
|
|
||||||
if global_pos_profile:
|
if global_pos_profile:
|
||||||
warehouse = global_pos_profile[0][1]
|
warehouse = global_pos_profile[0][1]
|
||||||
|
|||||||
Reference in New Issue
Block a user