fix: functions using mutable defaults (#25370)
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index c0c1315..bc1ac5e 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -713,7 +713,9 @@
return [(d,) for d in set(taxes)]
-def get_fields(doctype, fields=[]):
+def get_fields(doctype, fields=None):
+ if fields is None:
+ fields = []
meta = frappe.get_meta(doctype)
fields.extend(meta.get_search_fields())
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index 0987d09..cdb6d24 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -371,10 +371,12 @@
ref_doc.db_set("per_billed", per_billed)
ref_doc.set_status(update=True)
-def get_allowance_for(item_code, item_allowance={}, global_qty_allowance=None, global_amount_allowance=None, qty_or_amount="qty"):
+def get_allowance_for(item_code, item_allowance=None, global_qty_allowance=None, global_amount_allowance=None, qty_or_amount="qty"):
"""
Returns the allowance for the item, if not set, returns global allowance
"""
+ if item_allowance is None:
+ item_allowance = {}
if qty_or_amount == "qty":
if item_allowance.get(item_code, frappe._dict()).get("qty"):
return item_allowance[item_code].qty, item_allowance, global_qty_allowance, global_amount_allowance
diff --git a/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py b/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py
index 742d18c..8fbcd4e 100644
--- a/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py
+++ b/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py
@@ -53,7 +53,9 @@
rate=%s, amount=stock_qty*%s where bom_no = %s and docstatus < 2 and parenttype='BOM'""",
(self.new_bom, unit_cost, unit_cost, self.current_bom))
- def get_parent_boms(self, bom, bom_list=[]):
+ def get_parent_boms(self, bom, bom_list=None):
+ if bom_list is None:
+ bom_list = []
data = frappe.db.sql("""SELECT DISTINCT parent FROM `tabBOM Item`
WHERE bom_no = %s AND docstatus < 2 AND parenttype='BOM'""", bom)
@@ -106,4 +108,4 @@
for bom in bom_list:
frappe.get_doc("BOM", bom).update_cost(update_parent=False, from_child_bom=True)
- frappe.db.auto_commit_on_many_writes = 0
\ No newline at end of file
+ frappe.db.auto_commit_on_many_writes = 0