mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
Merge pull request #25611 from rohitwaghchaure/validation-to-check-duplicate-serial-nos
fix: added validation in stock entry to check duplicate serial nos
This commit is contained in:
@@ -76,6 +76,7 @@ class StockEntry(StockController):
|
|||||||
self.validate_difference_account()
|
self.validate_difference_account()
|
||||||
self.set_job_card_data()
|
self.set_job_card_data()
|
||||||
self.set_purpose_for_stock_entry()
|
self.set_purpose_for_stock_entry()
|
||||||
|
self.validate_duplicate_serial_no()
|
||||||
|
|
||||||
if not self.from_bom:
|
if not self.from_bom:
|
||||||
self.fg_completed_qty = 0.0
|
self.fg_completed_qty = 0.0
|
||||||
@@ -587,6 +588,22 @@ class StockEntry(StockController):
|
|||||||
self.purpose = frappe.get_cached_value('Stock Entry Type',
|
self.purpose = frappe.get_cached_value('Stock Entry Type',
|
||||||
self.stock_entry_type, 'purpose')
|
self.stock_entry_type, 'purpose')
|
||||||
|
|
||||||
|
def validate_duplicate_serial_no(self):
|
||||||
|
warehouse_wise_serial_nos = {}
|
||||||
|
|
||||||
|
# In case of repack the source and target serial nos could be same
|
||||||
|
for warehouse in ['s_warehouse', 't_warehouse']:
|
||||||
|
serial_nos = []
|
||||||
|
for row in self.items:
|
||||||
|
if not (row.serial_no and row.get(warehouse)): continue
|
||||||
|
|
||||||
|
for sn in get_serial_nos(row.serial_no):
|
||||||
|
if sn in serial_nos:
|
||||||
|
frappe.throw(_('The serial no {0} has added multiple times in the stock entry {1}')
|
||||||
|
.format(frappe.bold(sn), self.name))
|
||||||
|
|
||||||
|
serial_nos.append(sn)
|
||||||
|
|
||||||
def validate_purchase_order(self):
|
def validate_purchase_order(self):
|
||||||
"""Throw exception if more raw material is transferred against Purchase Order than in
|
"""Throw exception if more raw material is transferred against Purchase Order than in
|
||||||
the raw materials supplied table"""
|
the raw materials supplied table"""
|
||||||
|
|||||||
Reference in New Issue
Block a user