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:
rohitwaghchaure 2021-05-07 23:30:27 +05:30 committed by GitHub
commit 64bd4f27b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,6 +76,7 @@ class StockEntry(StockController):
self.validate_difference_account()
self.set_job_card_data()
self.set_purpose_for_stock_entry()
self.validate_duplicate_serial_no()
if not self.from_bom:
self.fg_completed_qty = 0.0
@ -587,6 +588,22 @@ class StockEntry(StockController):
self.purpose = frappe.get_cached_value('Stock Entry Type',
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):
"""Throw exception if more raw material is transferred against Purchase Order than in
the raw materials supplied table"""