Fetch warehouse from pos settings
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 614c13a..5d6171a 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -383,20 +383,20 @@
def get_warehouse(self):
- w = frappe.db.sql("""select warehouse from `tabPOS Setting`
- where ifnull(user,'') = %s and company = %s""",
- (frappe.session['user'], self.company))
- w = w and w[0][0] or ''
- if not w:
- ps = frappe.db.sql("""select name, warehouse from `tabPOS Setting`
+ user_pos_setting = frappe.db.sql("""select name, warehouse from `tabPOS Setting`
+ where ifnull(user,'') = %s and company = %s""", (frappe.session['user'], self.company))
+ warehouse = user_pos_setting[0][1] if user_pos_setting else None
+
+ if not warehouse:
+ global_pos_setting = frappe.db.sql("""select name, warehouse from `tabPOS Setting`
where ifnull(user,'') = '' and company = %s""", self.company)
- if not ps:
+
+ if global_pos_setting:
+ warehouse = global_pos_setting[0][1] if global_pos_setting else None
+ elif not user_pos_setting:
msgprint(_("POS Setting required to make POS Entry"), raise_exception=True)
- elif not ps[0][1]:
- msgprint(_("Warehouse required in POS Setting"))
- else:
- w = ps[0][1]
- return w
+
+ return warehouse
def on_update(self):
if cint(self.update_stock) == 1: