Hello,
I have a use case where we need to select items from Purchase Invoice/Material Request while creating a new stock entry.
I added the following code in stock_entry.js from the example of Purchase Order>Get Items From>Material Request: https://github.com/frappe/erpnext/blob/develop/erpnext/buying/doctype/purchase_order/purchase_order.js
frm.add_custom_button(
__("Material Request"),
function () {
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",
source_doctype: "Material Request",
target: frm,
date_field: "schedule_date",
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: {
docstatus: 1,
material_request_type: ["in", allowed_request_types],
status: ["not in", ["Transferred", "Issued", "Cancelled", "Stopped"]],
},
allow_child_item_selection: true,
child_fieldname: "items",
child_columns: ["item_code", "qty", "custom_order_no"]
});
},
__("Get Items From")
);
}
It is enabling the item selection option and items as well:
BUT, clicking on Get Items is generating error:
TypeError: make_stock_entry() takes from 1 to 2 positional arguments but 3 were given
Detail Error:
### App Versions
{
"ecommerce_integrations": "1.17.0",
"erpnext": "15.10.6",
"erpnext_telegram_integration": "1.2.0",
"frappe": "15.11.0",
"hrms": "16.0.0-dev",
"payments": "0.0.1",
}
### Route
Form/Stock Entry/new-stock-entry-ecnuwbvpdb
### Traceback
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 110, in application
response = frappe.api.handle(request)
File "apps/frappe/frappe/api/__init__.py", line 49, in handle
data = endpoint(**arguments)
File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 49, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/__init__.py", line 1682, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
return func(*args, **kwargs)
File "apps/frappe/frappe/model/mapper.py", line 53, in map_docs
target_doc = method(*_args)
File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
return func(*args, **kwargs)
TypeError: make_stock_entry() takes from 1 to 2 positional arguments but 3 were given
### Request Data
{
"type": "POST",
"args": {
"method": "erpnext.stock.doctype.material_request.material_request.make_stock_entry",
"source_names": "[\"MR-24-928\"]",
"target_doc": "{\"docstatus\":0,\"doctype\":\"Stock Entry\",\"name\":\"new-stock-entry-ecnuwbvpdb\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"naming_series\":\"\",\"purpose\":\"Material Issue\",\"add_to_transit\":0,\"company\":\"Demo Ltd.\",\"posting_date\":\"2024-04-29\",\"set_posting_time\":0,\"inspection_required\":0,\"apply_putaway_rule\":0,\"from_warehouse\":\"Stores - DEMO\",\"to_warehouse\":\"Work In Progress - DEMO\",\"items\":[],\"from_bom\":0,\"use_multi_level_bom\":1,\"additional_costs\":[],\"letter_head\":\"EC Bottom Signature\",\"is_opening\":\"No\",\"is_return\":0,\"expense_account\":\"Stock Adjustment - ECKPL\",\"total_additional_costs\":0,\"posting_time\":\"19:49:45\",\"address_display\":null,\"purchase_receipt_no\":null,\"supplier_address\":null,\"supplier_name\":null,\"supplier\":null,\"sales_invoice_no\":null,\"delivery_note_no\":null,\"customer_address\":null,\"customer_name\":null,\"customer\":null}",
"args": "{\"material_request_type\":\"Material Transfer\",\"allow_child_item_selection\":1,\"filtered_children\":[\"aba5db0600\"]}"
},
"freeze": true,
"freeze_message": "Mapping Material Request ...",
"headers": {},
"error_handlers": {},
"url": "/api/method/frappe.model.mapper.map_docs",
"request_id": null
}
### Response Data
{
"exception": "TypeError: make_stock_entry() takes from 1 to 2 positional arguments but 3 were given",
"exc_type": "TypeError"
}
Got the same result by adding code in Get Items From Purchase Invoice section.
I will appreciate guidelines to solve it.