From 7549a5c371c318395a6375696e48155245d4c659 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Wed, 14 Jun 2023 14:58:01 +0530 Subject: [PATCH] fix(ux): add filters for SBB --- .../asset_capitalization.js | 12 ++++++++++++ .../assets/doctype/asset_repair/asset_repair.js | 12 ++++++++++++ .../manufacturing/doctype/job_card/job_card.js | 11 +++++++++++ .../installation_note/installation_note.js | 11 +++++++++++ erpnext/selling/doctype/quotation/quotation.js | 12 ++++++++++++ erpnext/stock/doctype/pick_list/pick_list.js | 17 +++++++++++++++++ .../stock/doctype/stock_entry/stock_entry.js | 12 ++++++++++++ .../stock_reconciliation.js | 12 ++++++++++++ .../subcontracting_receipt.js | 12 ++++++++++++ 9 files changed, 111 insertions(+) diff --git a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js index 5a3768585a..96f4438ef7 100644 --- a/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js +++ b/erpnext/assets/doctype/asset_capitalization/asset_capitalization.js @@ -65,6 +65,18 @@ erpnext.assets.AssetCapitalization = class AssetCapitalization extends erpnext.s }; }); + me.frm.set_query("serial_and_batch_bundle", "stock_items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); + me.frm.set_query("item_code", "stock_items", function() { return erpnext.queries.item({"is_stock_item": 1}); }); diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.js b/erpnext/assets/doctype/asset_repair/asset_repair.js index f9ed2cc344..b2ab82cbfb 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.js +++ b/erpnext/assets/doctype/asset_repair/asset_repair.js @@ -28,6 +28,18 @@ frappe.ui.form.on('Asset Repair', { } }; }; + + frm.set_query("serial_and_batch_bundle", "stock_items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); }, refresh: function(frm) { diff --git a/erpnext/manufacturing/doctype/job_card/job_card.js b/erpnext/manufacturing/doctype/job_card/job_card.js index 5305db318b..6c9338f249 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.js +++ b/erpnext/manufacturing/doctype/job_card/job_card.js @@ -12,6 +12,17 @@ frappe.ui.form.on('Job Card', { }; }); + frm.set_query("serial_and_batch_bundle", () => { + return { + filters: { + 'item_code': frm.doc.production_item, + 'voucher_type': frm.doc.doctype, + 'voucher_no': ["in", [frm.doc.name, ""]], + 'is_cancelled': 0, + } + } + }); + frm.set_indicator_formatter('sub_operation', function(doc) { if (doc.status == "Pending") { diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js index 27a3b35ccf..d63060e6e4 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.js +++ b/erpnext/selling/doctype/installation_note/installation_note.js @@ -7,6 +7,17 @@ frappe.ui.form.on('Installation Note', { frm.set_query('customer_address', erpnext.queries.address_query); frm.set_query('contact_person', erpnext.queries.contact_query); frm.set_query('customer', erpnext.queries.customer); + frm.set_query("serial_and_batch_bundle", "items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); }, onload: function(frm) { if(!frm.doc.status) { diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 2d5c3fa961..280485a833 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -34,6 +34,18 @@ frappe.ui.form.on('Quotation', { } }; }); + + frm.set_query("serial_and_batch_bundle", "packed_items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); }, refresh: function(frm) { diff --git a/erpnext/stock/doctype/pick_list/pick_list.js b/erpnext/stock/doctype/pick_list/pick_list.js index 54e263130e..acbb62d0a0 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.js +++ b/erpnext/stock/doctype/pick_list/pick_list.js @@ -12,6 +12,7 @@ frappe.ui.form.on('Pick List', { 'Delivery Note': 'Delivery Note', 'Stock Entry': 'Stock Entry', }; + frm.set_query('parent_warehouse', () => { return { filters: { @@ -20,6 +21,7 @@ frappe.ui.form.on('Pick List', { } }; }); + frm.set_query('work_order', () => { return { query: 'erpnext.stock.doctype.pick_list.pick_list.get_pending_work_orders', @@ -28,6 +30,7 @@ frappe.ui.form.on('Pick List', { } }; }); + frm.set_query('material_request', () => { return { filters: { @@ -35,9 +38,11 @@ frappe.ui.form.on('Pick List', { } }; }); + frm.set_query('item_code', 'locations', () => { return erpnext.queries.item({ "is_stock_item": 1 }); }); + frm.set_query('batch_no', 'locations', (frm, cdt, cdn) => { const row = locals[cdt][cdn]; return { @@ -48,6 +53,18 @@ frappe.ui.form.on('Pick List', { }, }; }); + + frm.set_query("serial_and_batch_bundle", "locations", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); }, set_item_locations:(frm, save) => { if (!(frm.doc.locations && frm.doc.locations.length)) { diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 2c8e7a7da4..f1aae0edeb 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -103,6 +103,18 @@ frappe.ui.form.on('Stock Entry', { } }); + frm.set_query("serial_and_batch_bundle", "items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); + frm.add_fetch("bom_no", "inspection_required", "inspection_required"); erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js index d584858cd9..56cc21cb2c 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -30,6 +30,18 @@ frappe.ui.form.on("Stock Reconciliation", { }; }); + frm.set_query("serial_and_batch_bundle", "items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); + if (frm.doc.company) { erpnext.queries.setup_queries(frm, "Warehouse", function() { return erpnext.queries.warehouse(frm.doc); diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js index 78572a66bc..bd1512b1e3 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js @@ -77,6 +77,18 @@ frappe.ui.form.on('Subcontracting Receipt', { } }); + frm.set_query("serial_and_batch_bundle", "supplied_items", (doc, cdt, cdn) => { + let row = locals[cdt][cdn]; + return { + filters: { + 'item_code': row.rm_item_code, + 'voucher_type': doc.doctype, + 'voucher_no': ["in", [doc.name, ""]], + 'is_cancelled': 0, + } + } + }); + let batch_no_field = frm.get_docfield('items', 'batch_no'); if (batch_no_field) { batch_no_field.get_route_options_for_new_doc = function(row) {