Skip to content

Commit 943ddff

Browse files
fix: inventory dimension patch (backport #54147) (#54149)
Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com> fix: inventory dimension patch (#54147)
1 parent 5866fc6 commit 943ddff

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

erpnext/patches/v16_0/depends_on_inv_dimensions.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,28 @@ def get_inventory_dimensions():
1616
)
1717

1818

19-
def get_display_depends_on(doctype):
19+
def get_display_depends_on(doctype, fieldname):
2020
if doctype not in [
2121
"Stock Entry Detail",
2222
"Sales Invoice Item",
2323
"Delivery Note Item",
2424
"Purchase Invoice Item",
2525
"Purchase Receipt Item",
2626
]:
27-
return
27+
return None, None
2828

29+
fieldname_start_with = "to"
2930
display_depends_on = ""
3031

3132
if doctype in ["Purchase Invoice Item", "Purchase Receipt Item"]:
3233
display_depends_on = "eval:parent.is_internal_supplier == 1"
34+
fieldname_start_with = "from"
3335
elif doctype != "Stock Entry Detail":
3436
display_depends_on = "eval:parent.is_internal_customer == 1"
3537
elif doctype == "Stock Entry Detail":
3638
display_depends_on = "eval:doc.t_warehouse"
3739

38-
return display_depends_on
40+
return f"{fieldname_start_with}_{fieldname}", display_depends_on
3941

4042

4143
def execute():
@@ -75,13 +77,13 @@ def execute():
7577
"depends_on",
7678
"eval:doc.t_warehouse",
7779
)
78-
if (display_depends_on := get_display_depends_on(dimension.doctype)) and frappe.db.exists(
79-
"Custom Field",
80-
{"fieldname": dimension.fieldname, "dt": dimension.doctype},
80+
fieldname, display_depends_on = get_display_depends_on(dimension.doctype, dimension.fieldname)
81+
if display_depends_on and frappe.db.exists(
82+
"Custom Field", {"fieldname": fieldname, "dt": dimension.doctype}
8183
):
8284
frappe.set_value(
8385
"Custom Field",
84-
{"fieldname": dimension.fieldname, "dt": dimension.doctype},
86+
{"fieldname": fieldname, "dt": dimension.doctype},
8587
"mandatory_depends_on",
8688
display_depends_on if dimension.reqd else dimension.mandatory_depends_on,
8789
)

0 commit comments

Comments
 (0)