From 6f9fe6a792ecfb5008cd7b7159679d62747a646d Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Wed, 10 Jan 2024 08:02:27 +0100 Subject: [PATCH] fix: wrong usage of get_single_value (#39268) * fix: wrong usage of get_single_value * test: fix wrong fieldname * chore: typo --------- Co-authored-by: Ankush Menat --- .../doctype/purchase_invoice/test_purchase_invoice.py | 6 +++--- erpnext/patches/v14_0/migrate_crm_settings.py | 6 +----- .../repost_item_valuation/repost_item_valuation.py | 2 +- erpnext/utilities/doctype/video/video.py | 8 +++----- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 5acd8b074b..992fbe6e02 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -1238,10 +1238,10 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): @change_settings("Accounts Settings", {"unlink_payment_on_cancellation_of_invoice": 1}) def test_gain_loss_with_advance_entry(self): unlink_enabled = frappe.db.get_single_value( - "Accounts Settings", "unlink_payment_on_cancel_of_invoice" + "Accounts Settings", "unlink_payment_on_cancellation_of_invoice" ) - frappe.db.set_single_value("Accounts Settings", "unlink_payment_on_cancel_of_invoice", 1) + frappe.db.set_single_value("Accounts Settings", "unlink_payment_on_cancellation_of_invoice", 1) original_account = frappe.db.get_value("Company", "_Test Company", "exchange_gain_loss_account") frappe.db.set_value( @@ -1432,7 +1432,7 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): pay.cancel() frappe.db.set_single_value( - "Accounts Settings", "unlink_payment_on_cancel_of_invoice", unlink_enabled + "Accounts Settings", "unlink_payment_on_cancellation_of_invoice", unlink_enabled ) frappe.db.set_value("Company", "_Test Company", "exchange_gain_loss_account", original_account) diff --git a/erpnext/patches/v14_0/migrate_crm_settings.py b/erpnext/patches/v14_0/migrate_crm_settings.py index d093bc386e..e928626d3c 100644 --- a/erpnext/patches/v14_0/migrate_crm_settings.py +++ b/erpnext/patches/v14_0/migrate_crm_settings.py @@ -2,11 +2,7 @@ import frappe def execute(): - settings = frappe.db.get_single_value( - "Selling Settings", - ["campaign_naming_by", "close_opportunity_after_days", "default_valid_till"], - as_dict=True, - ) + settings = frappe.db.get_singles_dict("Selling Settings", cast=True) frappe.reload_doc("crm", "doctype", "crm_settings") if settings: 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 112c2260e9..4f45210fb9 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py @@ -140,7 +140,7 @@ class RepostItemValuation(Document): return query[0][0] if query else None def validate_accounts_freeze(self): - acc_settings = frappe.get_cached_doc("Account Settings") + acc_settings = frappe.get_cached_doc("Accounts Settings") if not acc_settings.acc_frozen_upto: return if getdate(self.posting_date) <= getdate(acc_settings.acc_frozen_upto): diff --git a/erpnext/utilities/doctype/video/video.py b/erpnext/utilities/doctype/video/video.py index c3a653a5cf..875c4e723a 100644 --- a/erpnext/utilities/doctype/video/video.py +++ b/erpnext/utilities/doctype/video/video.py @@ -78,13 +78,11 @@ def get_frequency(value): def update_youtube_data(): # Called every 30 minutes via hooks - enable_youtube_tracking = frappe.db.get_single_value("Video Settings", "enable_youtube_tracking") - frequency = frappe.db.get_single_value("Video Settings", "frequency") - - if not cint(enable_youtube_tracking): + video_settings = frappe.get_cached_doc("Video Settings") + if not video_settings.enable_youtube_tracking: return - frequency = get_frequency(frequency) + frequency = get_frequency(video_settings.frequency) time = datetime.now() timezone = pytz.timezone(get_system_timezone()) site_time = time.astimezone(timezone)