mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-13 03:45:08 +00:00
refactor: rename get_settings -> get_single_value (#47961)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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"):
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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."))
|
||||
|
||||
|
||||
@@ -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"]
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 = (
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -554,7 +554,7 @@ def check_credit_limit(customer, company, ignore_outstanding_sales_order=False,
|
||||
message += "<br><br>"
|
||||
|
||||
# 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")
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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."),
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"]:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user