diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.js b/erpnext/assets/doctype/asset_repair/asset_repair.js index dae993a28343..03afcb944292 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.js +++ b/erpnext/assets/doctype/asset_repair/asset_repair.js @@ -40,16 +40,6 @@ frappe.ui.form.on('Asset Repair', { } } }); - - let sbb_field = frm.get_docfield('stock_items', 'serial_and_batch_bundle'); - if (sbb_field) { - sbb_field.get_route_options_for_new_doc = (row) => { - return { - 'item_code': row.doc.item_code, - 'voucher_type': frm.doc.doctype, - } - }; - } }, refresh: function(frm) { @@ -61,6 +51,16 @@ frappe.ui.form.on('Asset Repair', { frappe.set_route("query-report", "General Ledger"); }); } + + let sbb_field = frm.get_docfield('stock_items', 'serial_and_batch_bundle'); + if (sbb_field) { + sbb_field.get_route_options_for_new_doc = (row) => { + return { + 'item_code': row.doc.item_code, + 'voucher_type': frm.doc.doctype, + } + }; + } }, repair_status: (frm) => { diff --git a/erpnext/manufacturing/doctype/job_card/job_card.js b/erpnext/manufacturing/doctype/job_card/job_card.js index f1e60948130a..66212755b23d 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.js +++ b/erpnext/manufacturing/doctype/job_card/job_card.js @@ -23,17 +23,6 @@ frappe.ui.form.on('Job Card', { } }); - let sbb_field = frm.get_docfield('serial_and_batch_bundle'); - if (sbb_field) { - sbb_field.get_route_options_for_new_doc = () => { - return { - 'item_code': frm.doc.production_item, - 'warehouse': frm.doc.wip_warehouse, - 'voucher_type': frm.doc.doctype, - } - }; - } - frm.set_indicator_formatter('sub_operation', function(doc) { if (doc.status == "Pending") { @@ -124,6 +113,17 @@ frappe.ui.form.on('Job Card', { } }); } + + let sbb_field = frm.get_docfield('serial_and_batch_bundle'); + if (sbb_field) { + sbb_field.get_route_options_for_new_doc = () => { + return { + 'item_code': frm.doc.production_item, + 'warehouse': frm.doc.wip_warehouse, + 'voucher_type': frm.doc.doctype, + } + }; + } }, setup_quality_inspection: function(frm) { diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 80d7b79c1ecb..975adc2acea9 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -134,15 +134,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } } }); - - let sbb_field = this.frm.get_docfield('items', 'serial_and_batch_bundle'); - if (sbb_field) { - sbb_field.get_route_options_for_new_doc = (row) => { - return { - 'item_code': row.doc.item_code, - } - }; - } } if( @@ -207,15 +198,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe }); } - let batch_no_field = this.frm.get_docfield("items", "batch_no"); - if (batch_no_field) { - batch_no_field.get_route_options_for_new_doc = function(row) { - return { - "item": row.doc.item_code - } - }; - } - if (this.frm.fields_dict["items"].grid.get_field('blanket_order')) { this.frm.set_query("blanket_order", "items", function(doc, cdt, cdn) { var item = locals[cdt][cdn]; @@ -268,6 +250,28 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } ]); } + + if(this.frm.fields_dict['items'].grid.get_field('serial_and_batch_bundle')) { + let sbb_field = this.frm.get_docfield('items', 'serial_and_batch_bundle'); + if (sbb_field) { + sbb_field.get_route_options_for_new_doc = (row) => { + return { + 'item_code': row.doc.item_code, + } + }; + } + } + + if(this.frm.fields_dict['items'].grid.get_field('batch_no')) { + let batch_no_field = this.frm.get_docfield('items', 'batch_no'); + if (batch_no_field) { + batch_no_field.get_route_options_for_new_doc = function(row) { + return { + 'item': row.doc.item_code + } + }; + } + } } is_return() { @@ -358,7 +362,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } refresh() { - erpnext.toggle_naming_series(); erpnext.hide_company(); this.set_dynamic_labels(); diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js index dd6f8a8104e2..8128c77f8d4d 100644 --- a/erpnext/selling/doctype/installation_note/installation_note.js +++ b/erpnext/selling/doctype/installation_note/installation_note.js @@ -18,6 +18,14 @@ frappe.ui.form.on('Installation Note', { } } }); + }, + onload: function(frm) { + if(!frm.doc.status) { + frm.set_value({ status:'Draft'}); + } + if(frm.doc.__islocal) { + frm.set_value({inst_date: frappe.datetime.get_today()}); + } let sbb_field = frm.get_docfield('items', 'serial_and_batch_bundle'); if (sbb_field) { @@ -29,14 +37,6 @@ frappe.ui.form.on('Installation Note', { }; } }, - onload: function(frm) { - if(!frm.doc.status) { - frm.set_value({ status:'Draft'}); - } - if(frm.doc.__islocal) { - frm.set_value({inst_date: frappe.datetime.get_today()}); - } - }, customer: function(frm) { erpnext.utils.get_party_details(frm); }, diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index d18f70ade6de..1bc8d6857e97 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -48,6 +48,11 @@ frappe.ui.form.on('Quotation', { } } }); + }, + + refresh: function(frm) { + frm.trigger("set_label"); + frm.trigger("set_dynamic_field_label"); let sbb_field = frm.get_docfield('packed_items', 'serial_and_batch_bundle'); if (sbb_field) { @@ -61,11 +66,6 @@ frappe.ui.form.on('Quotation', { } }, - refresh: function(frm) { - frm.trigger("set_label"); - frm.trigger("set_dynamic_field_label"); - }, - quotation_to: function(frm) { frm.trigger("set_label"); frm.trigger("toggle_reqd_lead_customer"); diff --git a/erpnext/stock/doctype/pick_list/pick_list.js b/erpnext/stock/doctype/pick_list/pick_list.js index 4eed285fdab4..ae05b80727f2 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.js +++ b/erpnext/stock/doctype/pick_list/pick_list.js @@ -65,17 +65,6 @@ frappe.ui.form.on('Pick List', { } } }); - - let sbb_field = frm.get_docfield('locations', 'serial_and_batch_bundle'); - if (sbb_field) { - sbb_field.get_route_options_for_new_doc = (row) => { - return { - 'item_code': row.doc.item_code, - 'warehouse': row.doc.warehouse, - 'voucher_type': frm.doc.doctype, - } - }; - } }, set_item_locations:(frm, save) => { if (!(frm.doc.locations && frm.doc.locations.length)) { @@ -132,6 +121,17 @@ frappe.ui.form.on('Pick List', { } } } + + let sbb_field = frm.get_docfield('locations', 'serial_and_batch_bundle'); + if (sbb_field) { + sbb_field.get_route_options_for_new_doc = (row) => { + return { + 'item_code': row.doc.item_code, + 'warehouse': row.doc.warehouse, + 'voucher_type': frm.doc.doctype, + } + }; + } }, work_order: (frm) => { frappe.db.get_value('Work Order', diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 4fb8a10748eb..d37e8ee599b1 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -117,15 +117,6 @@ frappe.ui.form.on('Stock Entry', { } }); - let sbb_field = frm.get_docfield('items', 'serial_and_batch_bundle'); - if (sbb_field) { - sbb_field.get_route_options_for_new_doc = (row) => { - return { - 'item_code': row.doc.item_code, - 'voucher_type': frm.doc.doctype, - } - }; - } frm.add_fetch("bom_no", "inspection_required", "inspection_required"); erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); @@ -362,6 +353,16 @@ frappe.ui.form.on('Stock Entry', { if(!check_should_not_attach_bom_items(frm.doc.bom_no)) { erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); } + + let sbb_field = frm.get_docfield('items', 'serial_and_batch_bundle'); + if (sbb_field) { + sbb_field.get_route_options_for_new_doc = (row) => { + return { + 'item_code': row.doc.item_code, + 'voucher_type': frm.doc.doctype, + } + }; + } }, get_items_from_transit_entry: function(frm) { diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js index 8ac22e6f1bf7..19a1c939c3ee 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.js @@ -77,6 +77,7 @@ frappe.ui.form.on('Subcontracting Receipt', { } frm.trigger('setup_quality_inspection'); + frm.trigger('set_route_options_for_new_doc'); }, set_warehouse: (frm) => { @@ -87,6 +88,23 @@ frappe.ui.form.on('Subcontracting Receipt', { set_warehouse_in_children(frm.doc.items, 'rejected_warehouse', frm.doc.rejected_warehouse); }, + get_scrap_items: (frm) => { + frappe.call({ + doc: frm.doc, + method: 'get_scrap_items', + args: { + recalculate_rate: true + }, + freeze: true, + freeze_message: __('Getting Scrap Items'), + callback: (r) => { + if (!r.exc) { + frm.refresh(); + } + } + }); + }, + set_queries: (frm) => { frm.set_query('set_warehouse', () => { return { @@ -173,7 +191,28 @@ frappe.ui.form.on('Subcontracting Receipt', { } } }); + }, + + get_serial_and_batch_bundle_filters: (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, + } + } + }, + + setup_quality_inspection: (frm) => { + if (!frm.is_new() && frm.doc.docstatus === 0 && !frm.doc.is_return) { + let transaction_controller = new erpnext.TransactionController({ frm: frm }); + transaction_controller.setup_quality_inspection(); + } + }, + set_route_options_for_new_doc: (frm) => { let batch_no_field = frm.get_docfield('items', 'batch_no'); if (batch_no_field) { batch_no_field.get_route_options_for_new_doc = (row) => { @@ -213,42 +252,6 @@ frappe.ui.form.on('Subcontracting Receipt', { } } }, - - get_serial_and_batch_bundle_filters: (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, - } - } - }, - - setup_quality_inspection: (frm) => { - if (!frm.is_new() && frm.doc.docstatus === 0 && !frm.doc.is_return) { - let transaction_controller = new erpnext.TransactionController({ frm: frm }); - transaction_controller.setup_quality_inspection(); - } - }, - - get_scrap_items: (frm) => { - frappe.call({ - doc: frm.doc, - method: 'get_scrap_items', - args: { - recalculate_rate: true - }, - freeze: true, - freeze_message: __('Getting Scrap Items'), - callback: (r) => { - if (!r.exc) { - frm.refresh(); - } - } - }); - }, }); frappe.ui.form.on('Landed Cost Taxes and Charges', { @@ -303,4 +306,4 @@ let set_missing_values = (frm) => { if (!r.exc) frm.refresh(); }, }); -} \ No newline at end of file +}