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

fix: move `get_route_options_for_new_doc` to `refresh`
This commit is contained in:
HENRY Florian
2023-09-16 11:47:26 +02:00
committed by GitHub
parent 19a227a970
commit a563fed6dc
3 changed files with 32 additions and 38 deletions

View File

@@ -119,19 +119,10 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
} }
}); });
if(this.frm.fields_dict["items"].grid.get_field('batch_no')) { if(this.frm.fields_dict['items'].grid.get_field('batch_no')) {
this.frm.set_query("batch_no", "items", function(doc, cdt, cdn) { this.frm.set_query('batch_no', 'items', function(doc, cdt, cdn) {
return me.set_query_for_batch(doc, cdt, cdn); return me.set_query_for_batch(doc, cdt, cdn);
}); });
let batch_field = this.frm.get_docfield('items', 'batch_no');
if (batch_field) {
batch_field.get_route_options_for_new_doc = (row) => {
return {
'item': row.doc.item_code
}
};
}
} }
if( if(
@@ -196,14 +187,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')) { if (this.frm.fields_dict["items"].grid.get_field('blanket_order')) {
this.frm.set_query("blanket_order", "items", function(doc, cdt, cdn) { this.frm.set_query("blanket_order", "items", function(doc, cdt, cdn) {
@@ -257,6 +240,17 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
} }
]); ]);
} }
if(this.frm.fields_dict['items'].grid.get_field('batch_no')) {
let batch_field = this.frm.get_docfield('items', 'batch_no');
if (batch_field) {
batch_field.get_route_options_for_new_doc = (row) => {
return {
'item': row.doc.item_code
}
};
}
}
} }
is_return() { is_return() {

View File

@@ -101,15 +101,6 @@ frappe.ui.form.on('Stock Entry', {
} }
}); });
let batch_field = frm.get_docfield('items', 'batch_no');
if (batch_field) {
batch_field.get_route_options_for_new_doc = (row) => {
return {
'item': row.doc.item_code
}
};
}
frm.add_fetch("bom_no", "inspection_required", "inspection_required"); frm.add_fetch("bom_no", "inspection_required", "inspection_required");
erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype);
@@ -345,6 +336,15 @@ frappe.ui.form.on('Stock Entry', {
if(!check_should_not_attach_bom_items(frm.doc.bom_no)) { if(!check_should_not_attach_bom_items(frm.doc.bom_no)) {
erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); erpnext.accounts.dimensions.update_dimension(frm, frm.doctype);
} }
let batch_field = frm.get_docfield('items', 'batch_no');
if (batch_field) {
batch_field.get_route_options_for_new_doc = (row) => {
return {
'item': row.doc.item_code
}
};
}
}, },
get_items_from_transit_entry: function(frm) { get_items_from_transit_entry: function(frm) {

View File

@@ -75,15 +75,6 @@ frappe.ui.form.on('Subcontracting Receipt', {
} }
} }
}); });
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) {
return {
'item': row.doc.item_code
}
};
}
}, },
refresh: (frm) => { refresh: (frm) => {
@@ -148,6 +139,15 @@ frappe.ui.form.on('Subcontracting Receipt', {
frm.fields_dict.supplied_items.grid.update_docfield_property('consumed_qty', 'read_only', frm.doc.__onload && frm.doc.__onload.backflush_based_on === 'BOM'); frm.fields_dict.supplied_items.grid.update_docfield_property('consumed_qty', 'read_only', frm.doc.__onload && frm.doc.__onload.backflush_based_on === 'BOM');
} }
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) {
return {
'item': row.doc.item_code
}
};
}
}, },
set_warehouse: (frm) => { set_warehouse: (frm) => {