mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
fix: fetch Material Requests of type Customer Provided in Stock Entry using Get Items From (#24756)
Co-authored-by: walstanb <walstanb@gmail.com>
This commit is contained in:
@@ -595,21 +595,7 @@ erpnext.utils.update_child_items = function(opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
erpnext.utils.map_current_doc = function(opts) {
|
erpnext.utils.map_current_doc = function(opts) {
|
||||||
let query_args = {};
|
function _map() {
|
||||||
if (opts.get_query_filters) {
|
|
||||||
query_args.filters = opts.get_query_filters;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.get_query_method) {
|
|
||||||
query_args.query = opts.get_query_method;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query_args.filters || query_args.query) {
|
|
||||||
opts.get_query = () => {
|
|
||||||
return query_args;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var _map = function() {
|
|
||||||
if($.isArray(cur_frm.doc.items) && cur_frm.doc.items.length > 0) {
|
if($.isArray(cur_frm.doc.items) && cur_frm.doc.items.length > 0) {
|
||||||
// remove first item row if empty
|
// remove first item row if empty
|
||||||
if(!cur_frm.doc.items[0].item_code) {
|
if(!cur_frm.doc.items[0].item_code) {
|
||||||
@@ -683,8 +669,22 @@ erpnext.utils.map_current_doc = function(opts) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let query_args = {};
|
||||||
|
if (opts.get_query_filters) {
|
||||||
|
query_args.filters = opts.get_query_filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.get_query_method) {
|
||||||
|
query_args.query = opts.get_query_method;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query_args.filters || query_args.query) {
|
||||||
|
opts.get_query = () => query_args;
|
||||||
|
}
|
||||||
|
|
||||||
if (opts.source_doctype) {
|
if (opts.source_doctype) {
|
||||||
var d = new frappe.ui.form.MultiSelectDialog({
|
const d = new frappe.ui.form.MultiSelectDialog({
|
||||||
doctype: opts.source_doctype,
|
doctype: opts.source_doctype,
|
||||||
target: opts.target,
|
target: opts.target,
|
||||||
date_field: opts.date_field || undefined,
|
date_field: opts.date_field || undefined,
|
||||||
@@ -703,7 +703,11 @@ erpnext.utils.map_current_doc = function(opts) {
|
|||||||
_map();
|
_map();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else if(opts.source_name) {
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts.source_name) {
|
||||||
opts.source_name = [opts.source_name];
|
opts.source_name = [opts.source_name];
|
||||||
_map();
|
_map();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,15 +231,37 @@ frappe.ui.form.on('Stock Entry', {
|
|||||||
}, __("Get Items From"));
|
}, __("Get Items From"));
|
||||||
|
|
||||||
frm.add_custom_button(__('Material Request'), function() {
|
frm.add_custom_button(__('Material Request'), function() {
|
||||||
erpnext.utils.map_current_doc({
|
const allowed_request_types = ["Material Transfer", "Material Issue", "Customer Provided"];
|
||||||
|
const depends_on_condition = "eval:doc.material_request_type==='Customer Provided'";
|
||||||
|
const d = erpnext.utils.map_current_doc({
|
||||||
method: "erpnext.stock.doctype.material_request.material_request.make_stock_entry",
|
method: "erpnext.stock.doctype.material_request.material_request.make_stock_entry",
|
||||||
source_doctype: "Material Request",
|
source_doctype: "Material Request",
|
||||||
target: frm,
|
target: frm,
|
||||||
date_field: "schedule_date",
|
date_field: "schedule_date",
|
||||||
setters: {},
|
setters: [{
|
||||||
|
fieldtype: 'Select',
|
||||||
|
label: __('Purpose'),
|
||||||
|
options: allowed_request_types.join("\n"),
|
||||||
|
fieldname: 'material_request_type',
|
||||||
|
default: "Material Transfer",
|
||||||
|
mandatory: 1,
|
||||||
|
change() {
|
||||||
|
if (this.value === 'Customer Provided') {
|
||||||
|
d.dialog.get_field("customer").set_focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldtype: 'Link',
|
||||||
|
label: __('Customer'),
|
||||||
|
options: 'Customer',
|
||||||
|
fieldname: 'customer',
|
||||||
|
depends_on: depends_on_condition,
|
||||||
|
mandatory_depends_on: depends_on_condition,
|
||||||
|
}],
|
||||||
get_query_filters: {
|
get_query_filters: {
|
||||||
docstatus: 1,
|
docstatus: 1,
|
||||||
material_request_type: ["in", ["Material Transfer", "Material Issue"]],
|
material_request_type: ["in", allowed_request_types],
|
||||||
status: ["not in", ["Transferred", "Issued"]]
|
status: ["not in", ["Transferred", "Issued"]]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user