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

Stock Ledger Variance Report Showing Error #377

Closed
rushabhmaywade opened this issue Oct 22, 2024 · 2 comments
Closed

Stock Ledger Variance Report Showing Error #377

rushabhmaywade opened this issue Oct 22, 2024 · 2 comments
Assignees
Labels
bug Something isn't working Report

Comments

@rushabhmaywade
Copy link
Collaborator

Information about bug

image

Module

stock

Version

ERPNext: v15.34.0 (pre-prod)

Frappe Framework: v15.41.0 (pre-prod)

Installation method

None

Relevant log output / Stack trace / Full Error Message.

### App Versions

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

Route

query-report/Stock Ledger Variance

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/desk/query_report.py", line 223, in run
    result = generate_report_result(report, filters, user, custom_columns, is_tree, parent_field)
  File "apps/frappe/frappe/__init__.py", line 928, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
  File "apps/frappe/frappe/desk/query_report.py", line 84, in generate_report_result
    res = get_report_result(report, filters) or []
  File "apps/frappe/frappe/desk/query_report.py", line 65, in get_report_result
    res = report.execute_script_report(filters)
  File "apps/frappe/frappe/core/doctype/report/report.py", line 163, in execute_script_report
    res = self.execute_module(filters)
  File "apps/frappe/frappe/core/doctype/report/report.py", line 180, in execute_module
    return frappe.get_attr(method_name)(frappe._dict(filters))
  File "apps/erpnext/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py", line 18, in execute
    data = get_data(filters)
  File "apps/erpnext/erpnext/stock/report/stock_ledger_variance/stock_ledger_variance.py", line 209, in get_data
    report_data = stock_ledger_invariant_check(item_warehouse)
  File "apps/erpnext/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py", line 38, in get_data
    sles = get_stock_ledger_entries(filters)
  File "apps/erpnext/erpnext/stock/report/stock_ledger_invariant_check/stock_ledger_invariant_check.py", line 43, in get_stock_ledger_entries
    return frappe.get_all(
  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 233, 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.SyntaxError: syntax error at or near "posting_date"
LINE 5:     order by timestamp(posting_date, posting_time), creation
                               ^


During handling of the above exception, another exception occurred:

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/__init__.py", line 928, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
  File "apps/frappe/frappe/desk/query_report.py", line 226, in run
    frappe.log_error("Report Error")
  File "apps/frappe/frappe/utils/error.py", line 76, in log_error
    return error_log.insert(ignore_permissions=True)
  File "apps/frappe/frappe/model/document.py", line 279, in insert
    self._set_defaults()
  File "apps/frappe/frappe/model/document.py", line 783, in _set_defaults
    new_doc = frappe.new_doc(self.doctype, as_dict=True)
  File "apps/frappe/frappe/__init__.py", line 1197, in new_doc
    new_doc = get_new_doc(doctype, parent_doc, parentfield, as_dict=as_dict)
  File "apps/frappe/frappe/model/create_new.py", line 22, in get_new_doc
    frappe.local.new_doc_templates[doctype] = make_new_doc(doctype)
  File "apps/frappe/frappe/model/create_new.py", line 44, in make_new_doc
    if not frappe.model.meta.is_single(doctype):
  File "apps/frappe/frappe/model/meta.py", line 727, in is_single
    return frappe.db.get_value("DocType", doctype, "issingle")
  File "apps/frappe/frappe/database/database.py", line 512, in get_value
    result = self.get_values(
  File "apps/frappe/frappe/database/database.py", line 616, in get_values
    out = self._get_values_from_table(
  File "apps/frappe/frappe/database/database.py", line 889, in _get_values_from_table
    return query.run(as_dict=as_dict, debug=debug, update=update, run=run, pluck=pluck)
  File "apps/frappe/frappe/query_builder/utils.py", line 87, in execute_query
    result = frappe.db.sql(query, params, *args, **kwargs)  # nosemgrep
  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.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block


Request Data

{
	"type": "GET",
	"args": {
		"report_name": "Stock Ledger Variance",
		"filters": "{\"company\":\"PP Ltd\"}",
		"ignore_prepared_report": false,
		"are_default_filters": true
	},
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.query_report.run",
	"request_id": null
}

Response Data

{
	"exception": "",
	"exc_type": "InFailedSqlTransaction",
	"_exc_source": "erpnext (app)",
	"_debug_messages": "[\"Syntax error in query:\\nselect \\\"name\\\", \\\"posting_date\\\", \\\"posting_time\\\", \\\"creation\\\", \\\"voucher_type\\\", \\\"voucher_no\\\", \\\"actual_qty\\\", \\\"qty_after_transaction\\\", \\\"incoming_rate\\\", \\\"outgoing_rate\\\", \\\"stock_queue\\\", \\\"batch_no\\\", \\\"stock_value\\\", \\\"stock_value_difference\\\", \\\"valuation_rate\\\", \\\"voucher_detail_no\\\", \\\"serial_and_batch_bundle\\\"\\n\\t\\t\\tfrom \\\"tabStock Ledger Entry\\\"\\n\\t\\t\\twhere \\\"tabStock Ledger Entry\\\".\\\"item_code\\\" = 'Carpet' and \\\"tabStock Ledger Entry\\\".\\\"warehouse\\\" = 'Stores - PP Ltd' and \\\"tabStock Ledger Entry\\\".\\\"is_cancelled\\\" = '0'\\n\\t\\t\\t\\n\\t\\t\\t order by timestamp(posting_date, posting_time), creation \", \"Error in query:\\ncurrent transaction is aborted, commands ignored until end of transaction block\\n\"]"
}
@rushabhmaywade rushabhmaywade added bug Something isn't working Report labels Oct 22, 2024
@chintanshah8848 chintanshah8848 self-assigned this Oct 22, 2024
@chintanshah8848
Copy link

Issue was Resolved in PR: #375

@tinadn
Copy link

tinadn commented Oct 22, 2024

Issue resolved. Hence closing.

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

No branches or pull requests

3 participants