refactor: use db.get_single_value
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index 82af85d..651599d 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -91,8 +91,8 @@
super(Account, self).on_update()
def onload(self):
- frozen_accounts_modifier = frappe.db.get_value(
- "Accounts Settings", "Accounts Settings", "frozen_accounts_modifier"
+ frozen_accounts_modifier = frappe.db.get_single_value(
+ "Accounts Settings", "frozen_accounts_modifier"
)
if not frozen_accounts_modifier or frozen_accounts_modifier in frappe.get_roles():
self.set_onload("can_freeze_account", True)
diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index 139f526..777a5bb 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -435,8 +435,8 @@
def validate_frozen_account(account, adv_adj=None):
frozen_account = frappe.get_cached_value("Account", account, "freeze_account")
if frozen_account == "Yes" and not adv_adj:
- frozen_accounts_modifier = frappe.db.get_value(
- "Accounts Settings", None, "frozen_accounts_modifier"
+ frozen_accounts_modifier = frappe.db.get_single_value(
+ "Accounts Settings", "frozen_accounts_modifier"
)
if not frozen_accounts_modifier:
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index e676560..7f145c5 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -552,7 +552,7 @@
self.against_expense_account = ",".join(against_accounts)
def po_required(self):
- if frappe.db.get_value("Buying Settings", None, "po_required") == "Yes":
+ if frappe.db.get_single_value("Buying Settings", "po_required") == "Yes":
if frappe.get_value(
"Supplier", self.supplier, "allow_purchase_invoice_creation_without_purchase_order"
@@ -572,7 +572,7 @@
def pr_required(self):
stock_items = self.get_stock_items()
- if frappe.db.get_value("Buying Settings", None, "pr_required") == "Yes":
+ if frappe.db.get_single_value("Buying Settings", "pr_required") == "Yes":
if frappe.get_value(
"Supplier", self.supplier, "allow_purchase_invoice_creation_without_purchase_receipt"
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 8aa95bf..5acd8b0 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -1237,8 +1237,8 @@
@change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1})
def test_gain_loss_with_advance_entry(self):
- unlink_enabled = frappe.db.get_value(
- "Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice"
+ unlink_enabled = frappe.db.get_single_value(
+ "Accounts Settings", "unlink_payment_on_cancel_of_invoice"
)
frappe.db.set_single_value("Accounts Settings", "unlink_payment_on_cancel_of_invoice", 1)
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index 91ba239..b48a8e6 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -654,10 +654,10 @@
Hence stop admin to bypass if accounts are freezed
"""
if not adv_adj:
- acc_frozen_upto = frappe.db.get_value("Accounts Settings", None, "acc_frozen_upto")
+ acc_frozen_upto = frappe.db.get_single_value("Accounts Settings", "acc_frozen_upto")
if acc_frozen_upto:
- frozen_accounts_modifier = frappe.db.get_value(
- "Accounts Settings", None, "frozen_accounts_modifier"
+ frozen_accounts_modifier = frappe.db.get_single_value(
+ "Accounts Settings", "frozen_accounts_modifier"
)
if getdate(posting_date) <= getdate(acc_frozen_upto) and (
frozen_accounts_modifier not in frappe.get_roles() or frappe.session.user == "Administrator"
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 9feda11..3a70afc 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -55,8 +55,8 @@
def run(self, args):
self.filters.update(args)
self.set_defaults()
- self.party_naming_by = frappe.db.get_value(
- args.get("naming_by")[0], None, args.get("naming_by")[1]
+ self.party_naming_by = frappe.db.get_single_value(
+ args.get("naming_by")[0], args.get("naming_by")[1]
)
self.get_columns()
self.get_data()
diff --git a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
index 22b5c6b..0947cff 100644
--- a/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
+++ b/erpnext/accounts/report/accounts_receivable_summary/accounts_receivable_summary.py
@@ -24,8 +24,8 @@
def run(self, args):
self.account_type = args.get("account_type")
self.party_type = get_party_types_from_account_type(self.account_type)
- self.party_naming_by = frappe.db.get_value(
- args.get("naming_by")[0], None, args.get("naming_by")[1]
+ self.party_naming_by = frappe.db.get_single_value(
+ args.get("naming_by")[0], args.get("naming_by")[1]
)
self.get_columns()
self.get_data(args)
diff --git a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
index 0464f99..a2c0f86 100644
--- a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
+++ b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
@@ -21,8 +21,8 @@
frappe.throw(_("From Date must be before To Date"))
self.filters.party_type = args.get("party_type")
- self.party_naming_by = frappe.db.get_value(
- args.get("naming_by")[0], None, args.get("naming_by")[1]
+ self.party_naming_by = frappe.db.get_single_value(
+ args.get("naming_by")[0], args.get("naming_by")[1]
)
self.get_gl_entries()
diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py
index 66930c0..017df90 100644
--- a/erpnext/assets/doctype/asset/depreciation.py
+++ b/erpnext/assets/doctype/asset/depreciation.py
@@ -35,7 +35,7 @@
def post_depreciation_entries(date=None):
# Return if automatic booking of asset depreciation is disabled
if not cint(
- frappe.db.get_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically")
+ frappe.db.get_single_value("Accounts Settings", "book_asset_depreciation_entry_automatically")
):
return
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
index 9aaf86b..eec996c 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
@@ -358,8 +358,8 @@
target_doc.currency = args.currency or get_party_account_currency(
"Supplier", for_supplier, source.company
)
- target_doc.buying_price_list = args.buying_price_list or frappe.db.get_value(
- "Buying Settings", None, "buying_price_list"
+ target_doc.buying_price_list = args.buying_price_list or frappe.db.get_single_value(
+ "Buying Settings", "buying_price_list"
)
set_missing_values(source, target_doc)
@@ -399,7 +399,7 @@
"currency": doc.get("currency")
or get_party_account_currency("Supplier", doc.get("supplier"), doc.get("company")),
"buying_price_list": doc.get("buying_price_list")
- or frappe.db.get_value("Buying Settings", None, "buying_price_list"),
+ or frappe.db.get_single_value("Buying Settings", "buying_price_list"),
}
)
add_items(sq_doc, doc.get("supplier"), doc.get("items"))
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
index 8ebca54..ba1fae9 100644
--- a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
@@ -129,9 +129,7 @@
self.default_cost_center, self.default_round_off_account = frappe.db.get_value(
"Company", self.erpnext_company, ["cost_center", "round_off_account"]
)
- self.default_warehouse = frappe.db.get_value(
- "Stock Settings", "Stock Settings", "default_warehouse"
- )
+ self.default_warehouse = frappe.db.get_single_value("Stock Settings", "default_warehouse")
def _process_master_data(self):
def get_company_name(collection):
diff --git a/erpnext/manufacturing/doctype/workstation/workstation.py b/erpnext/manufacturing/doctype/workstation/workstation.py
index 0a247fc..0f05eaa 100644
--- a/erpnext/manufacturing/doctype/workstation/workstation.py
+++ b/erpnext/manufacturing/doctype/workstation/workstation.py
@@ -156,7 +156,7 @@
if not frappe.db.get_single_value("Manufacturing Settings", "allow_production_on_holidays"):
check_workstation_for_holiday(workstation, from_datetime, to_datetime)
- if not cint(frappe.db.get_value("Manufacturing Settings", None, "allow_overtime")):
+ if not cint(frappe.db.get_single_value("Manufacturing Settings", "allow_overtime")):
is_within_operating_hours(workstation, operation, from_datetime, to_datetime)
diff --git a/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py b/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py
index 0f77afd..8e58d79 100644
--- a/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py
+++ b/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py
@@ -45,7 +45,7 @@
message=json.dumps(purchase_invoices + sales_invoices, indent=2),
)
- acc_frozen_upto = frappe.db.get_value("Accounts Settings", None, "acc_frozen_upto")
+ acc_frozen_upto = frappe.db.get_single_value("Accounts Settings", "acc_frozen_upto")
if acc_frozen_upto:
frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", None)
diff --git a/erpnext/patches/v14_0/migrate_crm_settings.py b/erpnext/patches/v14_0/migrate_crm_settings.py
index 2477255..d093bc3 100644
--- a/erpnext/patches/v14_0/migrate_crm_settings.py
+++ b/erpnext/patches/v14_0/migrate_crm_settings.py
@@ -2,8 +2,7 @@
def execute():
- settings = frappe.db.get_value(
- "Selling Settings",
+ settings = frappe.db.get_single_value(
"Selling Settings",
["campaign_naming_by", "close_opportunity_after_days", "default_valid_till"],
as_dict=True,
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index a6c86a6..ac7fdb1 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -35,8 +35,8 @@
def setUpClass(cls):
super().setUpClass()
cls.unlink_setting = int(
- frappe.db.get_value(
- "Accounts Settings", "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order"
+ frappe.db.get_single_value(
+ "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order"
)
)
diff --git a/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py b/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py
index 98633cb..a584d3a 100644
--- a/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py
+++ b/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py
@@ -13,7 +13,7 @@
if not filters:
filters = {}
# Check if customer id is according to naming series or customer name
- customer_naming_type = frappe.db.get_value("Selling Settings", None, "cust_master_name")
+ customer_naming_type = frappe.db.get_single_value("Selling Settings", "cust_master_name")
columns = get_columns(customer_naming_type)
data = []
diff --git a/erpnext/startup/boot.py b/erpnext/startup/boot.py
index 4b4d14f..4cd0ef4 100644
--- a/erpnext/startup/boot.py
+++ b/erpnext/startup/boot.py
@@ -9,7 +9,7 @@
def boot_session(bootinfo):
"""boot session - send website info if guest"""
- bootinfo.custom_css = frappe.db.get_value("Style Settings", None, "custom_css") or ""
+ bootinfo.custom_css = frappe.db.get_single_value("Style Settings", "custom_css") or ""
if frappe.session["user"] != "Guest":
update_page_info(bootinfo)
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 2d9e11a..feb4583 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -635,8 +635,8 @@
def recalculate_bin_qty(self, new_name):
from erpnext.stock.stock_balance import repost_stock
- existing_allow_negative_stock = frappe.db.get_value(
- "Stock Settings", None, "allow_negative_stock"
+ existing_allow_negative_stock = frappe.db.get_single_value(
+ "Stock Settings", "allow_negative_stock"
)
frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py
index 580c7c0..882c3f5 100644
--- a/erpnext/stock/doctype/price_list/price_list.py
+++ b/erpnext/stock/doctype/price_list/price_list.py
@@ -39,11 +39,11 @@
def set_default_if_missing(self):
if cint(self.selling):
- if not frappe.db.get_value("Selling Settings", None, "selling_price_list"):
+ if not frappe.db.get_single_value("Selling Settings", "selling_price_list"):
frappe.set_value("Selling Settings", "Selling Settings", "selling_price_list", self.name)
elif cint(self.buying):
- if not frappe.db.get_value("Buying Settings", None, "buying_price_list"):
+ if not frappe.db.get_single_value("Buying Settings", "buying_price_list"):
frappe.set_value("Buying Settings", "Buying Settings", "buying_price_list", self.name)
def update_item_price(self):
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index c7e36e9..5cfa739 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -302,7 +302,7 @@
)
def po_required(self):
- if frappe.db.get_value("Buying Settings", None, "po_required") == "Yes":
+ if frappe.db.get_single_value("Buying Settings", "po_required") == "Yes":
for d in self.get("items"):
if not d.purchase_order:
frappe.throw(_("Purchase Order number required for Item {0}").format(d.item_code))
diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
index 79b8ee3..909aa36 100644
--- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
+++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py
@@ -140,11 +140,8 @@
return query[0][0] if query else None
def validate_accounts_freeze(self):
- acc_settings = frappe.db.get_value(
- "Accounts Settings",
- "Accounts Settings",
- ["acc_frozen_upto", "frozen_accounts_modifier"],
- as_dict=1,
+ acc_settings = frappe.db.get_single_value(
+ "Accounts Settings", ["acc_frozen_upto", "frozen_accounts_modifier"], as_dict=1
)
if not acc_settings.acc_frozen_upto:
return
diff --git a/erpnext/stock/reorder_item.py b/erpnext/stock/reorder_item.py
index a6f52f3..4cd9cbb 100644
--- a/erpnext/stock/reorder_item.py
+++ b/erpnext/stock/reorder_item.py
@@ -18,7 +18,7 @@
if not (frappe.db.a_row_exists("Company") and frappe.db.a_row_exists("Fiscal Year")):
return
- if cint(frappe.db.get_value("Stock Settings", None, "auto_indent")):
+ if cint(frappe.db.get_single_value("Stock Settings", "auto_indent")):
return _reorder_item()
@@ -212,7 +212,7 @@
if mr_list:
if getattr(frappe.local, "reorder_email_notify", None) is None:
frappe.local.reorder_email_notify = cint(
- frappe.db.get_value("Stock Settings", None, "reorder_email_notify")
+ frappe.db.get_single_value("Stock Settings", "reorder_email_notify")
)
if frappe.local.reorder_email_notify:
diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py
index a4fe2ee..ba03ff2 100644
--- a/erpnext/stock/stock_balance.py
+++ b/erpnext/stock/stock_balance.py
@@ -15,8 +15,8 @@
frappe.db.auto_commit_on_many_writes = 1
if allow_negative_stock:
- existing_allow_negative_stock = frappe.db.get_value(
- "Stock Settings", None, "allow_negative_stock"
+ existing_allow_negative_stock = frappe.db.get_single_value(
+ "Stock Settings", "allow_negative_stock"
)
frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index 4b0e284..f29e7ea 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -338,7 +338,7 @@
val_method = frappe.db.get_value("Item", item_code, "valuation_method", cache=True)
if not val_method:
val_method = (
- frappe.db.get_value("Stock Settings", None, "valuation_method", cache=True) or "FIFO"
+ frappe.db.get_single_value("Stock Settings", "valuation_method", cache=True) or "FIFO"
)
return val_method
diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py
index c03fb3e..dc1529b 100644
--- a/erpnext/support/doctype/issue/issue.py
+++ b/erpnext/support/doctype/issue/issue.py
@@ -230,7 +230,7 @@
def auto_close_tickets():
"""Auto-close replied support tickets after 7 days"""
auto_close_after_days = (
- frappe.db.get_value("Support Settings", "Support Settings", "close_issue_after_days") or 7
+ frappe.db.get_single_value("Support Settings", "close_issue_after_days") or 7
)
table = frappe.qb.DocType("Issue")
diff --git a/erpnext/utilities/doctype/video/video.py b/erpnext/utilities/doctype/video/video.py
index 1a9fe19..7a04329 100644
--- a/erpnext/utilities/doctype/video/video.py
+++ b/erpnext/utilities/doctype/video/video.py
@@ -78,8 +78,8 @@
def update_youtube_data():
# Called every 30 minutes via hooks
- enable_youtube_tracking, frequency = frappe.db.get_value(
- "Video Settings", "Video Settings", ["enable_youtube_tracking", "frequency"]
+ enable_youtube_tracking, frequency = frappe.db.get_single_value(
+ "Video Settings", ["enable_youtube_tracking", "frequency"]
)
if not cint(enable_youtube_tracking):