Merge pull request #23970 from rohitwaghchaure/incorrect-delink-serial-no-and-batch-v13-pre-release

fix: incorrect delink serial no and batch
This commit is contained in:
rohitwaghchaure 2020-11-20 14:30:27 +05:30 committed by GitHub
commit 2d21473e61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -247,16 +247,17 @@ class StockController(AccountsController):
for d in self.items:
if not d.batch_no: continue
serial_nos = [sr.name for sr in frappe.get_all("Serial No",
{'batch_no': d.batch_no, 'status': 'Inactive'})]
if serial_nos:
frappe.db.set_value("Serial No", { 'name': ['in', serial_nos] }, "batch_no", None)
d.batch_no = None
d.db_set("batch_no", None)
for data in frappe.get_all("Batch",
{'reference_name': self.name, 'reference_doctype': self.doctype}):
serial_nos = [sr.name for sr in frappe.get_all("Serial No", {'batch_no': data.name})]
if serial_nos:
frappe.db.set_value("Serial No", { 'name': ['in', serial_nos] }, "batch_no", None)
frappe.delete_doc("Batch", data.name)
def get_sl_entries(self, d, args):