Merge pull request #40388 from GursheenK/promotional-scheme-recurse-for
feat: add recursion qty field in promotional scheme
diff --git a/erpnext/public/js/controllers/stock_controller.js b/erpnext/public/js/controllers/stock_controller.js
index e9c409e..3181d76 100644
--- a/erpnext/public/js/controllers/stock_controller.js
+++ b/erpnext/public/js/controllers/stock_controller.js
@@ -11,6 +11,18 @@
}
}
+ barcode(doc, cdt, cdn) {
+ let row = locals[cdt][cdn];
+ if (row.barcode) {
+ erpnext.stock.utils.set_item_details_using_barcode(this.frm, row, (r) => {
+ frappe.model.set_value(cdt, cdn, {
+ "item_code": r.message.item_code,
+ "qty": 1,
+ });
+ });
+ }
+ }
+
setup_warehouse_query() {
var me = this;
erpnext.queries.setup_queries(this.frm, "Warehouse", function() {
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index ae32ccd..0e6bd5f 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -411,6 +411,19 @@
barcode_scanner.process_scan();
}
+ barcode(doc, cdt, cdn) {
+ let row = locals[cdt][cdn];
+ if (row.barcode) {
+ erpnext.stock.utils.set_item_details_using_barcode(this.frm, row, (r) => {
+ debugger
+ frappe.model.set_value(cdt, cdn, {
+ "item_code": r.message.item_code,
+ "qty": 1,
+ });
+ });
+ }
+ }
+
validate_has_items () {
let table = this.frm.doc.items;
this.frm.has_items = (table && table.length
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index f17f60a..7655ad9 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -2,6 +2,7 @@
// License: GNU General Public License v3. See license.txt
frappe.provide("erpnext");
frappe.provide("erpnext.utils");
+frappe.provide("erpnext.stock.utils");
$.extend(erpnext, {
get_currency: function (company) {
@@ -1201,3 +1202,10 @@
context.show_serial_batch_selector(grid_row.frm, grid_row.doc, "", "", true);
});
}
+
+$.extend(erpnext.stock.utils, {
+ set_item_details_using_barcode(frm, child_row, callback) {
+ const barcode_scanner = new erpnext.utils.BarcodeScanner({ frm: frm });
+ barcode_scanner.scan_api_call(child_row.barcode, callback);
+ },
+});
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index b5189b8..9fcda0d 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -2101,6 +2101,46 @@
self.assertFalse(row.warehouse == rejected_warehouse)
self.assertTrue(row.warehouse == warehouse)
+ def test_pick_list_for_batch(self):
+ from erpnext.stock.doctype.pick_list.pick_list import create_delivery_note
+
+ batch_item = make_item(
+ "_Test Batch Item for Pick LIST",
+ properties={
+ "has_batch_no": 1,
+ "create_new_batch": 1,
+ "batch_number_series": "BATCH-SDDTBIFRM-.#####",
+ },
+ ).name
+
+ warehouse = "_Test Warehouse - _TC"
+ se = make_stock_entry(item_code=batch_item, qty=10, target=warehouse, use_serial_batch_fields=1)
+ so = make_sales_order(item_code=batch_item, qty=10, warehouse=warehouse)
+ pick_list = create_pick_list(so.name)
+
+ pick_list.save()
+ batch_no = frappe.get_all(
+ "Serial and Batch Entry",
+ filters={"parent": se.items[0].serial_and_batch_bundle},
+ fields=["batch_no"],
+ )[0].batch_no
+
+ for row in pick_list.locations:
+ self.assertEqual(row.qty, 10.0)
+ self.assertTrue(row.warehouse == warehouse)
+ self.assertTrue(row.batch_no == batch_no)
+
+ pick_list.submit()
+
+ dn = create_delivery_note(pick_list.name)
+ for row in dn.items:
+ self.assertEqual(row.qty, 10.0)
+ self.assertTrue(row.warehouse == warehouse)
+ self.assertTrue(row.batch_no == batch_no)
+
+ dn.submit()
+ dn.reload()
+
def automatically_fetch_payment_terms(enable=1):
accounts_settings = frappe.get_doc("Accounts Settings")
diff --git a/erpnext/stock/serial_batch_bundle.py b/erpnext/stock/serial_batch_bundle.py
index 12df0fab..4e87fa0 100644
--- a/erpnext/stock/serial_batch_bundle.py
+++ b/erpnext/stock/serial_batch_bundle.py
@@ -599,6 +599,7 @@
elif self.sle.voucher_no:
query = query.where(parent.voucher_no != self.sle.voucher_no)
+ query = query.where(parent.voucher_type != "Pick List")
if timestamp_condition:
query = query.where(timestamp_condition)