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

Unable to submit Subcontracting Receipt entry #153

Closed
8848swa opened this issue Oct 1, 2024 · 1 comment · Fixed by #180
Closed

Unable to submit Subcontracting Receipt entry #153

8848swa opened this issue Oct 1, 2024 · 1 comment · Fixed by #180
Assignees
Labels
bug Something isn't working Subcontracting Receipt

Comments

@8848swa
Copy link
Collaborator

8848swa commented Oct 1, 2024

Information about bug

image

Module

buying

Version

"erpnext": "15.34.0",
"frappe": "15.41.0",

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

### App Versions

{
	"erpnext": "15.34.0",
	"frappe": "15.41.0",
	"payments": "0.0.1"
}

Route

Form/Subcontracting Receipt/MAT-SCR-2024-00002

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 114, 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 1775, 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/desk/form/save.py", line 37, in savedocs
    doc.submit()
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1048, in submit
    return self._submit()
  File "apps/frappe/frappe/model/document.py", line 1031, in _submit
    return self.save()
  File "apps/frappe/frappe/model/document.py", line 337, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 373, in _save
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1094, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py", line 127, in validate
    super().validate()
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 54, in validate
    self.create_raw_materials_supplied()
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 835, in create_raw_materials_supplied
    self.set_materials_for_subcontracted_items(raw_material_table)
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 831, in set_materials_for_subcontracted_items
    self.__prepare_supplied_items()
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 786, in __prepare_supplied_items
    self.__set_supplied_items()
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 695, in __set_supplied_items
    for bom_item in self.__get_materials_from_bom(
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 476, in __get_materials_from_bom
    return frappe.get_all("BOM", fields=fields, filters=filters, order_by=f"`tab{doctype}`.`idx`") or []
  File "apps/frappe/frappe/__init__.py", line 2064, in get_all
    return get_list(doctype, *args, **kwargs)
  File "apps/frappe/frappe/__init__.py", line 2039, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
  File "apps/frappe/frappe/model/db_query.py", line 191, in execute
    result = self.build_and_run()
  File "apps/frappe/frappe/model/db_query.py", line 232, in build_and_run
    return frappe.db.sql(
  File "apps/frappe/frappe/database/postgres/database.py", line 218, in sql
    return super().sql(modify_query(query), modify_values(values), *args, **kwargs)
  File "apps/frappe/frappe/database/database.py", line 227, in sql
    self._cursor.execute(query, values)
psycopg2.errors.DatatypeMismatch: COALESCE types character varying and integer cannot be matched
LINE 3:    where coalesce("tabBOM Item"."parent", 0) = '0' and "tabB...
                                                  ^


Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"name\":\"MAT-SCR-2024-00002\",\"owner\":\"Administrator\",\"creation\":\"2024-10-01 17:48:19.900999\",\"modified\":\"2024-10-01 17:48:19.900999\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":0,\"title\":\"_Test Supplier\",\"naming_series\":\"MAT-SCR-.YYYY.-\",\"supplier\":\"_Test Supplier\",\"supplier_name\":\"_Test Supplier\",\"company\":\"8848 Digital\",\"posting_date\":\"2024-10-01\",\"posting_time\":\"17:48:19.934562\",\"set_posting_time\":0,\"is_return\":0,\"supplier_warehouse\":\"Test Subcontracted warehouse - 8D\",\"total_qty\":20,\"total\":71000,\"supplier_address\":\"Test Supplier-Billing\",\"address_display\":\"address line 1<br>\\naddress line 2<br>mumbai<br>\\nMaharashtra <br>400006<br>India<br>\\n<br>\\nPhone: 022-5896555<br>Email: [email protected]<br>\",\"shipping_address\":\"8848 Digital-Billing\",\"shipping_address_display\":\"address line1<br>\\naddress line1<br>mumbai<br>\\nMaharashtra<br>400078<br>India<br>\\n<br>\\n\",\"billing_address\":\"8848 Digital-Billing\",\"billing_address_display\":\"address line1<br>\\naddress line1<br>mumbai<br>\\nMaharashtra<br>400078<br>India<br>\\n<br>\\n\",\"distribute_additional_costs_based_on\":\"Qty\",\"total_additional_costs\":0,\"represents_company\":\"\",\"status\":\"Draft\",\"per_returned\":0,\"letter_head\":\"8848 Digital\",\"doctype\":\"Subcontracting Receipt\",\"supplied_items\":[{\"name\":\"e5bnd14ftm\",\"owner\":\"Administrator\",\"creation\":\"2024-10-01 17:48:19.973767\",\"modified\":\"2024-10-01 17:48:19.973767\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":1,\"main_item_code\":\"_Test FG Item\",\"rm_item_code\":\"_Test Item\",\"item_name\":\"_Test Item\",\"bom_detail_no\":\"kl0iv3slg3\",\"description\":\"_Test Item 1\",\"stock_uom\":\"_Test UOM\",\"conversion_factor\":1,\"reference_name\":\"e5bnn60jb5\",\"rate\":5000,\"amount\":50000,\"available_qty_for_consumption\":10,\"required_qty\":10,\"consumed_qty\":10,\"current_stock\":10,\"use_serial_batch_fields\":1,\"subcontracting_order\":\"SC-ORD-2024-00001\",\"parent\":\"MAT-SCR-2024-00002\",\"parentfield\":\"supplied_items\",\"parenttype\":\"Subcontracting Receipt\",\"doctype\":\"Subcontracting Receipt Supplied Item\"},{\"name\":\"e5bnmh71kc\",\"owner\":\"Administrator\",\"creation\":\"2024-10-01 17:48:19.974440\",\"modified\":\"2024-10-01 17:48:19.974440\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":2,\"main_item_code\":\"_Test FG Item\",\"rm_item_code\":\"_Test Item Home Desktop 100\",\"item_name\":\"_Test Item Home Desktop 100\",\"bom_detail_no\":\"kl0i2nh151\",\"description\":\"_Test Item Home Desktop 100 3\",\"stock_uom\":\"_Test UOM\",\"conversion_factor\":1,\"reference_name\":\"e5bnn60jb5\",\"rate\":1000,\"amount\":20000,\"available_qty_for_consumption\":20,\"required_qty\":20,\"consumed_qty\":20,\"current_stock\":20,\"use_serial_batch_fields\":1,\"subcontracting_order\":\"SC-ORD-2024-00001\",\"parent\":\"MAT-SCR-2024-00002\",\"parentfield\":\"supplied_items\",\"parenttype\":\"Subcontracting Receipt\",\"doctype\":\"Subcontracting Receipt Supplied Item\"}],\"items\":[{\"name\":\"e5bnn60jb5\",\"owner\":\"Administrator\",\"creation\":\"2024-10-01 17:48:19.900999\",\"modified\":\"2024-10-01 17:48:19.900999\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":1,\"item_code\":\"_Test FG Item\",\"item_name\":\"_Test FG Item\",\"is_scrap_item\":0,\"description\":\"_Test FG Item 6\",\"received_qty\":10,\"qty\":10,\"rejected_qty\":0,\"returned_qty\":0,\"stock_uom\":\"_Test UOM\",\"conversion_factor\":1,\"rate\":7000,\"amount\":70000,\"rm_cost_per_qty\":7000,\"service_cost_per_qty\":100,\"additional_cost_per_qty\":0,\"scrap_cost_per_qty\":100,\"rm_supp_cost\":70000,\"warehouse\":\"Stores - 8D\",\"subcontracting_order\":\"SC-ORD-2024-00001\",\"subcontracting_order_item\":\"e3b8ii5skm\",\"bom\":\"BOM-_Test FG Item-001\",\"include_exploded_items\":0,\"schedule_date\":\"2024-10-31\",\"use_serial_batch_fields\":0,\"expense_account\":\"Cost of Goods Sold - 8D\",\"cost_center\":\"Main - 8D\",\"page_break\":0,\"purchase_order\":\"PUR-ORD-2024-00008\",\"purchase_order_item\":\"e1j3me9e0r\",\"parent\":\"MAT-SCR-2024-00002\",\"parentfield\":\"items\",\"parenttype\":\"Subcontracting Receipt\",\"doctype\":\"Subcontracting Receipt Item\"},{\"name\":\"e5bnju06f8\",\"owner\":\"Administrator\",\"creation\":\"2024-10-01 17:48:19.971755\",\"modified\":\"2024-10-01 17:48:19.971755\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":2,\"item_code\":\"_Test Item Home Desktop 100\",\"item_name\":\"_Test Item Home Desktop 100\",\"is_scrap_item\":1,\"received_qty\":10,\"qty\":10,\"rejected_qty\":0,\"returned_qty\":0,\"stock_uom\":\"_Test UOM\",\"conversion_factor\":0,\"rate\":100,\"amount\":1000,\"rm_cost_per_qty\":0,\"service_cost_per_qty\":0,\"additional_cost_per_qty\":0,\"scrap_cost_per_qty\":0,\"rm_supp_cost\":0,\"include_exploded_items\":0,\"reference_name\":\"e5bnn60jb5\",\"use_serial_batch_fields\":0,\"page_break\":0,\"parent\":\"MAT-SCR-2024-00002\",\"parentfield\":\"items\",\"parenttype\":\"Subcontracting Receipt\",\"doctype\":\"Subcontracting Receipt Item\"}],\"additional_costs\":[],\"__onload\":{\"backflush_based_on\":\"BOM\"},\"__last_sync_on\":\"2024-10-01T12:19:13.203Z\"}",
		"action": "Submit"
	},
	"btn": {
		"jQuery370036855260540715821": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 307,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs",
	"request_id": null
}

Response Data

{
	"exception": "",
	"exc_type": "DatatypeMismatch",
	"_exc_source": "erpnext (app)",
	"_debug_messages": "[\"Error in query:\\nCOALESCE types character varying and integer cannot be matched\\nLINE 3:    where coalesce(\\\"tabBOM Item\\\".\\\"parent\\\", 0) = '0' and \\\"tabB...\\n                                                  ^\\n\"]"
}
@8848swa 8848swa added bug Something isn't working Subcontracting Receipt labels Oct 1, 2024
@Gopal8848 Gopal8848 self-assigned this Oct 4, 2024
@Gopal8848 Gopal8848 linked a pull request Oct 4, 2024 that will close this issue
@aasif-patel
Copy link
Collaborator

Resolved hence closing...

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working Subcontracting Receipt
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants