fix: javascript: execution blocked by undefined route options (#33405)
Some implementations of DocField.get_route_options_for_new_doc() returned no value instead of an empty object in some cases, which caused a JavaScript error.
diff --git a/erpnext/projects/doctype/project/project.js b/erpnext/projects/doctype/project/project.js
index c48ed91..f366f77 100644
--- a/erpnext/projects/doctype/project/project.js
+++ b/erpnext/projects/doctype/project/project.js
@@ -20,7 +20,7 @@
onload: function (frm) {
const so = frm.get_docfield("sales_order");
so.get_route_options_for_new_doc = () => {
- if (frm.is_new()) return;
+ if (frm.is_new()) return {};
return {
"customer": frm.doc.customer,
"project_name": frm.doc.name
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index aa57bc2..f2f1ce1 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -272,7 +272,7 @@
let quality_inspection_field = this.frm.get_docfield("items", "quality_inspection");
quality_inspection_field.get_route_options_for_new_doc = function(row) {
- if(me.frm.is_new()) return;
+ if(me.frm.is_new()) return {};
return {
"inspection_type": inspection_type,
"reference_type": me.frm.doc.doctype,
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index d4b4efa..897fca3 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -133,7 +133,7 @@
let quality_inspection_field = frm.get_docfield("items", "quality_inspection");
quality_inspection_field.get_route_options_for_new_doc = function(row) {
- if (frm.is_new()) return;
+ if (frm.is_new()) return {};
return {
"inspection_type": "Incoming",
"reference_type": frm.doc.doctype,