fix: auto fetch batch and serial no for draft stock transactions

(cherry picked from commit 88ab9be79c)

# Conflicts:
#	erpnext/stock/get_item_details.py
This commit is contained in:
Rohit Waghchaure
2025-01-13 16:34:08 +05:30
committed by Mergify
parent f954b241a8
commit 2f2554e9e5
5 changed files with 191 additions and 4 deletions

View File

@@ -777,7 +777,14 @@ class AccountsController(TransactionBase):
ret = get_item_details(args, self, for_validate=for_validate, overwrite_warehouse=False)
for fieldname, value in ret.items():
if item.meta.get_field(fieldname) and value is not None:
if item.get(fieldname) is None or fieldname in force_item_fields:
if (
item.get(fieldname) is None
or fieldname in force_item_fields
or (
fieldname in ["serial_no", "batch_no"]
and item.get("use_serial_batch_fields")
)
):
item.set(fieldname, value)
elif fieldname in ["cost_center", "conversion_factor"] and not item.get(