fix(ux): move get_route_options_for_new_doc to refresh (#37096)

fix: move `get_route_options_for_new_doc` to `refresh`
This commit is contained in:
HENRY Florian 2023-09-16 12:29:09 +02:00 committed by GitHub
parent fc016680c9
commit 34bb64e41a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 117 additions and 110 deletions

View File

@ -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) => {

View File

@ -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) {

View File

@ -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();

View File

@ -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);
},

View File

@ -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");

View File

@ -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',

View File

@ -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) {

View File

@ -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();
},
});
}
}