fix: ensure that frappe.db.get_defaults works for all parents (#17296)
fix: ensure that frappe.db.get_defaults` for all parents, as designed
This commit is contained in:
parent
0a8a91e30b
commit
fc99c22ea2
2 changed files with 6 additions and 9 deletions
|
|
@ -933,14 +933,11 @@ class Database:
|
|||
@staticmethod
|
||||
def get_defaults(key=None, parent="__default"):
|
||||
"""Get all defaults"""
|
||||
if key:
|
||||
defaults = frappe.defaults.get_defaults(parent)
|
||||
d = defaults.get(key, None)
|
||||
if not d and key != frappe.scrub(key):
|
||||
d = defaults.get(frappe.scrub(key), None)
|
||||
return d
|
||||
else:
|
||||
return frappe.defaults.get_defaults(parent)
|
||||
defaults = frappe.defaults.get_defaults_for(parent)
|
||||
if not key:
|
||||
return defaults
|
||||
|
||||
return defaults.get(key) or defaults.get(frappe.scrub(key))
|
||||
|
||||
def begin(self):
|
||||
self.sql("START TRANSACTION")
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ def get_defaults_for(parent="__default"):
|
|||
.run(as_dict=True)
|
||||
)
|
||||
|
||||
defaults = frappe._dict({})
|
||||
defaults = frappe._dict()
|
||||
for d in res:
|
||||
if d.defkey in defaults:
|
||||
# listify
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue