From 765c7c2bcc3a2f2598d12a084ff7b72986946f58 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Mon, 9 Jun 2025 10:10:02 +0530 Subject: [PATCH] refactor: rename get_settings -> get_single_value (#47961) --- erpnext/accounts/deferred_revenue.py | 2 +- erpnext/accounts/doctype/account/account.py | 2 +- .../bank_transaction/auto_match_party.py | 2 +- .../bank_transaction/bank_transaction.py | 2 +- .../doctype/journal_entry/journal_entry.py | 2 +- .../doctype/payment_entry/payment_entry.py | 6 ++--- .../payment_reconciliation.py | 4 ++-- .../pos_closing_entry/pos_closing_entry.py | 6 +++-- .../doctype/pos_invoice/pos_invoice.py | 4 +++- .../process_payment_reconciliation.py | 6 ++--- .../purchase_invoice/purchase_invoice.py | 2 +- .../doctype/sales_invoice/sales_invoice.py | 22 +++++++++-------- erpnext/accounts/general_ledger.py | 10 ++++---- erpnext/accounts/party.py | 8 ++++--- .../accounts_receivable.py | 5 ++-- .../accounts/report/financial_statements.py | 4 ++-- .../report/general_ledger/general_ledger.py | 6 ++--- .../tax_withholding_details.py | 2 +- .../tds_computation_summary.py | 2 +- .../report/trial_balance/trial_balance.py | 4 ++-- .../trial_balance_for_party.py | 2 +- erpnext/accounts/utils.py | 4 ++-- erpnext/assets/doctype/asset/depreciation.py | 6 ++--- .../deppreciation_schedule_controller.py | 2 +- .../depreciation_methods.py | 2 +- erpnext/controllers/accounts_controller.py | 24 +++++++++---------- erpnext/controllers/buying_controller.py | 6 ++--- erpnext/controllers/queries.py | 2 +- erpnext/controllers/selling_controller.py | 10 ++++---- erpnext/controllers/status_updater.py | 6 ++--- erpnext/controllers/stock_controller.py | 14 +++++------ .../controllers/subcontracting_controller.py | 2 +- erpnext/controllers/taxes_and_totals.py | 4 ++-- erpnext/projects/doctype/project/project.py | 2 +- erpnext/selling/doctype/customer/customer.py | 2 +- .../selling/doctype/quotation/quotation.py | 2 +- .../doctype/sales_order/sales_order.py | 24 ++++++++++--------- .../customer_credit_balance.py | 2 +- erpnext/startup/boot.py | 12 +++++----- erpnext/stock/doctype/batch/batch.py | 6 ++--- .../doctype/delivery_note/delivery_note.py | 6 ++--- erpnext/stock/doctype/item/item.py | 20 +++++++++------- .../stock/doctype/packed_item/packed_item.py | 4 ++-- erpnext/stock/doctype/pick_list/pick_list.py | 4 ++-- .../stock/doctype/price_list/price_list.py | 2 +- .../purchase_receipt/purchase_receipt.py | 8 +++---- .../serial_and_batch_bundle.py | 6 +++-- .../stock/doctype/stock_entry/stock_entry.py | 8 +++---- .../stock_ledger_entry/stock_ledger_entry.py | 2 +- .../stock_reservation_entry.py | 10 ++++---- erpnext/stock/get_item_details.py | 6 ++--- erpnext/stock/serial_batch_bundle.py | 16 ++++++++----- erpnext/stock/stock_balance.py | 2 +- erpnext/stock/utils.py | 2 +- erpnext/utilities/transaction_base.py | 2 +- 55 files changed, 177 insertions(+), 156 deletions(-) diff --git a/erpnext/accounts/deferred_revenue.py b/erpnext/accounts/deferred_revenue.py index 77607f12c9f..15b040669e8 100644 --- a/erpnext/accounts/deferred_revenue.py +++ b/erpnext/accounts/deferred_revenue.py @@ -317,7 +317,7 @@ def get_already_booked_amount(doc, item): def book_deferred_income_or_expense(doc, deferred_process, posting_date=None): enable_check = "enable_deferred_revenue" if doc.doctype == "Sales Invoice" else "enable_deferred_expense" - accounts_frozen_upto = frappe.get_settings("Accounts Settings", "acc_frozen_upto") + accounts_frozen_upto = frappe.get_single_value("Accounts Settings", "acc_frozen_upto") def _book_deferred_revenue_or_expense( item, diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 53a1309d2c8..b9b4304f519 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -92,7 +92,7 @@ class Account(NestedSet): super().on_update() def onload(self): - frozen_accounts_modifier = frappe.get_settings("Accounts Settings", "frozen_accounts_modifier") + frozen_accounts_modifier = frappe.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/bank_transaction/auto_match_party.py b/erpnext/accounts/doctype/bank_transaction/auto_match_party.py index e8ffe2d63ef..b6b24be368d 100644 --- a/erpnext/accounts/doctype/bank_transaction/auto_match_party.py +++ b/erpnext/accounts/doctype/bank_transaction/auto_match_party.py @@ -25,7 +25,7 @@ class AutoMatchParty: deposit=self.deposit, ).match() - fuzzy_matching_enabled = frappe.get_settings("Accounts Settings", "enable_fuzzy_matching") + fuzzy_matching_enabled = frappe.get_single_value("Accounts Settings", "enable_fuzzy_matching") if not result and fuzzy_matching_enabled: result = AutoMatchbyPartyNameDescription( bank_party_name=self.bank_party_name, description=self.description, deposit=self.deposit diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py index a049aeb8720..deea543aa86 100644 --- a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py +++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py @@ -121,7 +121,7 @@ class BankTransaction(Document): self.allocate_payment_entries() self.set_status() - if frappe.get_settings("Accounts Settings", "enable_party_matching"): + if frappe.get_single_value("Accounts Settings", "enable_party_matching"): self.auto_set_party() def before_update_after_submit(self): diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 4b33707478f..1f64ac08919 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -1171,7 +1171,7 @@ class JournalEntry(AccountsController): def make_gl_entries(self, cancel=0, adv_adj=0): from erpnext.accounts.general_ledger import make_gl_entries - merge_entries = frappe.get_settings("Accounts Settings", "merge_similar_account_heads") + merge_entries = frappe.get_single_value("Accounts Settings", "merge_similar_account_heads") gl_map = self.build_gl_map() if self.voucher_type in ("Deferred Revenue", "Deferred Expense"): diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 8719c05feb4..efa32a5b189 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -2969,7 +2969,7 @@ def get_payment_entry( created_from_payment_request=False, ): doc = frappe.get_doc(dt, dn) - over_billing_allowance = frappe.get_settings("Accounts Settings", "over_billing_allowance") + over_billing_allowance = frappe.get_single_value("Accounts Settings", "over_billing_allowance") if dt in ("Sales Order", "Purchase Order") and flt(doc.per_billed, 2) >= (100.0 + over_billing_allowance): frappe.throw(_("Can only make payment against unbilled {0}").format(_(dt))) @@ -3109,7 +3109,7 @@ def get_payment_entry( if party_account and bank: if discount_amount: base_total_discount_loss = 0 - if frappe.get_settings("Accounts Settings", "book_tax_discount_loss"): + if frappe.get_single_value("Accounts Settings", "book_tax_discount_loss"): base_total_discount_loss = split_early_payment_discount_loss(pe, doc, valid_discounts) set_pending_discount_loss( @@ -3463,7 +3463,7 @@ def set_pending_discount_loss(pe, doc, discount_amount, base_total_discount_loss # If tax loss booking is enabled, pending loss will be rounding loss. # Otherwise it will be the total discount loss. - book_tax_loss = frappe.get_settings("Accounts Settings", "book_tax_discount_loss") + book_tax_loss = frappe.get_single_value("Accounts Settings", "book_tax_discount_loss") account_type = "round_off_account" if book_tax_loss else "default_discount_account" pe.append( diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index 8632cbe666c..2719d11e050 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -407,7 +407,7 @@ class PaymentReconciliation(Document): @frappe.whitelist() def is_auto_process_enabled(self): - return frappe.get_settings("Accounts Settings", "auto_reconcile_payments") + return frappe.get_single_value("Accounts Settings", "auto_reconcile_payments") @frappe.whitelist() def calculate_difference_on_allocation_change(self, payment_entry, invoice, allocated_amount): @@ -532,7 +532,7 @@ class PaymentReconciliation(Document): @frappe.whitelist() def reconcile(self): - if frappe.get_settings("Accounts Settings", "auto_reconcile_payments"): + if frappe.get_single_value("Accounts Settings", "auto_reconcile_payments"): running_doc = is_any_doc_running( dict( company=self.company, diff --git a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py index f44d40a7495..0d3724a4bb0 100644 --- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py +++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py @@ -60,7 +60,9 @@ class POSClosingEntry(StatusUpdater): if frappe.db.get_value("POS Opening Entry", self.pos_opening_entry, "status") != "Open": frappe.throw(_("Selected POS Opening Entry should be open."), title=_("Invalid Opening Entry")) - self.is_pos_using_sales_invoice = frappe.get_settings("Accounts Settings", "use_sales_invoice_in_pos") + self.is_pos_using_sales_invoice = frappe.get_single_value( + "Accounts Settings", "use_sales_invoice_in_pos" + ) if self.is_pos_using_sales_invoice == 0: self.validate_duplicate_pos_invoices() @@ -299,7 +301,7 @@ def make_closing_entry_from_opening(opening_entry): closing_entry.net_total = 0 closing_entry.total_quantity = 0 - is_pos_using_sales_invoice = frappe.get_settings("Accounts Settings", "use_sales_invoice_in_pos") + is_pos_using_sales_invoice = frappe.get_single_value("Accounts Settings", "use_sales_invoice_in_pos") pos_invoices = ( get_pos_invoices( diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py index 2245085d884..dfb06bc6c9a 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py @@ -424,7 +424,9 @@ class POSInvoice(SalesInvoice): ) def validate_is_pos_using_sales_invoice(self): - self.is_pos_using_sales_invoice = frappe.get_settings("Accounts Settings", "use_sales_invoice_in_pos") + self.is_pos_using_sales_invoice = frappe.get_single_value( + "Accounts Settings", "use_sales_invoice_in_pos" + ) if self.is_pos_using_sales_invoice and not self.is_return: frappe.throw(_("Sales Invoice mode is activated in POS. Please create Sales Invoice instead.")) diff --git a/erpnext/accounts/doctype/process_payment_reconciliation/process_payment_reconciliation.py b/erpnext/accounts/doctype/process_payment_reconciliation/process_payment_reconciliation.py index dc67f48c128..95c6308ec9b 100644 --- a/erpnext/accounts/doctype/process_payment_reconciliation/process_payment_reconciliation.py +++ b/erpnext/accounts/doctype/process_payment_reconciliation/process_payment_reconciliation.py @@ -142,7 +142,7 @@ def trigger_job_for_doc(docname: str | None = None): if not docname: return - if not frappe.get_settings("Accounts Settings", "auto_reconcile_payments"): + if not frappe.get_single_value("Accounts Settings", "auto_reconcile_payments"): frappe.throw( _("Auto Reconciliation of Payments has been disabled. Enable it through {0}").format( get_link_to_form("Accounts Settings", "Accounts Settings") @@ -190,7 +190,7 @@ def trigger_reconciliation_for_queued_docs(): Will be called from Cron Job Fetch queued docs and start reconciliation process for each one """ - if not frappe.get_settings("Accounts Settings", "auto_reconcile_payments"): + if not frappe.get_single_value("Accounts Settings", "auto_reconcile_payments"): frappe.msgprint( _("Auto Reconciliation of Payments has been disabled. Enable it through {0}").format( get_link_to_form("Accounts Settings", "Accounts Settings") @@ -210,7 +210,7 @@ def trigger_reconciliation_for_queued_docs(): docs_to_trigger = [] unique_filters = set() - queue_size = frappe.get_settings("Accounts Settings", "reconciliation_queue_size") or 5 + queue_size = frappe.get_single_value("Accounts Settings", "reconciliation_queue_size") or 5 fields = ["company", "party_type", "party", "receivable_payable_account", "default_advance_account"] diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 76585783afb..a9eb75b7260 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -1729,7 +1729,7 @@ class PurchaseInvoice(BuyingController): frappe.throw(_("Supplier Invoice Date cannot be greater than Posting Date")) if self.bill_no: - if cint(frappe.get_settings("Accounts Settings", "check_supplier_invoice_uniqueness")): + if cint(frappe.get_single_value("Accounts Settings", "check_supplier_invoice_uniqueness")): fiscal_year = get_fiscal_year(self.posting_date, company=self.company, as_dict=True) pi = frappe.db.sql( diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 4e75d92306e..c4c8f8c7d4d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -495,7 +495,7 @@ class SalesInvoice(SellingController): self.update_time_sheet(self.name) - if frappe.get_settings("Selling Settings", "sales_update_frequency") == "Each Transaction": + if frappe.get_single_value("Selling Settings", "sales_update_frequency") == "Each Transaction": update_company_current_month_sales(self.company) self.update_project() update_linked_doc(self.doctype, self.name, self.inter_company_invoice_reference) @@ -611,7 +611,7 @@ class SalesInvoice(SellingController): if self.coupon_code: update_coupon_code_count(self.coupon_code, "cancelled") - if frappe.get_settings("Selling Settings", "sales_update_frequency") == "Each Transaction": + if frappe.get_single_value("Selling Settings", "sales_update_frequency") == "Each Transaction": update_company_current_month_sales(self.company) self.update_project() if not self.is_return and not self.is_consolidated and self.loyalty_program: @@ -1016,7 +1016,7 @@ class SalesInvoice(SellingController): ) if ( - cint(frappe.get_settings("Selling Settings", "maintain_same_sales_rate")) + cint(frappe.get_single_value("Selling Settings", "maintain_same_sales_rate")) and not self.is_return and not self.is_internal_customer ): @@ -1063,7 +1063,7 @@ class SalesInvoice(SellingController): "Delivery Note": ["dn_required", "update_stock"], } for key, value in prev_doc_field_map.items(): - if frappe.get_settings("Selling Settings", value[0]) == "Yes": + if frappe.get_single_value("Selling Settings", value[0]) == "Yes": if frappe.get_value("Customer", self.customer, value[0]): continue @@ -1096,7 +1096,9 @@ class SalesInvoice(SellingController): if self.is_created_using_pos and not self.pos_profile: frappe.throw(_("POS Profile is mandatory to mark this invoice as POS Transaction.")) - self.is_pos_using_sales_invoice = frappe.get_settings("Accounts Settings", "use_sales_invoice_in_pos") + self.is_pos_using_sales_invoice = frappe.get_single_value( + "Accounts Settings", "use_sales_invoice_in_pos" + ) if not self.is_pos_using_sales_invoice and not self.is_return: frappe.throw(_("Transactions using Sales Invoice in POS are disabled.")) @@ -1466,7 +1468,7 @@ class SalesInvoice(SellingController): def make_tax_gl_entries(self, gl_entries): enable_discount_accounting = cint( - frappe.get_settings("Selling Settings", "enable_discount_accounting") + frappe.get_single_value("Selling Settings", "enable_discount_accounting") ) for tax in self.get("taxes"): @@ -1516,7 +1518,7 @@ class SalesInvoice(SellingController): def make_item_gl_entries(self, gl_entries): # income account gl entries enable_discount_accounting = cint( - frappe.get_settings("Selling Settings", "enable_discount_accounting") + frappe.get_single_value("Selling Settings", "enable_discount_accounting") ) for item in self.get("items"): @@ -1591,7 +1593,7 @@ class SalesInvoice(SellingController): def enable_discount_accounting(self): if not hasattr(self, "_enable_discount_accounting"): self._enable_discount_accounting = cint( - frappe.get_settings("Selling Settings", "enable_discount_accounting") + frappe.get_single_value("Selling Settings", "enable_discount_accounting") ) return self._enable_discount_accounting @@ -1633,7 +1635,7 @@ class SalesInvoice(SellingController): def make_pos_gl_entries(self, gl_entries): if cint(self.is_pos): skip_change_gl_entries = not cint( - frappe.get_settings("Accounts Settings", "post_change_gl_entries") + frappe.get_single_value("Accounts Settings", "post_change_gl_entries") ) for payment_mode in self.payments: @@ -2918,7 +2920,7 @@ def check_if_return_invoice_linked_with_payment_entry(self): # If a Return invoice is linked with payment entry along with other invoices, # the cancellation of the Return causes allocated amount to be greater than paid - if not frappe.get_settings("Accounts Settings", "unlink_payment_on_cancellation_of_invoice"): + if not frappe.get_single_value("Accounts Settings", "unlink_payment_on_cancellation_of_invoice"): return payment_entries = [] diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py index f2d0c6159f1..24685bfabe9 100644 --- a/erpnext/accounts/general_ledger.py +++ b/erpnext/accounts/general_ledger.py @@ -35,7 +35,7 @@ def make_gl_entries( ): if gl_map: if ( - frappe.get_settings("Accounts Settings", "use_new_budget_controller") + frappe.get_single_value("Accounts Settings", "use_new_budget_controller") and gl_map[0].voucher_type != "Period Closing Voucher" ): bud_val = BudgetValidation(gl_map=gl_map) @@ -743,9 +743,11 @@ def check_freezing_date(posting_date, adv_adj=False): Hence stop admin to bypass if accounts are freezed """ if not adv_adj: - acc_frozen_upto = frappe.get_settings("Accounts Settings", "acc_frozen_upto") + acc_frozen_upto = frappe.get_single_value("Accounts Settings", "acc_frozen_upto") if acc_frozen_upto: - frozen_accounts_modifier = frappe.get_settings("Accounts Settings", "frozen_accounts_modifier") + frozen_accounts_modifier = frappe.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" ): @@ -823,4 +825,4 @@ def validate_allowed_dimensions(gl_entry, dimension_filter_map): def is_immutable_ledger_enabled(): - return frappe.get_settings("Accounts Settings", "enable_immutable_ledger") + return frappe.get_single_value("Accounts Settings", "enable_immutable_ledger") diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index eff254c1cff..2feaaf7e8e1 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -689,7 +689,7 @@ def validate_due_date_with_template(posting_date, due_date, bill_date, template_ return if default_due_date != posting_date and getdate(due_date) > getdate(default_due_date): - if frappe.get_settings("Accounts Settings", "credit_controller") in frappe.get_roles(): + if frappe.get_single_value("Accounts Settings", "credit_controller") in frappe.get_roles(): party_type = "supplier" if doctype == "Purchase Invoice" else "customer" msgprint( @@ -703,7 +703,9 @@ def validate_due_date_with_template(posting_date, due_date, bill_date, template_ @frappe.whitelist() def get_address_tax_category(tax_category=None, billing_address=None, shipping_address=None): - addr_tax_category_from = frappe.get_settings("Accounts Settings", "determine_address_tax_category_from") + addr_tax_category_from = frappe.get_single_value( + "Accounts Settings", "determine_address_tax_category_from" + ) if addr_tax_category_from == "Shipping Address": if shipping_address: tax_category = frappe.db.get_value("Address", shipping_address, "tax_category") or tax_category @@ -801,7 +803,7 @@ def validate_party_frozen_disabled(party_type, party_name): if party.disabled: frappe.throw(_("{0} {1} is disabled").format(party_type, party_name), PartyDisabled) elif party.get("is_frozen"): - frozen_accounts_modifier = frappe.get_settings( + frozen_accounts_modifier = frappe.get_single_value( "Accounts Settings", "frozen_accounts_modifier" ) if frozen_accounts_modifier not in frappe.get_roles(): diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index a30c0b463af..412d0903e7a 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -57,7 +57,8 @@ class ReceivablePayableReport: self.ranges = [num.strip() for num in self.filters.range.split(",") if num.strip().isdigit()] self.range_numbers = [num for num in range(1, len(self.ranges) + 2)] self.ple_fetch_method = ( - frappe.get_settings("Accounts Settings", "receivable_payable_fetch_method") or "Buffered Cursor" + frappe.get_single_value("Accounts Settings", "receivable_payable_fetch_method") + or "Buffered Cursor" ) # Fail Safe def run(self, args): @@ -848,7 +849,7 @@ class ReceivablePayableReport: ) if self.filters.get("show_remarks"): - if remarks_length := frappe.get_settings( + if remarks_length := frappe.get_single_value( "Accounts Settings", "receivable_payable_remarks_length" ): query = query.select(Substring(ple.remarks, 1, remarks_length).as_("remarks")) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index b64bd47b5d8..5b9685de3c6 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -435,7 +435,7 @@ def set_gl_entries_by_account( gl_entries = [] # For balance sheet - ignore_closing_balances = frappe.get_settings("Accounts Settings", "ignore_account_closing_balance") + ignore_closing_balances = frappe.get_single_value("Accounts Settings", "ignore_account_closing_balance") if not from_date and not ignore_closing_balances: last_period_closing_voucher = frappe.db.get_all( "Period Closing Voucher", @@ -517,7 +517,7 @@ def get_accounting_entries( .where(gl_entry.company == filters.company) ) - ignore_is_opening = frappe.get_settings("Accounts Settings", "ignore_is_opening_check_for_reporting") + ignore_is_opening = frappe.get_single_value("Accounts Settings", "ignore_is_opening_check_for_reporting") if doctype == "GL Entry": query = query.select(gl_entry.posting_date, gl_entry.is_opening, gl_entry.fiscal_year) diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index 20a92f3f626..71fa184b914 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -163,7 +163,7 @@ def get_gl_entries(filters, accounting_dimensions): credit_in_account_currency """ if filters.get("show_remarks"): - if remarks_length := frappe.get_settings("Accounts Settings", "general_ledger_remarks_length"): + if remarks_length := frappe.get_single_value("Accounts Settings", "general_ledger_remarks_length"): select_fields += f",substr(remarks, 1, {remarks_length}) as 'remarks'" else: select_fields += """,remarks""" @@ -218,7 +218,7 @@ def get_gl_entries(filters, accounting_dimensions): def get_conditions(filters): conditions = [] - ignore_is_opening = frappe.get_settings("Accounts Settings", "ignore_is_opening_check_for_reporting") + ignore_is_opening = frappe.get_single_value("Accounts Settings", "ignore_is_opening_check_for_reporting") if filters.get("account"): filters.account = get_accounts_with_children(filters.account) @@ -478,7 +478,7 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map): if filters.get("show_net_values_in_party_account"): account_type_map = get_account_type_map(filters.get("company")) - immutable_ledger = frappe.get_settings("Accounts Settings", "enable_immutable_ledger") + immutable_ledger = frappe.get_single_value("Accounts Settings", "enable_immutable_ledger") def update_value_in_dict(data, key, gle): data[key].debit += gle.debit diff --git a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py index f51e4152e56..02dec9686c5 100644 --- a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py +++ b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py @@ -9,7 +9,7 @@ from frappe.utils import getdate def execute(filters=None): if filters.get("party_type") == "Customer": - party_naming_by = frappe.get_settings("Selling Settings", "cust_master_name") + party_naming_by = frappe.get_single_value("Selling Settings", "cust_master_name") else: party_naming_by = frappe.db.get_single_value("Buying Settings", "supp_master_name") diff --git a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py index 6b49f12a524..2253b3631c1 100644 --- a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py +++ b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py @@ -10,7 +10,7 @@ from erpnext.accounts.utils import get_fiscal_year def execute(filters=None): if filters.get("party_type") == "Customer": - party_naming_by = frappe.get_settings("Selling Settings", "cust_master_name") + party_naming_by = frappe.get_single_value("Selling Settings", "cust_master_name") else: party_naming_by = frappe.db.get_single_value("Buying Settings", "supp_master_name") diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py index b01f3315b3f..9524db3add6 100644 --- a/erpnext/accounts/report/trial_balance/trial_balance.py +++ b/erpnext/accounts/report/trial_balance/trial_balance.py @@ -89,7 +89,7 @@ def get_data(filters): ) company_currency = filters.presentation_currency or erpnext.get_company_currency(filters.company) - ignore_is_opening = frappe.get_settings("Accounts Settings", "ignore_is_opening_check_for_reporting") + ignore_is_opening = frappe.get_single_value("Accounts Settings", "ignore_is_opening_check_for_reporting") if not accounts: return None @@ -146,7 +146,7 @@ def get_rootwise_opening_balances(filters, report_type, ignore_is_opening): gle = [] last_period_closing_voucher = "" - ignore_closing_balances = frappe.get_settings("Accounts Settings", "ignore_account_closing_balance") + ignore_closing_balances = frappe.get_single_value("Accounts Settings", "ignore_account_closing_balance") if not ignore_closing_balances: last_period_closing_voucher = frappe.db.get_all( diff --git a/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.py b/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.py index d2587a78572..95484bb190b 100644 --- a/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.py +++ b/erpnext/accounts/report/trial_balance_for_party/trial_balance_for_party.py @@ -256,7 +256,7 @@ def is_party_name_visible(filters): if filters.get("party_type") in ["Customer", "Supplier"]: if filters.get("party_type") == "Customer": - party_naming_by = frappe.get_settings("Selling Settings", "cust_master_name") + party_naming_by = frappe.get_single_value("Selling Settings", "cust_master_name") else: party_naming_by = frappe.db.get_single_value("Buying Settings", "supp_master_name") diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index efd36325a34..9fe24857672 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -886,7 +886,7 @@ def cancel_common_party_journal(self): if self.doctype not in ["Sales Invoice", "Purchase Invoice"]: return - if not frappe.get_settings("Accounts Settings", "enable_common_party_accounting"): + if not frappe.get_single_value("Accounts Settings", "enable_common_party_accounting"): return party_link = self.get_common_party_link() @@ -2312,7 +2312,7 @@ def run_ledger_health_checks(): def sync_auto_reconcile_config(auto_reconciliation_job_trigger: int = 15): - auto_reconciliation_job_trigger = auto_reconciliation_job_trigger or frappe.get_settings( + auto_reconciliation_job_trigger = auto_reconciliation_job_trigger or frappe.get_single_value( "Accounts Settings", "auto_reconciliation_job_trigger" ) method = "erpnext.accounts.doctype.process_payment_reconciliation.process_payment_reconciliation.trigger_reconciliation_for_queued_docs" diff --git a/erpnext/assets/doctype/asset/depreciation.py b/erpnext/assets/doctype/asset/depreciation.py index 92546235780..037dc070255 100644 --- a/erpnext/assets/doctype/asset/depreciation.py +++ b/erpnext/assets/doctype/asset/depreciation.py @@ -35,7 +35,7 @@ from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_sched def post_depreciation_entries(date=None): # Return if automatic booking of asset depreciation is disabled - if not cint(frappe.get_settings("Accounts Settings", "book_asset_depreciation_entry_automatically")): + if not cint(frappe.get_single_value("Accounts Settings", "book_asset_depreciation_entry_automatically")): return date = date or today() @@ -112,12 +112,12 @@ def make_depreciation_entry_on_disposal(asset_doc, disposal_date=None): def get_acc_frozen_upto(): - acc_frozen_upto = frappe.get_settings("Accounts Settings", "acc_frozen_upto") + acc_frozen_upto = frappe.get_single_value("Accounts Settings", "acc_frozen_upto") if not acc_frozen_upto: return - frozen_accounts_modifier = frappe.get_settings("Accounts Settings", "frozen_accounts_modifier") + frozen_accounts_modifier = frappe.get_single_value("Accounts Settings", "frozen_accounts_modifier") if frozen_accounts_modifier not in frappe.get_roles() or frappe.session.user == "Administrator": return getdate(acc_frozen_upto) diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/deppreciation_schedule_controller.py b/erpnext/assets/doctype/asset_depreciation_schedule/deppreciation_schedule_controller.py index 278b44444d4..3e294bea362 100644 --- a/erpnext/assets/doctype/asset_depreciation_schedule/deppreciation_schedule_controller.py +++ b/erpnext/assets/doctype/asset_depreciation_schedule/deppreciation_schedule_controller.py @@ -251,7 +251,7 @@ class DepreciationScheduleController(StraightLineMethod, WDVMethod): return depr_booked_for_months def get_total_pending_days_or_years(self): - if cint(frappe.get_settings("Accounts Settings", "calculate_depr_using_total_days")): + if cint(frappe.get_single_value("Accounts Settings", "calculate_depr_using_total_days")): last_depr_date = self.get_last_booked_depreciation_date() if last_depr_date: self.total_pending_days = date_diff(self.final_schedule_date, last_depr_date) - 1 diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/depreciation_methods.py b/erpnext/assets/doctype/asset_depreciation_schedule/depreciation_methods.py index f6535221671..f6dcb144c1e 100644 --- a/erpnext/assets/doctype/asset_depreciation_schedule/depreciation_methods.py +++ b/erpnext/assets/doctype/asset_depreciation_schedule/depreciation_methods.py @@ -38,7 +38,7 @@ class StraightLineMethod(Document): return daily_depr_amount * total_depreciable_days def get_daily_depr_amount(self): - if cint(frappe.get_settings("Accounts Settings", "calculate_depr_using_total_days")): + if cint(frappe.get_single_value("Accounts Settings", "calculate_depr_using_total_days")): return self.depreciable_value / self.total_pending_days else: yearly_depr_amount = self.depreciable_value / self.total_pending_years diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 7970b43c7f0..cd1bcf5f489 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -403,7 +403,7 @@ class AccountsController(TransactionBase): self.remove_serial_and_batch_bundle() # delete sl and gl entries on deletion of transaction - if frappe.get_settings("Accounts Settings", "delete_linked_ledger_entries"): + if frappe.get_single_value("Accounts Settings", "delete_linked_ledger_entries"): # delete linked exchange gain/loss journal delete_exchange_gain_loss_journal(self) @@ -744,7 +744,7 @@ class AccountsController(TransactionBase): frappe.throw(_(msg), title=_("Internal Transfer Reference Missing")) def validate_internal_transaction(self): - if not cint(frappe.get_settings("Accounts Settings", "maintain_same_internal_transaction_rate")): + if not cint(frappe.get_single_value("Accounts Settings", "maintain_same_internal_transaction_rate")): return doctypes_list = ["Sales Order", "Sales Invoice", "Purchase Order", "Purchase Invoice"] @@ -1141,7 +1141,7 @@ class AccountsController(TransactionBase): return True def set_taxes_and_charges(self): - if frappe.get_settings("Accounts Settings", "add_taxes_from_item_tax_template"): + if frappe.get_single_value("Accounts Settings", "add_taxes_from_item_tax_template"): if hasattr(self, "taxes_and_charges") and not self.get("taxes") and not self.get("is_pos"): if tax_master_doctype := self.meta.get_field("taxes_and_charges").options: self.append_taxes_from_master(tax_master_doctype) @@ -1154,7 +1154,7 @@ class AccountsController(TransactionBase): self.extend("taxes", get_taxes_and_charges(tax_master_doctype, self.get("taxes_and_charges"))) def append_taxes_from_item_tax_template(self): - if not frappe.get_settings("Accounts Settings", "add_taxes_from_item_tax_template"): + if not frappe.get_single_value("Accounts Settings", "add_taxes_from_item_tax_template"): return for row in self.items: @@ -1495,7 +1495,7 @@ class AccountsController(TransactionBase): return res def is_inclusive_tax(self): - is_inclusive = cint(frappe.get_settings("Accounts Settings", "show_inclusive_tax_in_print")) + is_inclusive = cint(frappe.get_single_value("Accounts Settings", "show_inclusive_tax_in_print")) if is_inclusive: is_inclusive = 0 @@ -1505,7 +1505,7 @@ class AccountsController(TransactionBase): return is_inclusive def should_show_taxes_as_table_in_print(self): - return cint(frappe.get_settings("Accounts Settings", "show_taxes_as_table_in_print")) + return cint(frappe.get_single_value("Accounts Settings", "show_taxes_as_table_in_print")) def validate_advance_entries(self): order_field = "sales_order" if self.doctype == "Sales Invoice" else "purchase_order" @@ -1882,11 +1882,11 @@ class AccountsController(TransactionBase): cancel_exchange_gain_loss_journal(self) cancel_common_party_journal(self) - if frappe.get_settings("Accounts Settings", "unlink_payment_on_cancellation_of_invoice"): + if frappe.get_single_value("Accounts Settings", "unlink_payment_on_cancellation_of_invoice"): unlink_ref_doc_from_payment_entries(self) elif self.doctype in ["Sales Order", "Purchase Order"]: - if frappe.get_settings("Accounts Settings", "unlink_advance_payment_on_cancelation_of_order"): + if frappe.get_single_value("Accounts Settings", "unlink_advance_payment_on_cancelation_of_order"): unlink_ref_doc_from_payment_entries(self) if self.doctype == "Sales Order": @@ -1962,7 +1962,7 @@ class AccountsController(TransactionBase): def make_discount_gl_entries(self, gl_entries): enable_discount_accounting = cint( - frappe.get_settings("Selling Settings", "enable_discount_accounting") + frappe.get_single_value("Selling Settings", "enable_discount_accounting") ) if enable_discount_accounting: @@ -2444,7 +2444,7 @@ class AccountsController(TransactionBase): grand_total = grand_total - flt(self.write_off_amount) po_or_so, doctype, fieldname = self.get_order_details() automatically_fetch_payment_terms = cint( - frappe.get_settings("Accounts Settings", "automatically_fetch_payment_terms") + frappe.get_single_value("Accounts Settings", "automatically_fetch_payment_terms") ) if self.get("total_advance"): @@ -2727,7 +2727,7 @@ class AccountsController(TransactionBase): if not is_invoice: return - if frappe.get_settings("Accounts Settings", "enable_common_party_accounting"): + if frappe.get_single_value("Accounts Settings", "enable_common_party_accounting"): party_link = self.get_common_party_link() if party_link and self.outstanding_amount: self.create_advance_and_reconcile(party_link) @@ -3513,7 +3513,7 @@ def set_child_tax_template_and_map(item, child_item, parent_doc): def add_taxes_from_tax_template(child_item, parent_doc, db_insert=True): - add_taxes_from_item_tax_template = frappe.get_settings( + add_taxes_from_item_tax_template = frappe.get_single_value( "Accounts Settings", "add_taxes_from_item_tax_template" ) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index f8c96f3d466..830b6b32cff 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -75,7 +75,7 @@ class BuyingController(SubcontractingController): if self.docstatus == 1 and self.doctype in ["Purchase Receipt", "Purchase Invoice"]: self.set_onload( "allow_to_make_qc_after_submission", - frappe.get_settings( + frappe.get_single_value( "Stock Settings", "allow_to_make_quality_inspection_after_purchase_or_delivery" ), ) @@ -545,7 +545,7 @@ class BuyingController(SubcontractingController): item.bom = None def set_qty_as_per_stock_uom(self): - allow_to_edit_stock_qty = frappe.get_settings( + allow_to_edit_stock_qty = frappe.get_single_value( "Stock Settings", "allow_to_edit_stock_uom_qty_for_purchase" ) @@ -842,7 +842,7 @@ class BuyingController(SubcontractingController): self.update_fixed_asset(field, delete_asset=True) def validate_budget(self): - if frappe.get_settings("Accounts Settings", "use_new_budget_controller"): + if frappe.get_single_value("Accounts Settings", "use_new_budget_controller"): from erpnext.controllers.budget_controller import BudgetValidation val = BudgetValidation(doc=self) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 44eebf8981c..bb8477be560 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -948,7 +948,7 @@ def get_filtered_child_rows(doctype, txt, searchfield, start, page_len, filters) @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs def get_item_uom_query(doctype, txt, searchfield, start, page_len, filters): - if frappe.get_settings("Stock Settings", "allow_uom_with_conversion_rate_defined_in_item"): + if frappe.get_single_value("Stock Settings", "allow_uom_with_conversion_rate_defined_in_item"): query_filters = {"parent": filters.get("item_code")} if txt: diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 77e54c5747b..013953e9818 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -38,7 +38,7 @@ class SellingController(StockController): if self.docstatus == 1 and self.doctype in ["Delivery Note", "Sales Invoice"]: self.set_onload( "allow_to_make_qc_after_submission", - frappe.get_settings( + frappe.get_single_value( "Stock Settings", "allow_to_make_quality_inspection_after_purchase_or_delivery" ), ) @@ -224,7 +224,7 @@ class SellingController(StockController): frappe.throw(_("Maximum discount for Item {0} is {1}%").format(d.item_code, discount)) def set_qty_as_per_stock_uom(self): - allow_to_edit_stock_qty = frappe.get_settings( + allow_to_edit_stock_qty = frappe.get_single_value( "Stock Settings", "allow_to_edit_stock_uom_qty_for_sales" ) @@ -255,7 +255,7 @@ class SellingController(StockController): title=_("Invalid Selling Price"), ) - if self.get("is_return") or not frappe.get_settings("Selling Settings", "validate_selling_price"): + if self.get("is_return") or not frappe.get_single_value("Selling Settings", "validate_selling_price"): return is_internal_customer = self.get("is_internal_customer") @@ -715,7 +715,7 @@ class SellingController(StockController): def validate_for_duplicate_items(self): check_list, chk_dupl_itm = [], [] - if cint(frappe.get_settings("Selling Settings", "allow_multiple_items")): + if cint(frappe.get_single_value("Selling Settings", "allow_multiple_items")): return if self.doctype == "Sales Invoice" and self.is_consolidated: return @@ -958,7 +958,7 @@ def get_serial_and_batch_bundle(child, parent, delivery_note_child=None): if child.get("use_serial_batch_fields"): return - if not frappe.get_settings("Stock Settings", "auto_create_serial_and_batch_bundle_for_outward"): + if not frappe.get_single_value("Stock Settings", "auto_create_serial_and_batch_bundle_for_outward"): return item_details = frappe.db.get_value("Item", child.item_code, ["has_serial_no", "has_batch_no"], as_dict=1) diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index f98d61f221e..facfff7ded8 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -266,7 +266,7 @@ class StatusUpdater(Document): if hasattr(d, "qty") and d.qty > 0 and self.get("is_return"): frappe.throw(_("For an item {0}, quantity must be negative number").format(d.item_code)) - if not frappe.get_settings("Selling Settings", "allow_negative_rates_for_items"): + if not frappe.get_single_value("Selling Settings", "allow_negative_rates_for_items"): if hasattr(d, "item_code") and hasattr(d, "rate") and flt(d.rate) < 0: frappe.throw( _( @@ -336,10 +336,10 @@ class StatusUpdater(Document): qty_or_amount, ) - role_allowed_to_over_deliver_receive = frappe.get_settings( + role_allowed_to_over_deliver_receive = frappe.get_single_value( "Stock Settings", "role_allowed_to_over_deliver_receive" ) - role_allowed_to_over_bill = frappe.get_settings("Accounts Settings", "role_allowed_to_over_bill") + role_allowed_to_over_bill = frappe.get_single_value("Accounts Settings", "role_allowed_to_over_bill") role = role_allowed_to_over_deliver_receive if qty_or_amount == "qty" else role_allowed_to_over_bill overflow_percent = ( diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index e791a2ea329..8fbb832d3be 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -518,7 +518,7 @@ class StockController(AccountsController): ) def set_use_serial_batch_fields(self): - if frappe.get_settings("Stock Settings", "use_serial_batch_fields"): + if frappe.get_single_value("Stock Settings", "use_serial_batch_fields"): for row in self.items: row.use_serial_batch_fields = 1 @@ -1076,7 +1076,7 @@ class StockController(AccountsController): "Purchase Invoice", "Sales Invoice", "Delivery Note", - ] and frappe.get_settings( + ] and frappe.get_single_value( "Stock Settings", "allow_to_make_quality_inspection_after_purchase_or_delivery" ): return @@ -1092,7 +1092,7 @@ class StockController(AccountsController): def validate_qi_submission(self, row): """Check if QI is submitted on row level, during submission""" - action = frappe.get_settings("Stock Settings", "action_if_quality_inspection_is_not_submitted") + action = frappe.get_single_value("Stock Settings", "action_if_quality_inspection_is_not_submitted") qa_docstatus = frappe.db.get_value("Quality Inspection", row.quality_inspection, "docstatus") if qa_docstatus != 1: @@ -1107,7 +1107,7 @@ class StockController(AccountsController): def validate_qi_rejection(self, row): """Check if QI is rejected on row level, during submission""" - action = frappe.get_settings("Stock Settings", "action_if_quality_inspection_is_rejected") + action = frappe.get_single_value("Stock Settings", "action_if_quality_inspection_is_rejected") qa_status = frappe.db.get_value("Quality Inspection", row.quality_inspection, "status") if qa_status == "Rejected": @@ -1206,7 +1206,7 @@ class StockController(AccountsController): item_wise_received_qty = self.get_item_wise_inter_received_qty() precision = frappe.get_precision(self.doctype + " Item", "qty") - over_receipt_allowance = frappe.get_settings("Stock Settings", "over_delivery_receipt_allowance") + over_receipt_allowance = frappe.get_single_value("Stock Settings", "over_delivery_receipt_allowance") parent_doctype = { "Purchase Receipt": "Delivery Note", @@ -1379,7 +1379,7 @@ class StockController(AccountsController): force = True if force or future_sle_exists(args) or repost_required_for_queue(self): - item_based_reposting = frappe.get_settings("Stock Reposting Settings", "item_based_reposting") + item_based_reposting = frappe.get_single_value("Stock Reposting Settings", "item_based_reposting") if item_based_reposting: create_item_wise_repost_entries( voucher_type=self.doctype, @@ -1671,7 +1671,7 @@ def is_reposting_pending(): def future_sle_exists(args, sl_entries=None, allow_force_reposting=True): from erpnext.stock.utils import get_combine_datetime - if allow_force_reposting and frappe.get_settings( + if allow_force_reposting and frappe.get_single_value( "Stock Reposting Settings", "do_reposting_for_each_stock_transaction" ): return True diff --git a/erpnext/controllers/subcontracting_controller.py b/erpnext/controllers/subcontracting_controller.py index 81b803488b7..ada72c24ac5 100644 --- a/erpnext/controllers/subcontracting_controller.py +++ b/erpnext/controllers/subcontracting_controller.py @@ -590,7 +590,7 @@ class SubcontractingController(StockController): rm_obj.reference_name = item_row.name - use_serial_batch_fields = frappe.get_settings("Stock Settings", "use_serial_batch_fields") + use_serial_batch_fields = frappe.get_single_value("Stock Settings", "use_serial_batch_fields") if self.doctype == self.subcontract_data.order_doctype: rm_obj.required_qty = flt(qty, rm_obj.precision("required_qty")) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index f63395c649b..28dad216907 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -28,7 +28,7 @@ class calculate_taxes_and_totals: def __init__(self, doc: Document): self.doc = doc frappe.flags.round_off_applicable_accounts = [] - frappe.flags.round_row_wise_tax = frappe.get_settings("Accounts Settings", "round_row_wise_tax") + frappe.flags.round_row_wise_tax = frappe.get_single_value("Accounts Settings", "round_row_wise_tax") if doc.get("round_off_applicable_accounts_for_tax_withholding"): frappe.flags.round_off_applicable_accounts.append( @@ -1168,7 +1168,7 @@ def get_rounded_tax_amount(itemised_tax, precision): @frappe.whitelist() def get_rounding_tax_settings(): - return frappe.get_settings("Accounts Settings", "round_row_wise_tax") + return frappe.get_single_value("Accounts Settings", "round_row_wise_tax") class init_landed_taxes_and_totals: diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index 64781e0f212..e5d5d02b897 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -680,7 +680,7 @@ def send_project_status_email_to_users(): def update_project_sales_billing(): - sales_update_frequency = frappe.get_settings("Selling Settings", "sales_update_frequency") + sales_update_frequency = frappe.get_single_value("Selling Settings", "sales_update_frequency") if sales_update_frequency == "Each Transaction": return elif sales_update_frequency == "Monthly" and frappe.utils.now_datetime().day != 1: diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index e5a02d55d5f..4fc2dac10e8 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -554,7 +554,7 @@ def check_credit_limit(customer, company, ignore_outstanding_sales_order=False, message += "

" # If not authorized person raise exception - credit_controller_role = frappe.get_settings("Accounts Settings", "credit_controller") + credit_controller_role = frappe.get_single_value("Accounts Settings", "credit_controller") if not credit_controller_role or credit_controller_role not in frappe.get_roles(): # form a list of emails for the credit controller users credit_controller_users = get_users_with_role(credit_controller_role or "Sales Master Manager") diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py index 17a2ff07617..9529cffb364 100644 --- a/erpnext/selling/doctype/quotation/quotation.py +++ b/erpnext/selling/doctype/quotation/quotation.py @@ -167,7 +167,7 @@ class Quotation(SellingController): """ If permitted in settings and any item has 0 qty, the SO has unit price items. """ - if not frappe.get_settings("Selling Settings", "allow_zero_qty_in_quotation"): + if not frappe.get_single_value("Selling Settings", "allow_zero_qty_in_quotation"): return self.has_unit_price_items = any( diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 77a28db827b..2117c7f9b6b 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -195,7 +195,7 @@ class SalesOrder(SellingController): def onload(self) -> None: super().onload() - if frappe.get_settings("Stock Settings", "enable_stock_reservation"): + if frappe.get_single_value("Stock Settings", "enable_stock_reservation"): if self.has_unreserved_stock(): self.set_onload("has_unreserved_stock", True) @@ -246,14 +246,14 @@ class SalesOrder(SellingController): self.enable_auto_reserve_stock() def enable_auto_reserve_stock(self): - if self.is_new() and frappe.get_settings("Stock Settings", "auto_reserve_stock"): + if self.is_new() and frappe.get_single_value("Stock Settings", "auto_reserve_stock"): self.reserve_stock = 1 def set_has_unit_price_items(self): """ If permitted in settings and any item has 0 qty, the SO has unit price items. """ - if not frappe.get_settings("Selling Settings", "allow_zero_qty_in_sales_order"): + if not frappe.get_single_value("Selling Settings", "allow_zero_qty_in_sales_order"): return self.has_unit_price_items = any( @@ -279,7 +279,9 @@ class SalesOrder(SellingController): (self.po_no, self.name, self.customer), ) if so and so[0][0]: - if cint(frappe.get_settings("Selling Settings", "allow_against_multiple_purchase_orders")): + if cint( + frappe.get_single_value("Selling Settings", "allow_against_multiple_purchase_orders") + ): frappe.msgprint( _( "Warning: Sales Order {0} already exists against Customer's Purchase Order {1}" @@ -403,7 +405,7 @@ class SalesOrder(SellingController): } ) - if cint(frappe.get_settings("Selling Settings", "maintain_same_sales_rate")): + if cint(frappe.get_single_value("Selling Settings", "maintain_same_sales_rate")): self.validate_rate_with_reference_doc([["Quotation", "prevdoc_docname", "quotation_item"]]) def update_enquiry_status(self, prevdoc, flag): @@ -481,7 +483,7 @@ class SalesOrder(SellingController): update_coupon_code_count(self.coupon_code, "cancelled") def update_project(self): - if frappe.get_settings("Selling Settings", "sales_update_frequency") != "Each Transaction": + if frappe.get_single_value("Selling Settings", "sales_update_frequency") != "Each Transaction": return if self.project: @@ -631,7 +633,7 @@ class SalesOrder(SellingController): if total_picked_qty and total_qty: per_picked = total_picked_qty / total_qty * 100 - pick_percentage = frappe.get_settings("Stock Settings", "over_picking_allowance") + pick_percentage = frappe.get_single_value("Stock Settings", "over_picking_allowance") if pick_percentage: total_qty += flt(total_qty) * (pick_percentage / 100) @@ -727,7 +729,7 @@ class SalesOrder(SellingController): def validate_reserved_stock(self): """Clean reserved stock flag for non-stock Item""" - enable_stock_reservation = frappe.get_settings("Stock Settings", "enable_stock_reservation") + enable_stock_reservation = frappe.get_single_value("Stock Settings", "enable_stock_reservation") for item in self.items: if item.reserve_stock and (not enable_stock_reservation or not cint(item.is_stock_item)): @@ -813,7 +815,7 @@ def get_list_context(context=None): @frappe.whitelist() def is_enable_cutoff_date_on_bulk_delivery_note_creation(): - return frappe.get_settings("Selling Settings", "enable_cutoff_date_on_bulk_delivery_note_creation") + return frappe.get_single_value("Selling Settings", "enable_cutoff_date_on_bulk_delivery_note_creation") @frappe.whitelist() @@ -1218,7 +1220,7 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False): ) automatically_fetch_payment_terms = cint( - frappe.get_settings("Accounts Settings", "automatically_fetch_payment_terms") + frappe.get_single_value("Accounts Settings", "automatically_fetch_payment_terms") ) if automatically_fetch_payment_terms: doclist.set_payment_schedule() @@ -1859,4 +1861,4 @@ def get_work_order_items(sales_order, for_raw_material_request=0): @frappe.whitelist() def get_stock_reservation_status(): - return frappe.get_settings("Stock Settings", "enable_stock_reservation") + return frappe.get_single_value("Stock Settings", "enable_stock_reservation") 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 24570391224..6813060d414 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 @@ def execute(filters=None): if not filters: filters = {} # Check if customer id is according to naming series or customer name - customer_naming_type = frappe.get_settings("Selling Settings", "cust_master_name") + customer_naming_type = frappe.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 a312d0d5499..8dccac80b88 100644 --- a/erpnext/startup/boot.py +++ b/erpnext/startup/boot.py @@ -15,13 +15,13 @@ def boot_session(bootinfo): if frappe.session["user"] != "Guest": update_page_info(bootinfo) - bootinfo.sysdefaults.territory = frappe.get_settings("Selling Settings", "territory") - bootinfo.sysdefaults.customer_group = frappe.get_settings("Selling Settings", "customer_group") - bootinfo.sysdefaults.use_server_side_reactivity = frappe.get_settings( + bootinfo.sysdefaults.territory = frappe.get_single_value("Selling Settings", "territory") + bootinfo.sysdefaults.customer_group = frappe.get_single_value("Selling Settings", "customer_group") + bootinfo.sysdefaults.use_server_side_reactivity = frappe.get_single_value( "Selling Settings", "use_server_side_reactivity" ) - bootinfo.sysdefaults.allow_stale = cint(frappe.get_settings("Accounts Settings", "allow_stale")) - bootinfo.sysdefaults.over_billing_allowance = frappe.get_settings( + bootinfo.sysdefaults.allow_stale = cint(frappe.get_single_value("Accounts Settings", "allow_stale")) + bootinfo.sysdefaults.over_billing_allowance = frappe.get_single_value( "Accounts Settings", "over_billing_allowance" ) @@ -30,7 +30,7 @@ def boot_session(bootinfo): ) bootinfo.sysdefaults.allow_sales_order_creation_for_expired_quotation = cint( - frappe.get_settings("Selling Settings", "allow_sales_order_creation_for_expired_quotation") + frappe.get_single_value("Selling Settings", "allow_sales_order_creation_for_expired_quotation") ) # if no company, show a dialog box to create a new company diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index 1a0557a5a0a..52af15e158a 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -37,7 +37,7 @@ def batch_uses_naming_series(): Verify if the Batch is to be named using a naming series :return: bool """ - use_naming_series = cint(frappe.get_settings("Stock Settings", "use_naming_series")) + use_naming_series = cint(frappe.get_single_value("Stock Settings", "use_naming_series")) return bool(use_naming_series) @@ -49,7 +49,7 @@ def _get_batch_prefix(): is set to use naming series. :return: The naming series. """ - naming_series_prefix = frappe.get_settings("Stock Settings", "naming_series_prefix") + naming_series_prefix = frappe.get_single_value("Stock Settings", "naming_series_prefix") if not naming_series_prefix: naming_series_prefix = "BATCH-" @@ -160,7 +160,7 @@ class Batch(Document): from erpnext.stock.utils import get_valuation_method if self.is_new(): - if get_valuation_method(self.item) == "Moving Average" and frappe.get_settings( + if get_valuation_method(self.item) == "Moving Average" and frappe.get_single_value( "Stock Settings", "do_not_use_batchwise_valuation" ): self.use_batchwise_valuation = 0 diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index 1a81d34fad1..0c390ce9085 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -247,7 +247,7 @@ class DeliveryNote(SellingController): def so_required(self): """check in manage account if sales order required or not""" - if frappe.get_settings("Selling Settings", "so_required") == "Yes": + if frappe.get_single_value("Selling Settings", "so_required") == "Yes": for d in self.get("items"): if not d.against_sales_order: frappe.throw(_("Sales Order required for Item {0}").format(d.item_code)) @@ -314,7 +314,7 @@ class DeliveryNote(SellingController): ) if ( - cint(frappe.get_settings("Selling Settings", "maintain_same_sales_rate")) + cint(frappe.get_single_value("Selling Settings", "maintain_same_sales_rate")) and not self.is_return and not self.is_internal_customer ): @@ -901,7 +901,7 @@ def make_sales_invoice(source_name, target_doc=None, args=None): ) automatically_fetch_payment_terms = cint( - frappe.get_settings("Accounts Settings", "automatically_fetch_payment_terms") + frappe.get_single_value("Accounts Settings", "automatically_fetch_payment_terms") ) if automatically_fetch_payment_terms and not doc.is_return: doc.set_payment_schedule() diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index a0decbd3a86..6f0d9664cac 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -227,7 +227,7 @@ class Item(Document): def validate_description(self): """Clean HTML description if set""" if ( - cint(frappe.get_settings("Stock Settings", "clean_description_html")) + cint(frappe.get_single_value("Stock Settings", "clean_description_html")) and self.description != self.item_name # perf: Avoid cleaning up a fallback ): self.description = clean_html(self.description) @@ -243,9 +243,9 @@ class Item(Document): def add_price(self, price_list=None): """Add a new price""" if not price_list: - price_list = frappe.get_settings("Selling Settings", "selling_price_list") or frappe.db.get_value( - "Price List", _("Standard Selling") - ) + price_list = frappe.get_single_value( + "Selling Settings", "selling_price_list" + ) or frappe.db.get_value("Price List", _("Standard Selling")) if price_list: item_price = frappe.get_doc( { @@ -274,7 +274,7 @@ class Item(Document): for default in self.item_defaults or [ frappe._dict({"company": frappe.defaults.get_defaults().company}) ]: - default_warehouse = default.default_warehouse or frappe.get_settings( + default_warehouse = default.default_warehouse or frappe.get_single_value( "Stock Settings", "default_warehouse" ) if default_warehouse: @@ -317,7 +317,7 @@ class Item(Document): ) def validate_retain_sample(self): - if self.retain_sample and not frappe.get_settings("Stock Settings", "sample_retention_warehouse"): + if self.retain_sample and not frappe.get_single_value("Stock Settings", "sample_retention_warehouse"): frappe.throw(_("Please select Sample Retention Warehouse in Stock Settings first")) if self.retain_sample and not self.has_batch_no: frappe.throw( @@ -662,7 +662,7 @@ class Item(Document): def recalculate_bin_qty(self, new_name): from erpnext.stock.stock_balance import repost_stock - existing_allow_negative_stock = frappe.get_settings("Stock Settings", "allow_negative_stock") + existing_allow_negative_stock = frappe.get_single_value("Stock Settings", "allow_negative_stock") frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1) repost_stock_for_warehouses = frappe.get_all( @@ -961,7 +961,9 @@ class Item(Document): return if not values.get("valuation_method") and self.get("valuation_method"): - values["valuation_method"] = frappe.get_settings("Stock Settings", "valuation_method") or "FIFO" + values["valuation_method"] = ( + frappe.get_single_value("Stock Settings", "valuation_method") or "FIFO" + ) changed_fields = [ field for field in restricted_fields if cstr(self.get(field)) != cstr(values.get(field)) @@ -1047,7 +1049,7 @@ class Item(Document): def validate_auto_reorder_enabled_in_stock_settings(self): if self.reorder_levels: - enabled = frappe.get_settings("Stock Settings", "auto_indent") + enabled = frappe.get_single_value("Stock Settings", "auto_indent") if not enabled: frappe.msgprint( msg=_("You have to enable auto re-order in Stock Settings to maintain re-order levels."), diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py index b6702379590..23aa5bf6247 100644 --- a/erpnext/stock/doctype/packed_item/packed_item.py +++ b/erpnext/stock/doctype/packed_item/packed_item.py @@ -69,7 +69,7 @@ def make_packing_list(doc): return parent_items_price, reset = {}, False - set_price_from_children = frappe.get_settings("Selling Settings", "editable_bundle_item_rates") + set_price_from_children = frappe.get_single_value("Selling Settings", "editable_bundle_item_rates") stale_packed_items_table = get_indexed_packed_items_table(doc) @@ -234,7 +234,7 @@ def update_packed_item_stock_data(main_item_row, pi_row, packing_item, item_data bin = get_packed_item_bin_qty(packing_item.item_code, pi_row.warehouse) pi_row.actual_qty = flt(bin.get("actual_qty")) pi_row.projected_qty = flt(bin.get("projected_qty")) - pi_row.use_serial_batch_fields = frappe.get_settings("Stock Settings", "use_serial_batch_fields") + pi_row.use_serial_batch_fields = frappe.get_single_value("Stock Settings", "use_serial_batch_fields") def update_packed_item_price_data(pi_row, item_data, doc): diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py index 38005a12d38..eb986eff6bf 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -440,7 +440,7 @@ class PickList(Document): def validate_picked_qty(self, data): over_delivery_receipt_allowance = 100 + flt( - frappe.get_settings("Stock Settings", "over_delivery_receipt_allowance") + frappe.get_single_value("Stock Settings", "over_delivery_receipt_allowance") ) for row in data: @@ -1102,7 +1102,7 @@ def get_available_item_locations_for_batched_item( { "item_code": item_code, "warehouse": from_warehouses, - "based_on": frappe.get_settings("Stock Settings", "pick_serial_and_batch_based_on"), + "based_on": frappe.get_single_value("Stock Settings", "pick_serial_and_batch_based_on"), } ) ) diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py index f4772c33fff..9ee05a3f6c7 100644 --- a/erpnext/stock/doctype/price_list/price_list.py +++ b/erpnext/stock/doctype/price_list/price_list.py @@ -39,7 +39,7 @@ class PriceList(Document): def set_default_if_missing(self): if cint(self.selling): - if not frappe.get_settings("Selling Settings", "selling_price_list"): + if not frappe.get_single_value("Selling Settings", "selling_price_list"): frappe.set_value("Selling Settings", "Selling Settings", "selling_price_list", self.name) elif cint(self.buying): diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 9aea6eaa559..2a564d862c0 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -952,8 +952,8 @@ class PurchaseReceipt(BuyingController): def reserve_stock_for_sales_order(self): if ( self.is_return - or not frappe.get_settings("Stock Settings", "enable_stock_reservation") - or not frappe.get_settings("Stock Settings", "auto_reserve_stock_for_sales_order_on_purchase") + or not frappe.get_single_value("Stock Settings", "enable_stock_reservation") + or not frappe.get_single_value("Stock Settings", "auto_reserve_stock_for_sales_order_on_purchase") ): return @@ -988,7 +988,7 @@ class PurchaseReceipt(BuyingController): ) def reserve_stock_for_production_plan(self): - if self.is_return or not frappe.get_settings("Stock Settings", "enable_stock_reservation"): + if self.is_return or not frappe.get_single_value("Stock Settings", "enable_stock_reservation"): return production_plan_references = self.get_production_plan_references() @@ -1199,7 +1199,7 @@ def get_billed_amount_against_po(po_items): def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate=False): # Update Billing % based on pending accepted qty buying_settings = frappe.get_single("Buying Settings") - over_billing_allowance = frappe.get_settings("Accounts Settings", "over_billing_allowance") + over_billing_allowance = frappe.get_single_value("Accounts Settings", "over_billing_allowance") total_amount, total_billed_amount = 0, 0 item_wise_returned_qty = get_item_wise_returned_qty(pr_doc) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index 5e671b2b38c..73d9efd7dc2 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -84,7 +84,9 @@ class SerialandBatchBundle(Document): # end: auto-generated types def autoname(self): - if frappe.get_settings("Stock Settings", "set_serial_and_batch_bundle_naming_based_on_naming_series"): + if frappe.get_single_value( + "Stock Settings", "set_serial_and_batch_bundle_naming_based_on_naming_series" + ): if not self.naming_series: frappe.throw(_("Naming Series is mandatory")) @@ -159,7 +161,7 @@ class SerialandBatchBundle(Document): if self.type_of_transaction == "Outward" or not self.has_serial_no: return - if frappe.get_settings("Stock Settings", "allow_existing_serial_no"): + if frappe.get_single_value("Stock Settings", "allow_existing_serial_no"): return if self.voucher_type not in ["Purchase Receipt", "Purchase Invoice", "Stock Entry"]: diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index ed1596f570c..00c54601178 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -2457,7 +2457,7 @@ class StockEntry(StockController): if not qty: return - use_serial_batch_fields = frappe.get_settings("Stock Settings", "use_serial_batch_fields") + use_serial_batch_fields = frappe.get_single_value("Stock Settings", "use_serial_batch_fields") ste_item_details = { "from_warehouse": item.warehouse, @@ -2935,7 +2935,7 @@ def move_sample_to_retention_warehouse(company, items): if isinstance(items, str): items = json.loads(items) - retention_warehouse = frappe.get_settings("Stock Settings", "sample_retention_warehouse") + retention_warehouse = frappe.get_single_value("Stock Settings", "sample_retention_warehouse") stock_entry = frappe.new_doc("Stock Entry") stock_entry.company = company stock_entry.purpose = "Material Transfer" @@ -2986,7 +2986,7 @@ def make_stock_in_entry(source_name, target_doc=None): target.stock_entry_type = "Material Transfer" target.set_missing_values() - if not frappe.get_settings("Stock Settings", "use_serial_batch_fields"): + if not frappe.get_single_value("Stock Settings", "use_serial_batch_fields"): target.make_serial_and_batch_bundle_for_transfer() def update_item(source_doc, target_doc, source_parent): @@ -3215,7 +3215,7 @@ def validate_sample_quantity(item_code, sample_quantity, qty, batch_no=None): frappe.throw( _("Sample quantity {0} cannot be more than received quantity {1}").format(sample_quantity, qty) ) - retention_warehouse = frappe.get_settings("Stock Settings", "sample_retention_warehouse") + retention_warehouse = frappe.get_single_value("Stock Settings", "sample_retention_warehouse") retainted_qty = 0 if batch_no: retainted_qty = get_batch_qty(batch_no, retention_warehouse, item_code) diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 5709af5bf5f..14aa83b1e50 100644 --- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -299,7 +299,7 @@ class StockLedgerEntry(Document): is_group_warehouse(self.warehouse) def validate_with_last_transaction_posting_time(self): - authorized_role = frappe.get_settings( + authorized_role = frappe.get_single_value( "Stock Settings", "role_allowed_to_create_edit_back_dated_transactions" ) if authorized_role: diff --git a/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry.py b/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry.py index 07c02a0f86c..b9482e31385 100644 --- a/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry.py +++ b/erpnext/stock/doctype/stock_reservation_entry/stock_reservation_entry.py @@ -162,7 +162,7 @@ class StockReservationEntry(Document): not self.from_voucher_type and (self.get("_action") == "submit") and (self.has_serial_no or self.has_batch_no) - and cint(frappe.get_settings("Stock Settings", "auto_reserve_serial_and_batch")) + and cint(frappe.get_single_value("Stock Settings", "auto_reserve_serial_and_batch")) ): from erpnext.stock.doctype.batch.batch import get_available_batches from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos_for_outward @@ -176,7 +176,7 @@ class StockReservationEntry(Document): "warehouse": self.warehouse, "qty": abs(self.reserved_qty) or 0, "based_on": based_on - or frappe.get_settings("Stock Settings", "pick_serial_and_batch_based_on"), + or frappe.get_single_value("Stock Settings", "pick_serial_and_batch_based_on"), } ) @@ -219,7 +219,7 @@ class StockReservationEntry(Document): return if self.reservation_based_on == "Serial and Batch": - allow_partial_reservation = frappe.get_settings("Stock Settings", "allow_partial_reservation") + allow_partial_reservation = frappe.get_single_value("Stock Settings", "allow_partial_reservation") available_serial_nos = [] if self.has_serial_no: @@ -568,7 +568,7 @@ class StockReservationEntry(Document): def validate_stock_reservation_settings(voucher: object) -> None: """Raises an exception if `Stock Reservation` is not enabled or `Voucher Type` is not allowed.""" - if not frappe.get_settings("Stock Settings", "enable_stock_reservation"): + if not frappe.get_single_value("Stock Settings", "enable_stock_reservation"): msg = _("Please enable {0} in the {1}.").format( frappe.bold(_("Stock Reservation")), frappe.bold(_("Stock Settings")), @@ -1345,7 +1345,7 @@ def create_stock_reservation_entries_for_so_items( validate_stock_reservation_settings(sales_order) - allow_partial_reservation = frappe.get_settings("Stock Settings", "allow_partial_reservation") + allow_partial_reservation = frappe.get_single_value("Stock Settings", "allow_partial_reservation") items = [] if items_details: diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index a5168a5176e..00bf974175a 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -136,7 +136,7 @@ def get_item_details( out.update(data) if ( - frappe.get_settings("Stock Settings", "auto_create_serial_and_batch_bundle_for_outward") + frappe.get_single_value("Stock Settings", "auto_create_serial_and_batch_bundle_for_outward") and not ctx.get("serial_and_batch_bundle") and (ctx.get("use_serial_batch_fields") or ctx.get("doctype") == "POS Invoice") ): @@ -201,7 +201,7 @@ def update_stock(ctx, out, doc=None): { "item_code": ctx.item_code, "warehouse": ctx.warehouse, - "based_on": frappe.get_settings("Stock Settings", "pick_serial_and_batch_based_on"), + "based_on": frappe.get_single_value("Stock Settings", "pick_serial_and_batch_based_on"), } ) @@ -591,7 +591,7 @@ def get_item_warehouse_(ctx: ItemDetailsCtx, item, overwrite_warehouse, defaults warehouse = ctx.warehouse if not warehouse: - default_warehouse = frappe.get_settings("Stock Settings", "default_warehouse") + default_warehouse = frappe.get_single_value("Stock Settings", "default_warehouse") if frappe.db.get_value("Warehouse", default_warehouse, "company") == ctx.company: return default_warehouse diff --git a/erpnext/stock/serial_batch_bundle.py b/erpnext/stock/serial_batch_bundle.py index 778accad396..eaea590971d 100644 --- a/erpnext/stock/serial_batch_bundle.py +++ b/erpnext/stock/serial_batch_bundle.py @@ -151,12 +151,14 @@ class SerialBatchBundle: if ( self.item_details.has_batch_no and not self.item_details.batch_number_series - and not frappe.get_settings("Stock Settings", "naming_series_prefix") + and not frappe.get_single_value("Stock Settings", "naming_series_prefix") ): msg += f". If you want auto pick batch bundle, then kindly set Batch Number Series in Item {self.item_code}" elif self.sle.actual_qty < 0: - if not frappe.get_settings("Stock Settings", "auto_create_serial_and_batch_bundle_for_outward"): + if not frappe.get_single_value( + "Stock Settings", "auto_create_serial_and_batch_bundle_for_outward" + ): msg += ". If you want auto pick serial/batch bundle, then kindly enable 'Auto Create Serial and Batch Bundle' in Stock Settings." if msg: @@ -185,7 +187,7 @@ class SerialBatchBundle: if self.sle.actual_qty < 0 and self.is_material_transfer(): values_to_update["valuation_rate"] = flt(sn_doc.avg_rate) - if not frappe.get_settings( + if not frappe.get_single_value( "Stock Settings", "do_not_update_serial_batch_on_creation_of_auto_bundle" ): if sn_doc.has_serial_no: @@ -251,7 +253,9 @@ class SerialBatchBundle: and ( self.item_details.create_new_batch or ( - frappe.get_settings("Stock Settings", "auto_create_serial_and_batch_bundle_for_outward") + frappe.get_single_value( + "Stock Settings", "auto_create_serial_and_batch_bundle_for_outward" + ) and self.sle.actual_qty < 0 ) ) @@ -720,7 +724,7 @@ class BatchNoValuation(DeprecatedBatchNoValuation): self.batchwise_valuation_batches = [] self.non_batchwise_valuation_batches = [] - if get_valuation_method(self.sle.item_code) == "Moving Average" and frappe.get_settings( + if get_valuation_method(self.sle.item_code) == "Moving Average" and frappe.get_single_value( "Stock Settings", "do_not_use_batchwise_valuation" ): self.non_batchwise_valuation_batches = self.batches @@ -1025,7 +1029,7 @@ class SerialBatchCreation: "item_code": self.item_code, "warehouse": self.warehouse, "qty": abs(self.actual_qty) if self.actual_qty else 0, - "based_on": frappe.get_settings("Stock Settings", "pick_serial_and_batch_based_on"), + "based_on": frappe.get_single_value("Stock Settings", "pick_serial_and_batch_based_on"), } ) diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py index 135b9097c12..e650fb607ba 100644 --- a/erpnext/stock/stock_balance.py +++ b/erpnext/stock/stock_balance.py @@ -15,7 +15,7 @@ def repost(only_actual=False, allow_negative_stock=False, allow_zero_rate=False, frappe.db.auto_commit_on_many_writes = 1 if allow_negative_stock: - existing_allow_negative_stock = frappe.get_settings("Stock Settings", "allow_negative_stock") + existing_allow_negative_stock = frappe.get_single_value("Stock Settings", "allow_negative_stock") frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1) item_warehouses = frappe.db.sql( diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py index b85956a35fa..9d5d9f7c49b 100644 --- a/erpnext/stock/utils.py +++ b/erpnext/stock/utils.py @@ -252,7 +252,7 @@ def get_incoming_rate(args, raise_error_if_no_rate=True): "Item", args.get("item_code"), ["has_serial_no", "has_batch_no"], as_dict=1 ) - use_moving_avg_for_batch = frappe.get_settings("Stock Settings", "do_not_use_batchwise_valuation") + use_moving_avg_for_batch = frappe.get_single_value("Stock Settings", "do_not_use_batchwise_valuation") if isinstance(args, dict): args = frappe._dict(args) diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 2384529c5ee..731e94723d5 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -354,7 +354,7 @@ class TransactionBase(StatusUpdater): self.set_rate_based_on_price_list(item_obj, item_details) def add_taxes_from_item_template(self, item_obj: object, item_details: dict) -> None: - if item_details.item_tax_rate and frappe.get_settings( + if item_details.item_tax_rate and frappe.get_single_value( "Accounts Settings", "add_taxes_from_item_tax_template" ): item_tax_template = frappe.json.loads(item_details.item_tax_rate)