fix: make inv dimen reqd only in delivery note (#54546)

(cherry picked from commit 0aadd1e3a5)

# Conflicts:
#	erpnext/patches.txt
#	erpnext/stock/doctype/inventory_dimension/inventory_dimension.py
#	erpnext/stock/doctype/packed_item/packed_item.json
This commit is contained in:
Mihir Kandoi
2026-04-27 13:58:55 +05:30
committed by Mergify
parent 8569ff67ff
commit daf4d075cf
4 changed files with 61 additions and 2 deletions

View File

@@ -433,3 +433,11 @@ erpnext.patches.v15_0.replace_http_with_https_in_sales_partner
erpnext.patches.v16_0.add_portal_redirects
erpnext.patches.v16_0.update_order_qty_and_requested_qty_based_on_mr_and_po
erpnext.patches.v16_0.depends_on_inv_dimensions
<<<<<<< HEAD
=======
erpnext.patches.v16_0.uom_category
erpnext.patches.v16_0.merge_repost_settings_to_accounts_settings
erpnext.patches.v16_0.set_root_type_in_account_categories
erpnext.patches.v16_0.scr_inv_dimension
erpnext.patches.v16_0.packed_item_inv_dimen
>>>>>>> 0aadd1e3a5 (fix: make inv dimen reqd only in delivery note (#54546))

View File

@@ -0,0 +1,27 @@
import frappe
from erpnext.stock.doctype.inventory_dimension.inventory_dimension import get_inventory_dimensions
def execute():
for dimension in get_inventory_dimensions():
if frappe.db.exists(
"Custom Field",
{
"fieldname": dimension.source_fieldname,
"dt": "Packed Item",
"reqd": 1,
},
):
frappe.set_value(
"Custom Field",
{
"fieldname": dimension.source_fieldname,
"dt": "Packed Item",
"reqd": 1,
},
{
"reqd": 0,
"mandatory_depends_on": "eval:doc.parent_detail_docname && ['Delivery Note', 'Sales Invoice', 'POS Invoice'].includes(parent.doctype)",
},
)

View File

@@ -166,6 +166,18 @@ class InventoryDimension(Document):
if label_start_with:
label = f"{label_start_with} {self.dimension_name}"
<<<<<<< HEAD
=======
mandatory_depends_on = self.mandatory_depends_on
if self.reqd:
if doctype == "Stock Entry Detail":
mandatory_depends_on = "eval:doc.s_warehouse"
elif doctype == "Subcontracting Receipt Supplied Item":
mandatory_depends_on = "eval:doc.reference_name"
elif doctype == "Packed Item":
mandatory_depends_on = "eval:doc.parent_detail_docname && ['Delivery Note', 'Sales Invoice', 'POS Invoice'].includes(parent.doctype)"
>>>>>>> 0aadd1e3a5 (fix: make inv dimen reqd only in delivery note (#54546))
dimension_fields = [
dict(
fieldname="inventory_dimension",
@@ -183,7 +195,14 @@ class InventoryDimension(Document):
depends_on="eval:doc.s_warehouse" if doctype == "Stock Entry Detail" else "",
search_index=1,
reqd=1
<<<<<<< HEAD
if self.reqd and not self.mandatory_depends_on and doctype != "Stock Entry Detail"
=======
if self.reqd
and not self.mandatory_depends_on
and doctype
not in ["Stock Entry Detail", "Subcontracting Receipt Supplied Item", "Packed Item"]
>>>>>>> 0aadd1e3a5 (fix: make inv dimen reqd only in delivery note (#54546))
else 0,
mandatory_depends_on="eval:doc.s_warehouse"
if self.reqd and doctype == "Stock Entry Detail"

View File

@@ -8,6 +8,7 @@
"parent_item",
"item_code",
"item_name",
"delivered_by_supplier",
"column_break_5",
"description",
"section_break_6",
@@ -23,7 +24,6 @@
"use_serial_batch_fields",
"column_break_11",
"serial_and_batch_bundle",
"delivered_by_supplier",
"section_break_bgys",
"serial_no",
"column_break_qlha",
@@ -118,6 +118,7 @@
"read_only": 1
},
{
"depends_on": "eval:parent.doctype !== \"Sales Order\"",
"fieldname": "section_break_9",
"fieldtype": "Section Break"
},
@@ -284,7 +285,7 @@
"label": "Use Serial No / Batch Fields"
},
{
"depends_on": "eval:doc.use_serial_batch_fields === 1",
"depends_on": "eval:doc.use_serial_batch_fields === 1 && parent.doctype !== \"Sales Order\"",
"fieldname": "section_break_bgys",
"fieldtype": "Section Break"
},
@@ -304,7 +305,11 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
<<<<<<< HEAD
"modified": "2025-07-09 19:12:45.850219",
=======
"modified": "2026-04-27 13:00:22.949296",
>>>>>>> 0aadd1e3a5 (fix: make inv dimen reqd only in delivery note (#54546))
"modified_by": "Administrator",
"module": "Stock",
"name": "Packed Item",