refactor: Use `db.set_single_value` (#35668)
I just applied semgrep autofix. Untested completed, review before merging.
```yaml
- id: frappe-set-value-semantics
patterns:
- pattern-either:
- pattern: frappe.db.set_value($DOCTYPE, None, $...AFTER)
- pattern: frappe.db.set_value($DOCTYPE, $DOCTYPE, $...AFTER)
fix: frappe.db.set_single_value($DOCTYPE, $...AFTER)
message: |
If $DOCTYPE is a single doctype then using `frappe.db.set_value` is discouraged for setting values in DB. Use db.set_single_value for single doctype instead.
languages: [python]
severity: ERROR
```
diff --git a/.semgrepignore b/.semgrepignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.semgrepignore
diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
index 3207e41..9d1b99b 100644
--- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
+++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
@@ -12,7 +12,7 @@
class FiscalYear(Document):
@frappe.whitelist()
def set_as_default(self):
- frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.name)
+ frappe.db.set_single_value("Global Defaults", "current_fiscal_year", self.name)
global_defaults = frappe.get_doc("Global Defaults")
global_defaults.check_permission("write")
global_defaults.on_update()
diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py
index f7297d1..73b1911 100644
--- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py
@@ -105,8 +105,8 @@
elif test_voucher.doctype in ["Sales Order", "Purchase Order"]:
# if test_voucher is a Sales Order/Purchase Order, test error on cancellation of test_voucher
- frappe.db.set_value(
- "Accounts Settings", "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order", 0
+ frappe.db.set_single_value(
+ "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order", 0
)
submitted_voucher = frappe.get_doc(test_voucher.doctype, test_voucher.name)
self.assertRaises(frappe.LinkExistsError, submitted_voucher.cancel)
diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py
index 9685d99..f842a16 100644
--- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py
+++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py
@@ -31,7 +31,7 @@
frappe.set_user("Administrator")
if frappe.db.get_single_value("Selling Settings", "validate_selling_price"):
- frappe.db.set_value("Selling Settings", None, "validate_selling_price", 0)
+ frappe.db.set_single_value("Selling Settings", "validate_selling_price", 0)
def test_timestamp_change(self):
w = create_pos_invoice(do_not_save=1)
@@ -722,7 +722,7 @@
)
if not frappe.db.get_single_value("Selling Settings", "validate_selling_price"):
- frappe.db.set_value("Selling Settings", "Selling Settings", "validate_selling_price", 1)
+ frappe.db.set_single_value("Selling Settings", "validate_selling_price", 1)
item = "Test Selling Price Validation"
make_item(item, {"is_stock_item": 1})
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 5b83534..42eb018 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -42,7 +42,7 @@
@classmethod
def setUpClass(self):
unlink_payment_on_cancel_of_invoice()
- frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
+ frappe.db.set_single_value("Buying Settings", "allow_multiple_items", 1)
@classmethod
def tearDownClass(self):
@@ -1232,9 +1232,7 @@
"Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice"
)
- frappe.db.set_value(
- "Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice", 1
- )
+ frappe.db.set_single_value("Accounts Settings", "unlink_payment_on_cancel_of_invoice", 1)
original_account = frappe.db.get_value("Company", "_Test Company", "exchange_gain_loss_account")
frappe.db.set_value(
@@ -1369,8 +1367,8 @@
pay.reload()
pay.cancel()
- frappe.db.set_value(
- "Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice", unlink_enabled
+ frappe.db.set_single_value(
+ "Accounts Settings", "unlink_payment_on_cancel_of_invoice", unlink_enabled
)
frappe.db.set_value("Company", "_Test Company", "exchange_gain_loss_account", original_account)
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 51e0d91..784bdf6 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -1063,7 +1063,7 @@
self.assertEqual(pos.write_off_amount, 10)
def test_pos_with_no_gl_entry_for_change_amount(self):
- frappe.db.set_value("Accounts Settings", None, "post_change_gl_entries", 0)
+ frappe.db.set_single_value("Accounts Settings", "post_change_gl_entries", 0)
make_pos_profile(
company="_Test Company with perpetual inventory",
@@ -1113,7 +1113,7 @@
self.validate_pos_gl_entry(pos, pos, 60, validate_without_change_gle=True)
- frappe.db.set_value("Accounts Settings", None, "post_change_gl_entries", 1)
+ frappe.db.set_single_value("Accounts Settings", "post_change_gl_entries", 1)
def validate_pos_gl_entry(self, si, pos, cash_amount, validate_without_change_gle=False):
if validate_without_change_gle:
@@ -2452,7 +2452,7 @@
"Check mapping (expense account) of inter company SI to PI in absence of default warehouse."
# setup
old_negative_stock = frappe.db.get_single_value("Stock Settings", "allow_negative_stock")
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
old_perpetual_inventory = erpnext.is_perpetual_inventory_enabled("_Test Company 1")
frappe.local.enable_perpetual_inventory["_Test Company 1"] = 1
@@ -2506,7 +2506,7 @@
# tear down
frappe.local.enable_perpetual_inventory["_Test Company 1"] = old_perpetual_inventory
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", old_negative_stock)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", old_negative_stock)
def test_sle_for_target_warehouse(self):
se = make_stock_entry(
@@ -2898,7 +2898,7 @@
party_link = create_party_link("Supplier", supplier, customer)
# enable common party accounting
- frappe.db.set_value("Accounts Settings", None, "enable_common_party_accounting", 1)
+ frappe.db.set_single_value("Accounts Settings", "enable_common_party_accounting", 1)
# create a sales invoice
si = create_sales_invoice(customer=customer, parent_cost_center="_Test Cost Center - _TC")
@@ -2925,7 +2925,7 @@
self.assertEqual(jv[0], si.grand_total)
party_link.delete()
- frappe.db.set_value("Accounts Settings", None, "enable_common_party_accounting", 0)
+ frappe.db.set_single_value("Accounts Settings", "enable_common_party_accounting", 0)
def test_payment_statuses(self):
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
@@ -3045,7 +3045,7 @@
self.assertRaises(frappe.ValidationError, si.save)
def test_sales_invoice_submission_post_account_freezing_date(self):
- frappe.db.set_value("Accounts Settings", None, "acc_frozen_upto", add_days(getdate(), 1))
+ frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", add_days(getdate(), 1))
si = create_sales_invoice(do_not_save=True)
si.posting_date = add_days(getdate(), 1)
si.save()
@@ -3054,7 +3054,7 @@
si.posting_date = getdate()
si.submit()
- frappe.db.set_value("Accounts Settings", None, "acc_frozen_upto", None)
+ frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", None)
def test_over_billing_case_against_delivery_note(self):
"""
@@ -3066,7 +3066,7 @@
over_billing_allowance = frappe.db.get_single_value(
"Accounts Settings", "over_billing_allowance"
)
- frappe.db.set_value("Accounts Settings", None, "over_billing_allowance", 0)
+ frappe.db.set_single_value("Accounts Settings", "over_billing_allowance", 0)
dn = create_delivery_note()
dn.submit()
@@ -3082,7 +3082,7 @@
self.assertTrue("cannot overbill" in str(err.exception).lower())
- frappe.db.set_value("Accounts Settings", None, "over_billing_allowance", over_billing_allowance)
+ frappe.db.set_single_value("Accounts Settings", "over_billing_allowance", over_billing_allowance)
def test_multi_currency_deferred_revenue_via_journal_entry(self):
deferred_account = create_account(
@@ -3121,7 +3121,7 @@
si.save()
si.submit()
- frappe.db.set_value("Accounts Settings", None, "acc_frozen_upto", getdate("2019-01-31"))
+ frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", getdate("2019-01-31"))
pda1 = frappe.get_doc(
dict(
@@ -3166,7 +3166,7 @@
acc_settings.submit_journal_entries = 0
acc_settings.save()
- frappe.db.set_value("Accounts Settings", None, "acc_frozen_upto", None)
+ frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", None)
def test_standalone_serial_no_return(self):
si = create_sales_invoice(
@@ -3216,9 +3216,7 @@
"Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice"
)
- frappe.db.set_value(
- "Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice", 1
- )
+ frappe.db.set_single_value("Accounts Settings", "unlink_payment_on_cancel_of_invoice", 1)
jv = make_journal_entry("_Test Receivable USD - _TC", "_Test Bank - _TC", -7000, save=False)
@@ -3261,8 +3259,8 @@
check_gl_entries(self, si.name, expected_gle, nowdate())
- frappe.db.set_value(
- "Accounts Settings", "Accounts Settings", "unlink_payment_on_cancel_of_invoice", unlink_enabled
+ frappe.db.set_single_value(
+ "Accounts Settings", "unlink_payment_on_cancel_of_invoice", unlink_enabled
)
def test_batch_expiry_for_sales_invoice_return(self):
diff --git a/erpnext/accounts/doctype/tax_rule/test_tax_rule.py b/erpnext/accounts/doctype/tax_rule/test_tax_rule.py
index 848e054..335b483 100644
--- a/erpnext/accounts/doctype/tax_rule/test_tax_rule.py
+++ b/erpnext/accounts/doctype/tax_rule/test_tax_rule.py
@@ -15,7 +15,7 @@
class TestTaxRule(unittest.TestCase):
@classmethod
def setUpClass(cls):
- frappe.db.set_value("Shopping Cart Settings", None, "enabled", 0)
+ frappe.db.set_single_value("Shopping Cart Settings", "enabled", 0)
@classmethod
def tearDownClass(cls):
diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py
index 0dfcee4..2a74f20 100644
--- a/erpnext/assets/doctype/asset/test_asset.py
+++ b/erpnext/assets/doctype/asset/test_asset.py
@@ -1804,7 +1804,7 @@
company.save()
# Enable booking asset depreciation entry automatically
- frappe.db.set_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically", 1)
+ frappe.db.set_single_value("Accounts Settings", "book_asset_depreciation_entry_automatically", 1)
def enable_cwip_accounting(asset_category, enable=1):
diff --git a/erpnext/assets/doctype/asset_maintenance/test_asset_maintenance.py b/erpnext/assets/doctype/asset_maintenance/test_asset_maintenance.py
index e40a551..23088c9 100644
--- a/erpnext/assets/doctype/asset_maintenance/test_asset_maintenance.py
+++ b/erpnext/assets/doctype/asset_maintenance/test_asset_maintenance.py
@@ -182,4 +182,4 @@
company.save()
# Enable booking asset depreciation entry automatically
- frappe.db.set_value("Accounts Settings", None, "book_asset_depreciation_entry_automatically", 1)
+ frappe.db.set_single_value("Accounts Settings", "book_asset_depreciation_entry_automatically", 1)
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index 920486a..3edaffa 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -92,7 +92,7 @@
frappe.db.set_value("Item", "_Test Item", "over_delivery_receipt_allowance", 0)
frappe.db.set_value("Item", "_Test Item", "over_billing_allowance", 0)
- frappe.db.set_value("Accounts Settings", None, "over_billing_allowance", 0)
+ frappe.db.set_single_value("Accounts Settings", "over_billing_allowance", 0)
def test_update_remove_child_linked_to_mr(self):
"""Test impact on linked PO and MR on deleting/updating row."""
@@ -581,7 +581,7 @@
)
def test_group_same_items(self):
- frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
+ frappe.db.set_single_value("Buying Settings", "allow_multiple_items", 1)
frappe.get_doc(
{
"doctype": "Purchase Order",
@@ -836,8 +836,8 @@
)
from erpnext.stock.doctype.delivery_note.delivery_note import make_inter_company_purchase_receipt
- frappe.db.set_value("Selling Settings", None, "maintain_same_sales_rate", 1)
- frappe.db.set_value("Buying Settings", None, "maintain_same_rate", 1)
+ frappe.db.set_single_value("Selling Settings", "maintain_same_sales_rate", 1)
+ frappe.db.set_single_value("Buying Settings", "maintain_same_rate", 1)
prepare_data_for_internal_transfer()
supplier = "_Test Internal Supplier 2"
diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py
index b9fc344..7a205ac 100644
--- a/erpnext/buying/doctype/supplier/test_supplier.py
+++ b/erpnext/buying/doctype/supplier/test_supplier.py
@@ -156,7 +156,7 @@
def test_serach_fields_for_supplier(self):
from erpnext.controllers.queries import supplier_query
- frappe.db.set_value("Buying Settings", None, "supp_master_name", "Naming Series")
+ frappe.db.set_single_value("Buying Settings", "supp_master_name", "Naming Series")
supplier_name = create_supplier(supplier_name="Test Supplier 1").name
@@ -189,7 +189,7 @@
self.assertEqual(data[0].supplier_type, "Company")
self.assertTrue("supplier_type" in data[0])
- frappe.db.set_value("Buying Settings", None, "supp_master_name", "Supplier Name")
+ frappe.db.set_single_value("Buying Settings", "supp_master_name", "Supplier Name")
def create_supplier(**args):
diff --git a/erpnext/controllers/tests/test_subcontracting_controller.py b/erpnext/controllers/tests/test_subcontracting_controller.py
index 8a325e4..eeb35c4 100644
--- a/erpnext/controllers/tests/test_subcontracting_controller.py
+++ b/erpnext/controllers/tests/test_subcontracting_controller.py
@@ -1074,8 +1074,8 @@
def set_backflush_based_on(based_on):
- frappe.db.set_value(
- "Buying Settings", None, "backflush_raw_materials_of_subcontract_based_on", based_on
+ frappe.db.set_single_value(
+ "Buying Settings", "backflush_raw_materials_of_subcontract_based_on", based_on
)
diff --git a/erpnext/crm/doctype/opportunity/test_opportunity.py b/erpnext/crm/doctype/opportunity/test_opportunity.py
index 1ff3267..247e20d 100644
--- a/erpnext/crm/doctype/opportunity/test_opportunity.py
+++ b/erpnext/crm/doctype/opportunity/test_opportunity.py
@@ -53,9 +53,7 @@
self.assertEqual(opportunity_doc.total, 2200)
def test_carry_forward_of_email_and_comments(self):
- frappe.db.set_value(
- "CRM Settings", "CRM Settings", "carry_forward_communication_and_comments", 1
- )
+ frappe.db.set_single_value("CRM Settings", "carry_forward_communication_and_comments", 1)
lead_doc = make_lead()
lead_doc.add_comment("Comment", text="Test Comment 1")
lead_doc.add_comment("Comment", text="Test Comment 2")
diff --git a/erpnext/e_commerce/shopping_cart/test_shopping_cart.py b/erpnext/e_commerce/shopping_cart/test_shopping_cart.py
index f44f8fe..951039d 100644
--- a/erpnext/e_commerce/shopping_cart/test_shopping_cart.py
+++ b/erpnext/e_commerce/shopping_cart/test_shopping_cart.py
@@ -205,7 +205,7 @@
self.assertEqual(quote_doctstatus, 0)
- frappe.db.set_value("E Commerce Settings", None, "save_quotations_as_draft", 0)
+ frappe.db.set_single_value("E Commerce Settings", "save_quotations_as_draft", 0)
frappe.local.shopping_cart_settings = None
update_cart("_Test Item", 1)
quote_name = request_for_quotation() # Request for Quote
diff --git a/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py b/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py
index 6d34a20..86e1b31 100644
--- a/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py
+++ b/erpnext/erpnext_integrations/doctype/plaid_settings/test_plaid_settings.py
@@ -32,7 +32,7 @@
frappe.delete_doc(doctype, d.name, force=True)
def test_plaid_disabled(self):
- frappe.db.set_value("Plaid Settings", None, "enabled", 0)
+ frappe.db.set_single_value("Plaid Settings", "enabled", 0)
self.assertTrue(get_plaid_configuration() == "disabled")
def test_add_account_type(self):
diff --git a/erpnext/manufacturing/doctype/work_order/test_work_order.py b/erpnext/manufacturing/doctype/work_order/test_work_order.py
index 9f8390c..690fe47 100644
--- a/erpnext/manufacturing/doctype/work_order/test_work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/test_work_order.py
@@ -503,10 +503,8 @@
stock_entry.cancel()
def test_capcity_planning(self):
- frappe.db.set_value(
- "Manufacturing Settings",
- None,
- {"disable_capacity_planning": 0, "capacity_planning_for_days": 1},
+ frappe.db.set_single_value(
+ "Manufacturing Settings", {"disable_capacity_planning": 0, "capacity_planning_for_days": 1}
)
data = frappe.get_cached_value(
@@ -529,7 +527,7 @@
self.assertRaises(CapacityError, work_order1.submit)
- frappe.db.set_value("Manufacturing Settings", None, {"capacity_planning_for_days": 30})
+ frappe.db.set_single_value("Manufacturing Settings", {"capacity_planning_for_days": 30})
work_order1.reload()
work_order1.submit()
@@ -539,7 +537,7 @@
work_order.cancel()
def test_work_order_with_non_transfer_item(self):
- frappe.db.set_value("Manufacturing Settings", None, "backflush_raw_materials_based_on", "BOM")
+ frappe.db.set_single_value("Manufacturing Settings", "backflush_raw_materials_based_on", "BOM")
items = {"Finished Good Transfer Item": 1, "_Test FG Item": 1, "_Test FG Item 1": 0}
for item, allow_transfer in items.items():
@@ -619,7 +617,7 @@
fg_item = "Test Batch Size Item For BOM 3"
rm1 = "Test Batch Size Item RM 1 For BOM 3"
- frappe.db.set_value("Manufacturing Settings", None, "make_serial_no_batch_from_work_order", 0)
+ frappe.db.set_single_value("Manufacturing Settings", "make_serial_no_batch_from_work_order", 0)
for item in ["Test Batch Size Item For BOM 3", "Test Batch Size Item RM 1 For BOM 3"]:
item_args = {"include_item_in_manufacturing": 1, "is_stock_item": 1}
@@ -655,7 +653,7 @@
work_order = make_wo_order_test_record(
item=fg_item, skip_transfer=True, planned_start_date=now(), qty=1
)
- frappe.db.set_value("Manufacturing Settings", None, "make_serial_no_batch_from_work_order", 1)
+ frappe.db.set_single_value("Manufacturing Settings", "make_serial_no_batch_from_work_order", 1)
ste1 = frappe.get_doc(make_stock_entry(work_order.name, "Manufacture", 1))
for row in ste1.get("items"):
if row.is_finished_item:
@@ -699,10 +697,10 @@
self.assertEqual(sorted(remaining_batches), sorted(batches))
- frappe.db.set_value("Manufacturing Settings", None, "make_serial_no_batch_from_work_order", 0)
+ frappe.db.set_single_value("Manufacturing Settings", "make_serial_no_batch_from_work_order", 0)
def test_partial_material_consumption(self):
- frappe.db.set_value("Manufacturing Settings", None, "material_consumption", 1)
+ frappe.db.set_single_value("Manufacturing Settings", "material_consumption", 1)
wo_order = make_wo_order_test_record(planned_start_date=now(), qty=4)
ste_cancel_list = []
@@ -736,13 +734,12 @@
for ste_doc in ste_cancel_list:
ste_doc.cancel()
- frappe.db.set_value("Manufacturing Settings", None, "material_consumption", 0)
+ frappe.db.set_single_value("Manufacturing Settings", "material_consumption", 0)
def test_extra_material_transfer(self):
- frappe.db.set_value("Manufacturing Settings", None, "material_consumption", 0)
- frappe.db.set_value(
+ frappe.db.set_single_value("Manufacturing Settings", "material_consumption", 0)
+ frappe.db.set_single_value(
"Manufacturing Settings",
- None,
"backflush_raw_materials_based_on",
"Material Transferred for Manufacture",
)
@@ -787,7 +784,7 @@
for ste_doc in ste_cancel_list:
ste_doc.cancel()
- frappe.db.set_value("Manufacturing Settings", None, "backflush_raw_materials_based_on", "BOM")
+ frappe.db.set_single_value("Manufacturing Settings", "backflush_raw_materials_based_on", "BOM")
def test_make_stock_entry_for_customer_provided_item(self):
finished_item = "Test Item for Make Stock Entry 1"
@@ -1087,9 +1084,8 @@
def test_partial_manufacture_entries(self):
cancel_stock_entry = []
- frappe.db.set_value(
+ frappe.db.set_single_value(
"Manufacturing Settings",
- None,
"backflush_raw_materials_based_on",
"Material Transferred for Manufacture",
)
@@ -1139,7 +1135,7 @@
doc = frappe.get_doc("Stock Entry", ste)
doc.cancel()
- frappe.db.set_value("Manufacturing Settings", None, "backflush_raw_materials_based_on", "BOM")
+ frappe.db.set_single_value("Manufacturing Settings", "backflush_raw_materials_based_on", "BOM")
@change_settings("Manufacturing Settings", {"make_serial_no_batch_from_work_order": 1})
def test_auto_batch_creation(self):
@@ -1283,9 +1279,8 @@
self.assertEqual(work_order.required_items[1].transferred_qty, 2)
def test_backflushed_batch_raw_materials_based_on_transferred(self):
- frappe.db.set_value(
+ frappe.db.set_single_value(
"Manufacturing Settings",
- None,
"backflush_raw_materials_based_on",
"Material Transferred for Manufacture",
)
@@ -1356,9 +1351,8 @@
self.assertEqual(abs(d.qty), 2)
def test_backflushed_serial_no_raw_materials_based_on_transferred(self):
- frappe.db.set_value(
+ frappe.db.set_single_value(
"Manufacturing Settings",
- None,
"backflush_raw_materials_based_on",
"Material Transferred for Manufacture",
)
@@ -1400,9 +1394,8 @@
self.assertEqual(manufacture_ste_doc2.items[0].qty, 2)
def test_backflushed_serial_no_batch_raw_materials_based_on_transferred(self):
- frappe.db.set_value(
+ frappe.db.set_single_value(
"Manufacturing Settings",
- None,
"backflush_raw_materials_based_on",
"Material Transferred for Manufacture",
)
@@ -1486,9 +1479,8 @@
self.assertFalse(serial_nos)
def test_non_consumed_material_return_against_work_order(self):
- frappe.db.set_value(
+ frappe.db.set_single_value(
"Manufacturing Settings",
- None,
"backflush_raw_materials_based_on",
"Material Transferred for Manufacture",
)
diff --git a/erpnext/patches/v11_0/update_backflush_subcontract_rm_based_on_bom.py b/erpnext/patches/v11_0/update_backflush_subcontract_rm_based_on_bom.py
index 51ba706..037dda5 100644
--- a/erpnext/patches/v11_0/update_backflush_subcontract_rm_based_on_bom.py
+++ b/erpnext/patches/v11_0/update_backflush_subcontract_rm_based_on_bom.py
@@ -7,8 +7,8 @@
def execute():
frappe.reload_doc("buying", "doctype", "buying_settings")
- frappe.db.set_value(
- "Buying Settings", None, "backflush_raw_materials_of_subcontract_based_on", "BOM"
+ frappe.db.set_single_value(
+ "Buying Settings", "backflush_raw_materials_of_subcontract_based_on", "BOM"
)
frappe.reload_doc("stock", "doctype", "stock_entry_detail")
diff --git a/erpnext/patches/v12_0/rename_tolerance_fields.py b/erpnext/patches/v12_0/rename_tolerance_fields.py
index ef1ba65..c53604c 100644
--- a/erpnext/patches/v12_0/rename_tolerance_fields.py
+++ b/erpnext/patches/v12_0/rename_tolerance_fields.py
@@ -11,6 +11,6 @@
rename_field("Item", "tolerance", "over_delivery_receipt_allowance")
qty_allowance = frappe.db.get_single_value("Stock Settings", "over_delivery_receipt_allowance")
- frappe.db.set_value("Accounts Settings", None, "over_delivery_receipt_allowance", qty_allowance)
+ frappe.db.set_single_value("Accounts Settings", "over_delivery_receipt_allowance", qty_allowance)
frappe.db.sql("update tabItem set over_billing_allowance=over_delivery_receipt_allowance")
diff --git a/erpnext/patches/v12_0/set_automatically_process_deferred_accounting_in_accounts_settings.py b/erpnext/patches/v12_0/set_automatically_process_deferred_accounting_in_accounts_settings.py
index 37af989..84dd1c7 100644
--- a/erpnext/patches/v12_0/set_automatically_process_deferred_accounting_in_accounts_settings.py
+++ b/erpnext/patches/v12_0/set_automatically_process_deferred_accounting_in_accounts_settings.py
@@ -4,6 +4,6 @@
def execute():
frappe.reload_doc("accounts", "doctype", "accounts_settings")
- frappe.db.set_value(
- "Accounts Settings", None, "automatically_process_deferred_accounting_entry", 1
+ frappe.db.set_single_value(
+ "Accounts Settings", "automatically_process_deferred_accounting_entry", 1
)
diff --git a/erpnext/patches/v12_0/set_default_homepage_type.py b/erpnext/patches/v12_0/set_default_homepage_type.py
index d70b28e..d91fe33 100644
--- a/erpnext/patches/v12_0/set_default_homepage_type.py
+++ b/erpnext/patches/v12_0/set_default_homepage_type.py
@@ -2,4 +2,4 @@
def execute():
- frappe.db.set_value("Homepage", "Homepage", "hero_section_based_on", "Default")
+ frappe.db.set_single_value("Homepage", "hero_section_based_on", "Default")
diff --git a/erpnext/patches/v12_0/set_priority_for_support.py b/erpnext/patches/v12_0/set_priority_for_support.py
index a8a07e7..a16eb8a 100644
--- a/erpnext/patches/v12_0/set_priority_for_support.py
+++ b/erpnext/patches/v12_0/set_priority_for_support.py
@@ -46,7 +46,7 @@
frappe.reload_doc("support", "doctype", "service_level")
frappe.reload_doc("support", "doctype", "support_settings")
- frappe.db.set_value("Support Settings", None, "track_service_level_agreement", 1)
+ frappe.db.set_single_value("Support Settings", "track_service_level_agreement", 1)
for service_level in service_level_priorities:
if service_level:
diff --git a/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py b/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py
index 6c64ef6..0f77afd 100644
--- a/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py
+++ b/erpnext/patches/v13_0/modify_invalid_gain_loss_gl_entries.py
@@ -47,7 +47,7 @@
acc_frozen_upto = frappe.db.get_value("Accounts Settings", None, "acc_frozen_upto")
if acc_frozen_upto:
- frappe.db.set_value("Accounts Settings", None, "acc_frozen_upto", None)
+ frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", None)
for invoice in purchase_invoices + sales_invoices:
try:
@@ -65,4 +65,4 @@
print(f"Failed to correct gl entries of {invoice.name}")
if acc_frozen_upto:
- frappe.db.set_value("Accounts Settings", None, "acc_frozen_upto", acc_frozen_upto)
+ frappe.db.set_single_value("Accounts Settings", "acc_frozen_upto", acc_frozen_upto)
diff --git a/erpnext/patches/v14_0/discount_accounting_separation.py b/erpnext/patches/v14_0/discount_accounting_separation.py
index 0d1349a..4216ecc 100644
--- a/erpnext/patches/v14_0/discount_accounting_separation.py
+++ b/erpnext/patches/v14_0/discount_accounting_separation.py
@@ -8,4 +8,4 @@
discount_account = data and int(data[0][0]) or 0
if discount_account:
for doctype in ["Buying Settings", "Selling Settings"]:
- frappe.db.set_value(doctype, doctype, "enable_discount_accounting", 1, update_modified=False)
+ frappe.db.set_single_value(doctype, "enable_discount_accounting", 1, update_modified=False)
diff --git a/erpnext/patches/v14_0/migrate_crm_settings.py b/erpnext/patches/v14_0/migrate_crm_settings.py
index 696a100..2477255 100644
--- a/erpnext/patches/v14_0/migrate_crm_settings.py
+++ b/erpnext/patches/v14_0/migrate_crm_settings.py
@@ -11,8 +11,7 @@
frappe.reload_doc("crm", "doctype", "crm_settings")
if settings:
- frappe.db.set_value(
- "CRM Settings",
+ frappe.db.set_single_value(
"CRM Settings",
{
"campaign_naming_by": settings.campaign_naming_by,
diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py
index a621c73..6e737e4 100644
--- a/erpnext/selling/doctype/customer/test_customer.py
+++ b/erpnext/selling/doctype/customer/test_customer.py
@@ -345,7 +345,7 @@
def test_serach_fields_for_customer(self):
from erpnext.controllers.queries import customer_query
- frappe.db.set_value("Selling Settings", None, "cust_master_name", "Naming Series")
+ frappe.db.set_single_value("Selling Settings", "cust_master_name", "Naming Series")
make_property_setter(
"Customer", None, "search_fields", "customer_group", "Data", for_doctype="Doctype"
@@ -371,7 +371,7 @@
self.assertEqual(data[0].territory, "_Test Territory")
self.assertTrue("territory" in data[0])
- frappe.db.set_value("Selling Settings", None, "cust_master_name", "Customer Name")
+ frappe.db.set_single_value("Selling Settings", "cust_master_name", "Customer Name")
def get_customer_dict(customer_name):
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index 6459def..45100d7 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -43,11 +43,8 @@
@classmethod
def tearDownClass(cls) -> None:
# reset config to previous state
- frappe.db.set_value(
- "Accounts Settings",
- "Accounts Settings",
- "unlink_advance_payment_on_cancelation_of_order",
- cls.unlink_setting,
+ frappe.db.set_single_value(
+ "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order", cls.unlink_setting
)
super().tearDownClass()
@@ -705,7 +702,7 @@
self.assertEqual(so.taxes[0].total, 110)
old_stock_settings_value = frappe.db.get_single_value("Stock Settings", "default_warehouse")
- frappe.db.set_value("Stock Settings", None, "default_warehouse", "_Test Warehouse - _TC")
+ frappe.db.set_single_value("Stock Settings", "default_warehouse", "_Test Warehouse - _TC")
items = json.dumps(
[
@@ -741,7 +738,7 @@
so.delete()
new_item_with_tax.delete()
frappe.get_doc("Item Tax Template", "Test Update Items Template - _TC").delete()
- frappe.db.set_value("Stock Settings", None, "default_warehouse", old_stock_settings_value)
+ frappe.db.set_single_value("Stock Settings", "default_warehouse", old_stock_settings_value)
def test_warehouse_user(self):
test_user = create_user("test_so_warehouse_user@example.com", "Sales User", "Stock User")
@@ -820,7 +817,7 @@
def test_auto_insert_price(self):
make_item("_Test Item for Auto Price List", {"is_stock_item": 0})
make_item("_Test Item for Auto Price List with Discount Percentage", {"is_stock_item": 0})
- frappe.db.set_value("Stock Settings", None, "auto_insert_price_list_rate_if_missing", 1)
+ frappe.db.set_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing", 1)
item_price = frappe.db.get_value(
"Item Price", {"price_list": "_Test Price List", "item_code": "_Test Item for Auto Price List"}
@@ -861,7 +858,7 @@
)
# do not update price list
- frappe.db.set_value("Stock Settings", None, "auto_insert_price_list_rate_if_missing", 0)
+ frappe.db.set_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing", 0)
item_price = frappe.db.get_value(
"Item Price", {"price_list": "_Test Price List", "item_code": "_Test Item for Auto Price List"}
@@ -882,7 +879,7 @@
None,
)
- frappe.db.set_value("Stock Settings", None, "auto_insert_price_list_rate_if_missing", 1)
+ frappe.db.set_single_value("Stock Settings", "auto_insert_price_list_rate_if_missing", 1)
def test_drop_shipping(self):
from erpnext.buying.doctype.purchase_order.purchase_order import update_status
@@ -1257,8 +1254,8 @@
def test_advance_payment_entry_unlink_against_sales_order(self):
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
- frappe.db.set_value(
- "Accounts Settings", "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order", 0
+ frappe.db.set_single_value(
+ "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order", 0
)
so = make_sales_order()
@@ -1312,8 +1309,8 @@
so = make_sales_order()
# disable unlinking of payment entry
- frappe.db.set_value(
- "Accounts Settings", "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order", 0
+ frappe.db.set_single_value(
+ "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order", 0
)
# create a payment entry against sales order
@@ -2080,7 +2077,7 @@
def create_dn_against_so(so, delivered_qty=0):
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
dn = make_delivery_note(so)
dn.get("items")[0].qty = delivered_qty or 5
diff --git a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py
index e3d281a..3b48c2b 100644
--- a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py
+++ b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py
@@ -87,13 +87,13 @@
cache.delete(key)
def tearDown(self):
- frappe.db.set_value("Accounts Settings", None, "allow_stale", 1)
+ frappe.db.set_single_value("Accounts Settings", "allow_stale", 1)
self.clear_cache()
def test_exchange_rate(self, mock_get):
save_new_records(test_records)
- frappe.db.set_value("Accounts Settings", None, "allow_stale", 1)
+ frappe.db.set_single_value("Accounts Settings", "allow_stale", 1)
# Start with allow_stale is True
exchange_rate = get_exchange_rate("USD", "INR", "2016-01-01", "for_buying")
@@ -124,7 +124,7 @@
settings.save()
# Update exchange
- frappe.db.set_value("Accounts Settings", None, "allow_stale", 1)
+ frappe.db.set_single_value("Accounts Settings", "allow_stale", 1)
# Start with allow_stale is True
exchange_rate = get_exchange_rate("USD", "INR", "2016-01-01", "for_buying")
@@ -152,8 +152,8 @@
def test_exchange_rate_strict(self, mock_get):
# strict currency settings
- frappe.db.set_value("Accounts Settings", None, "allow_stale", 0)
- frappe.db.set_value("Accounts Settings", None, "stale_days", 1)
+ frappe.db.set_single_value("Accounts Settings", "allow_stale", 0)
+ frappe.db.set_single_value("Accounts Settings", "stale_days", 1)
exchange_rate = get_exchange_rate("USD", "INR", "2016-01-01", "for_buying")
self.assertEqual(exchange_rate, 60.0)
@@ -175,8 +175,8 @@
exchange_rate = get_exchange_rate("USD", "INR", "2016-01-15", "for_buying")
self.assertEqual(exchange_rate, 65.1)
- frappe.db.set_value("Accounts Settings", None, "allow_stale", 0)
- frappe.db.set_value("Accounts Settings", None, "stale_days", 1)
+ frappe.db.set_single_value("Accounts Settings", "allow_stale", 0)
+ frappe.db.set_single_value("Accounts Settings", "stale_days", 1)
self.clear_cache()
exchange_rate = get_exchange_rate("USD", "INR", "2016-01-30", "for_buying")
diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py
index 74c1ee2..013d945 100644
--- a/erpnext/setup/install.py
+++ b/erpnext/setup/install.py
@@ -211,7 +211,7 @@
def add_app_name():
- frappe.db.set_value("System Settings", None, "app_name", "ERPNext")
+ frappe.db.set_single_value("System Settings", "app_name", "ERPNext")
def setup_log_settings():
diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
index 15a72a8..8baae8a 100644
--- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
@@ -43,7 +43,7 @@
class TestDeliveryNote(FrappeTestCase):
def test_over_billing_against_dn(self):
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
dn = create_delivery_note(do_not_submit=True)
self.assertRaises(frappe.ValidationError, make_sales_invoice, dn.name)
@@ -709,7 +709,7 @@
# Testing if Customer's Purchase Order No was rightly copied
self.assertEqual(so.po_no, si.po_no)
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
dn1 = make_delivery_note(so.name)
dn1.get("items")[0].qty = 2
@@ -741,7 +741,7 @@
make_sales_invoice as make_sales_invoice_from_so,
)
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
so = make_sales_order()
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index f91a991..93d799a 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -585,7 +585,7 @@
existing_allow_negative_stock = frappe.db.get_value(
"Stock Settings", None, "allow_negative_stock"
)
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
repost_stock_for_warehouses = frappe.get_all(
"Stock Ledger Entry",
@@ -601,8 +601,8 @@
for warehouse in repost_stock_for_warehouses:
repost_stock(new_name, warehouse)
- frappe.db.set_value(
- "Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock
+ frappe.db.set_single_value(
+ "Stock Settings", "allow_negative_stock", existing_allow_negative_stock
)
def update_bom_item_desc(self):
diff --git a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
index 03ff12c..257f263 100644
--- a/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
+++ b/erpnext/stock/doctype/landed_cost_voucher/test_landed_cost_voucher.py
@@ -25,7 +25,7 @@
class TestLandedCostVoucher(FrappeTestCase):
def test_landed_cost_voucher(self):
- frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
+ frappe.db.set_single_value("Buying Settings", "allow_multiple_items", 1)
pr = make_purchase_receipt(
company="_Test Company with perpetual inventory",
diff --git a/erpnext/stock/doctype/material_request/test_material_request.py b/erpnext/stock/doctype/material_request/test_material_request.py
index 03f58c6..e5aff38 100644
--- a/erpnext/stock/doctype/material_request/test_material_request.py
+++ b/erpnext/stock/doctype/material_request/test_material_request.py
@@ -400,7 +400,7 @@
mr.insert()
mr.submit()
- frappe.db.set_value("Stock Settings", None, "mr_qty_allowance", 20)
+ frappe.db.set_single_value("Stock Settings", "mr_qty_allowance", 20)
# map a stock entry
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index c0ea806..92235b0 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -27,7 +27,7 @@
class TestPurchaseReceipt(FrappeTestCase):
def setUp(self):
- frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
+ frappe.db.set_single_value("Buying Settings", "allow_multiple_items", 1)
def test_purchase_receipt_received_qty(self):
"""
@@ -1925,7 +1925,7 @@
if not frappe.db.exists("Location", "Test Location"):
frappe.get_doc({"doctype": "Location", "location_name": "Test Location"}).insert()
- frappe.db.set_value("Buying Settings", None, "allow_multiple_items", 1)
+ frappe.db.set_single_value("Buying Settings", "allow_multiple_items", 1)
pr = frappe.new_doc("Purchase Receipt")
args = frappe._dict(args)
pr.posting_date = args.posting_date or today()
diff --git a/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py b/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py
index 9d2e139..f5f8c3a 100644
--- a/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py
+++ b/erpnext/stock/doctype/quality_inspection/test_quality_inspection.py
@@ -167,13 +167,13 @@
reference_type="Stock Entry", reference_name=se.name, readings=readings, status="Rejected"
)
- frappe.db.set_value("Stock Settings", None, "action_if_quality_inspection_is_rejected", "Stop")
+ frappe.db.set_single_value("Stock Settings", "action_if_quality_inspection_is_rejected", "Stop")
se.reload()
self.assertRaises(
QualityInspectionRejectedError, se.submit
) # when blocked in Stock settings, block rejected QI
- frappe.db.set_value("Stock Settings", None, "action_if_quality_inspection_is_rejected", "Warn")
+ frappe.db.set_single_value("Stock Settings", "action_if_quality_inspection_is_rejected", "Warn")
se.reload()
se.submit() # when allowed in Stock settings, allow rejected QI
@@ -182,7 +182,7 @@
qa.cancel()
se.reload()
se.cancel()
- frappe.db.set_value("Stock Settings", None, "action_if_quality_inspection_is_rejected", "Stop")
+ frappe.db.set_single_value("Stock Settings", "action_if_quality_inspection_is_rejected", "Stop")
def test_qi_status(self):
make_stock_entry(
diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
index 64d81f6..cc8a108 100644
--- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
@@ -55,7 +55,7 @@
frappe.set_user("Administrator")
def test_fifo(self):
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
item_code = "_Test Item 2"
warehouse = "_Test Warehouse - _TC"
@@ -142,7 +142,7 @@
or 0
)
- frappe.db.set_value("Stock Settings", None, "auto_indent", 1)
+ frappe.db.set_single_value("Stock Settings", "auto_indent", 1)
# update re-level qty so that it is more than projected_qty
if projected_qty >= variant.reorder_levels[0].warehouse_reorder_level:
@@ -154,7 +154,7 @@
mr_list = reorder_item()
- frappe.db.set_value("Stock Settings", None, "auto_indent", 0)
+ frappe.db.set_single_value("Stock Settings", "auto_indent", 0)
items = []
for mr in mr_list:
@@ -792,24 +792,24 @@
remove_user_permission("Company", "_Test Company 1", "test2@example.com")
def test_freeze_stocks(self):
- frappe.db.set_value("Stock Settings", None, "stock_auth_role", "")
+ frappe.db.set_single_value("Stock Settings", "stock_auth_role", "")
# test freeze_stocks_upto
- frappe.db.set_value("Stock Settings", None, "stock_frozen_upto", add_days(nowdate(), 5))
+ frappe.db.set_single_value("Stock Settings", "stock_frozen_upto", add_days(nowdate(), 5))
se = frappe.copy_doc(test_records[0]).insert()
self.assertRaises(StockFreezeError, se.submit)
- frappe.db.set_value("Stock Settings", None, "stock_frozen_upto", "")
+ frappe.db.set_single_value("Stock Settings", "stock_frozen_upto", "")
# test freeze_stocks_upto_days
- frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", -1)
+ frappe.db.set_single_value("Stock Settings", "stock_frozen_upto_days", -1)
se = frappe.copy_doc(test_records[0])
se.set_posting_time = 1
se.posting_date = nowdate()
se.set_stock_entry_type()
se.insert()
self.assertRaises(StockFreezeError, se.submit)
- frappe.db.set_value("Stock Settings", None, "stock_frozen_upto_days", 0)
+ frappe.db.set_single_value("Stock Settings", "stock_frozen_upto_days", 0)
def test_work_order(self):
from erpnext.manufacturing.doctype.work_order.work_order import (
@@ -1211,7 +1211,7 @@
)
def test_conversion_factor_change(self):
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
repack_entry = frappe.copy_doc(test_records[3])
repack_entry.posting_date = nowdate()
repack_entry.posting_time = nowtime()
diff --git a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py
index a398855..f7c6ffe 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/test_stock_ledger_entry.py
@@ -416,8 +416,8 @@
def test_back_dated_entry_not_allowed(self):
# Back dated stock transactions are only allowed to stock managers
- frappe.db.set_value(
- "Stock Settings", None, "role_allowed_to_create_edit_back_dated_transactions", "Stock Manager"
+ frappe.db.set_single_value(
+ "Stock Settings", "role_allowed_to_create_edit_back_dated_transactions", "Stock Manager"
)
# Set User with Stock User role but not Stock Manager
@@ -453,8 +453,8 @@
stock_entry_on_today.cancel()
finally:
- frappe.db.set_value(
- "Stock Settings", None, "role_allowed_to_create_edit_back_dated_transactions", None
+ frappe.db.set_single_value(
+ "Stock Settings", "role_allowed_to_create_edit_back_dated_transactions", None
)
frappe.set_user("Administrator")
user.remove_roles("Stock Manager")
diff --git a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
index a04e2da..4817c8d 100644
--- a/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/test_stock_reconciliation.py
@@ -33,7 +33,7 @@
def setUpClass(cls):
create_batch_or_serial_no_items()
super().setUpClass()
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
def tearDown(self):
frappe.local.future_sle = {}
diff --git a/erpnext/stock/doctype/stock_settings/test_stock_settings.py b/erpnext/stock/doctype/stock_settings/test_stock_settings.py
index 974e163..cda739e 100644
--- a/erpnext/stock/doctype/stock_settings/test_stock_settings.py
+++ b/erpnext/stock/doctype/stock_settings/test_stock_settings.py
@@ -10,7 +10,7 @@
class TestStockSettings(FrappeTestCase):
def setUp(self):
super().setUp()
- frappe.db.set_value("Stock Settings", None, "clean_description_html", 0)
+ frappe.db.set_single_value("Stock Settings", "clean_description_html", 0)
def test_settings(self):
item = frappe.get_doc(
diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py
index 4886755..a4fe2ee 100644
--- a/erpnext/stock/stock_balance.py
+++ b/erpnext/stock/stock_balance.py
@@ -18,7 +18,7 @@
existing_allow_negative_stock = frappe.db.get_value(
"Stock Settings", None, "allow_negative_stock"
)
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
+ frappe.db.set_single_value("Stock Settings", "allow_negative_stock", 1)
item_warehouses = frappe.db.sql(
"""
@@ -37,8 +37,8 @@
frappe.db.rollback()
if allow_negative_stock:
- frappe.db.set_value(
- "Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock
+ frappe.db.set_single_value(
+ "Stock Settings", "allow_negative_stock", existing_allow_negative_stock
)
frappe.db.auto_commit_on_many_writes = 0
diff --git a/erpnext/support/doctype/issue/test_issue.py b/erpnext/support/doctype/issue/test_issue.py
index a440124..b30b699 100644
--- a/erpnext/support/doctype/issue/test_issue.py
+++ b/erpnext/support/doctype/issue/test_issue.py
@@ -20,7 +20,7 @@
frappe.db.sql("delete from `tabSLA Fulfilled On Status`")
frappe.db.sql("delete from `tabPause SLA On Status`")
frappe.db.sql("delete from `tabService Day`")
- frappe.db.set_value("Support Settings", None, "track_service_level_agreement", 1)
+ frappe.db.set_single_value("Support Settings", "track_service_level_agreement", 1)
create_service_level_agreements_for_issues()
diff --git a/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py
index 472f6bc..1f8f4a2 100644
--- a/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py
+++ b/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py
@@ -16,7 +16,7 @@
class TestServiceLevelAgreement(unittest.TestCase):
def setUp(self):
self.create_company()
- frappe.db.set_value("Support Settings", None, "track_service_level_agreement", 1)
+ frappe.db.set_single_value("Support Settings", "track_service_level_agreement", 1)
lead = frappe.qb.DocType("Lead")
frappe.qb.from_(lead).delete().where(lead.company == self.company).run()
diff --git a/erpnext/support/report/issue_analytics/test_issue_analytics.py b/erpnext/support/report/issue_analytics/test_issue_analytics.py
index 169392e..e30b31b 100644
--- a/erpnext/support/report/issue_analytics/test_issue_analytics.py
+++ b/erpnext/support/report/issue_analytics/test_issue_analytics.py
@@ -17,7 +17,7 @@
@classmethod
def setUpClass(self):
frappe.db.sql("delete from `tabIssue` where company='_Test Company'")
- frappe.db.set_value("Support Settings", None, "track_service_level_agreement", 1)
+ frappe.db.set_single_value("Support Settings", "track_service_level_agreement", 1)
current_month_date = getdate()
last_month_date = add_months(current_month_date, -1)
diff --git a/erpnext/tests/test_exotel.py b/erpnext/tests/test_exotel.py
index f5cca72..9b91414 100644
--- a/erpnext/tests/test_exotel.py
+++ b/erpnext/tests/test_exotel.py
@@ -12,7 +12,7 @@
cls.test_employee_name = make_employee(
user="test_employee_exotel@company.com", cell_number="9999999999"
)
- frappe.db.set_value("Exotel Settings", "Exotel Settings", "enabled", 1)
+ frappe.db.set_single_value("Exotel Settings", "enabled", 1)
phones = [{"phone": "+91 9999999991", "is_primary_phone": 0, "is_primary_mobile_no": 1}]
create_contact(name="Test Contact", salutation="Mr", phones=phones)
frappe.db.commit()