Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range error while creating a Production Plan #36692

Closed
kshemankar opened this issue Aug 17, 2023 · 3 comments
Closed

Comments

@kshemankar
Copy link

Information about bug

After recent update of erpnext (14.25 to 14.35), when we create a production plan and save it, following error is shown:

App Versions

{
	"erpnext": "14.35.0",
	"frappe": "14.45.0",
	"hrms": "14.10.1",
	"india_compliance": "14.15.1",
	"payments": "0.0.1"
}

Route

Form/Production Plan/new-production-plan-1

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 94, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 47, 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 1620, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 28, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 305, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 327, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 259, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1051, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 915, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1277, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1259, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 912, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/manufacturing/doctype/production_plan/production_plan.py", line 42, in validate
    self.validate_sales_orders()
  File "apps/erpnext/erpnext/manufacturing/doctype/production_plan/production_plan.py", line 57, in validate_sales_orders
    msg = _("No items are available in the sales order {0} for production").format(sales_orders[0])
IndexError: list index out of range

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Production Plan\",\"name\":\"new-production-plan-1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"naming_series\":\"MFG-PP-.YYYY.-\",\"company\":\"Tritech Disconnectors (India) Private Limited\",\"get_items_from\":\"\",\"posting_date\":\"2023-08-16\",\"sales_order_status\":\"\",\"combine_items\":0,\"combine_sub_items\":0,\"skip_available_sub_assembly_item\":0,\"include_non_stock_items\":1,\"include_subcontracted_items\":1,\"include_safety_stock\":0,\"ignore_existing_ordered_qty\":0,\"total_planned_qty\":0,\"total_produced_qty\":0,\"status\":\"Draft\",\"po_items\":[{\"docstatus\":0,\"doctype\":\"Production Plan Item\",\"name\":\"new-production-plan-item-1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"include_exploded_items\":1,\"planned_start_date\":\"2023-08-16\",\"pending_qty\":0,\"ordered_qty\":0,\"stock_uom\":\"Nos\",\"produced_qty\":0,\"parent\":\"new-production-plan-1\",\"parentfield\":\"po_items\",\"parenttype\":\"Production Plan\",\"idx\":1,\"item_code\":\"I33FX00\",\"bom_no\":\"BOM-I33FX00-004\",\"planned_qty\":100,\"temporary_name\":\"new-production-plan-item-1\"}]}",
		"action": "Save"
	},
	"btn": {
		"jQuery360099135546616313671": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 626,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs"
}

Response Data

{
	"exception": "IndexError: list index out of range"
}

Module

manufacturing

Version

"erpnext": "14.35.0",
"frappe": "14.45.0",
"hrms": "14.10.1",
"india_compliance": "14.15.1",
"payments": "0.0.1"

Installation method

docker

Relevant log output / Stack trace / Full Error Message.

### App Versions

{
	"erpnext": "14.35.0",
	"frappe": "14.45.0",
	"hrms": "14.10.1",
	"india_compliance": "14.15.1",
	"payments": "0.0.1"
}

Route

Form/Production Plan/new-production-plan-1

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 94, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 47, 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 1620, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 28, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 305, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 327, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 259, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1051, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 915, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1277, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1259, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 912, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/manufacturing/doctype/production_plan/production_plan.py", line 42, in validate
    self.validate_sales_orders()
  File "apps/erpnext/erpnext/manufacturing/doctype/production_plan/production_plan.py", line 57, in validate_sales_orders
    msg = _("No items are available in the sales order {0} for production").format(sales_orders[0])
IndexError: list index out of range

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Production Plan\",\"name\":\"new-production-plan-1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"naming_series\":\"MFG-PP-.YYYY.-\",\"company\":\"Tritech Disconnectors (India) Private Limited\",\"get_items_from\":\"\",\"posting_date\":\"2023-08-16\",\"sales_order_status\":\"\",\"combine_items\":0,\"combine_sub_items\":0,\"skip_available_sub_assembly_item\":0,\"include_non_stock_items\":1,\"include_subcontracted_items\":1,\"include_safety_stock\":0,\"ignore_existing_ordered_qty\":0,\"total_planned_qty\":0,\"total_produced_qty\":0,\"status\":\"Draft\",\"po_items\":[{\"docstatus\":0,\"doctype\":\"Production Plan Item\",\"name\":\"new-production-plan-item-1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"include_exploded_items\":1,\"planned_start_date\":\"2023-08-16\",\"pending_qty\":0,\"ordered_qty\":0,\"stock_uom\":\"Nos\",\"produced_qty\":0,\"parent\":\"new-production-plan-1\",\"parentfield\":\"po_items\",\"parenttype\":\"Production Plan\",\"idx\":1,\"item_code\":\"I33FX00\",\"bom_no\":\"BOM-I33FX00-004\",\"planned_qty\":100,\"temporary_name\":\"new-production-plan-item-1\"}]}",
		"action": "Save"
	},
	"btn": {
		"jQuery360099135546616313671": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 626,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs"
}

Response Data

{
	"exception": "IndexError: list index out of range"
}
@frappe-pr-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 14.37.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@viralkansodiya
Copy link
Contributor

@kshemankar
#36807
check this link this issue is resolved

@s-aga-r
Copy link
Contributor

s-aga-r commented Sep 12, 2023

Fixed in: #36807

@s-aga-r s-aga-r closed this as completed Sep 12, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants