From 2c121245500cd7bb2ce37da85dfd650d4a235b5c Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Fri, 15 Jan 2021 10:10:54 +0530 Subject: [PATCH] Revert "fix: Item Price using batch selector" This reverts commit 34c58529d9b4515cc4ae067ea7d6b73d2dcb6103. --- erpnext/public/js/controllers/buying.js | 4 ++++ erpnext/public/js/controllers/transaction.js | 9 ++++++--- erpnext/public/js/utils/serial_no_batch_selector.js | 9 +++------ erpnext/selling/sales_common.js | 6 ++++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index db85a3ec99e..fcd7c15a7ca 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -195,6 +195,10 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ this._super(doc, cdt, cdn); }, + batch_no: function(doc, cdt, cdn) { + this._super(doc, cdt, cdn); + }, + received_qty: function(doc, cdt, cdn) { this.calculate_accepted_qty(doc, cdt, cdn) }, diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index bb122c1fe09..32bd5028a7a 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1124,6 +1124,11 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }, + batch_no: function(doc, cdt, cdn) { + let item = frappe.get_doc(cdt, cdn); + this.apply_price_list(item, true); + }, + toggle_conversion_factor: function(item) { // toggle read only property for conversion factor field if the uom and stock uom are same if(this.frm.get_field('items').grid.fields_map.conversion_factor) { @@ -1540,9 +1545,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ return; } - let for_batch = (item && item.batch_no) ? true : false; - - if (me.in_apply_price_list == true && (!for_batch)) return; + if (me.in_apply_price_list == true) return; me.in_apply_price_list = true; return this.frm.call({ diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js index cd2f9509e5b..2623c3c1a73 100644 --- a/erpnext/public/js/utils/serial_no_batch_selector.js +++ b/erpnext/public/js/utils/serial_no_batch_selector.js @@ -154,7 +154,7 @@ erpnext.SerialNoBatchSelector = Class.extend({ if (this.item.serial_no) { this.dialog.fields_dict.serial_no.set_value(this.item.serial_no); } - + if (this.has_batch && !this.has_serial_no && d.batch_no) { this.frm.doc.items.forEach(data => { if(data.item_code == d.item_code) { @@ -220,7 +220,6 @@ erpnext.SerialNoBatchSelector = Class.extend({ if (i !== 0 && !this.batch_exists(batch_no)) { row = this.frm.add_child("items", { ...this.item }); - frappe.model.set_value(row.doctype, row.name, 'batch_no', batch_no); } else { row = this.frm.doc.items.find(i => i.batch_no === batch_no); } @@ -232,7 +231,7 @@ erpnext.SerialNoBatchSelector = Class.extend({ this.map_row_values(row, batch, 'batch_no', 'selected_qty', this.values.warehouse); }); - } + } }, update_serial_no_item() { @@ -251,7 +250,7 @@ erpnext.SerialNoBatchSelector = Class.extend({ filters: { 'name': ["in", selected_serial_nos]}, fields: ["batch_no", "name"] }).then((data) => { - // data = [{batch_no: 'batch-1', name: "SR-001"}, + // data = [{batch_no: 'batch-1', name: "SR-001"}, // {batch_no: 'batch-2', name: "SR-003"}, {batch_no: 'batch-2', name: "SR-004"}] const batch_serial_map = data.reduce((acc, d) => { if (!acc[d['batch_no']]) acc[d['batch_no']] = []; @@ -337,8 +336,6 @@ erpnext.SerialNoBatchSelector = Class.extend({ }, change: function () { const batch_no = this.get_value(); - let val = this.get_value(); - if (!batch_no) { this.grid_row.on_grid_fields_dict .available_qty.set_value(0); diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 5c3860684a7..ce084646e15 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -326,8 +326,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ }); } }) - - me.apply_price_list(item, true); }, set_dynamic_labels: function() { @@ -401,6 +399,10 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } }, + batch_no: function(doc, cdt, cdn) { + this._super(doc, cdt, cdn); + }, + qty: function(doc, cdt, cdn) { this._super(doc, cdt, cdn);