From 93e3fe8445f4e22e524fce88b75857eebd71ef3e Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Fri, 9 Jun 2023 10:23:45 +0530 Subject: [PATCH 1/4] fix: reset entries qty to `1` for serial item --- .../doctype/serial_and_batch_bundle/serial_and_batch_bundle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py index 7e5cac986e..cc55bd6ea8 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py @@ -133,7 +133,7 @@ class SerialandBatchBundle(Document): def calculate_total_qty(self, save=True): self.total_qty = 0.0 for d in self.entries: - d.qty = abs(d.qty) if d.qty else 0 + d.qty = 1 if self.has_serial_no and abs(d.qty) > 1 else abs(d.qty) if d.qty else 0 d.stock_value_difference = abs(d.stock_value_difference) if d.stock_value_difference else 0 if self.type_of_transaction == "Outward": d.qty *= -1 From 1d904c0a86131a23a5c9e86ef474cd63483a452e Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Fri, 9 Jun 2023 12:05:02 +0530 Subject: [PATCH 2/4] fix(ux): make qty field read-only for serial item --- .../serial_and_batch_bundle/serial_and_batch_bundle.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js index b02ad71b16..614b4662ab 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js @@ -134,6 +134,10 @@ frappe.ui.form.on('Serial and Batch Bundle', { frm.fields_dict.entries.grid.update_docfield_property( 'batch_no', 'read_only', !frm.doc.has_batch_no ); + + frm.fields_dict.entries.grid.update_docfield_property( + 'qty', 'read_only', frm.doc.has_serial_no + ); }, set_queries(frm) { From 1f28ca717ef125b0d5c09f8c57a5f0ac72806295 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Fri, 9 Jun 2023 12:06:46 +0530 Subject: [PATCH 3/4] fix(ux): set entries qty to `1` before making the field read-only --- .../serial_and_batch_bundle/serial_and_batch_bundle.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js index 614b4662ab..f28eed35cb 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js @@ -127,6 +127,14 @@ frappe.ui.form.on('Serial and Batch Bundle', { }, toggle_fields(frm) { + if (frm.doc.has_serial_no) { + frm.doc.entries.forEach(row => { + if (Math.abs(row.qty) !== 1) { + frappe.model.set_value(row.doctype, row.name, "qty", 1); + } + }) + } + frm.fields_dict.entries.grid.update_docfield_property( 'serial_no', 'read_only', !frm.doc.has_serial_no ); From b5c5a90f71bfd2246605ff5fd7233bda4b5cc87b Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Fri, 9 Jun 2023 12:20:35 +0530 Subject: [PATCH 4/4] fix(ux): set warehouse for new row --- .../serial_and_batch_bundle/serial_and_batch_bundle.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js index f28eed35cb..d50bdba3c9 100644 --- a/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js +++ b/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.js @@ -210,9 +210,9 @@ frappe.ui.form.on('Serial and Batch Bundle', { frappe.ui.form.on("Serial and Batch Entry", { - ledgers_add(frm, cdt, cdn) { + entries_add(frm, cdt, cdn) { if (frm.doc.warehouse) { - locals[cdt][cdn].warehouse = frm.doc.warehouse; + frappe.model.set_value(cdt, cdn, 'warehouse', frm.doc.warehouse); } }, }) \ No newline at end of file