hrms
hrms copied to clipboard
Customer/Employee account details bug `psycopg2.errors.InFailedSqlTransaction`
Information about bug
After adding CRM new customer account we faced this bug error and when we need to get customer or employee account details we faced the same error empty message
Module
accounts, CRM
Version
Frappe Framework version: v14.25.1 (version-14) ERPNext version: v14.15.1 (version-14)
Installation method
docker
Relevant log output / Stack trace / Full Error Message.
### App Versions
{
"erpnext": "14.15.1",
"frappe": "14.25.1"
}
Route
Form/Customer/new-customer-1
Trackeback
Syntax error in query:
select "company", sum(grand_total) as grand_total, sum(base_grand_total) as base_grand_total, MAX(docstatus, tabSales Invoice) as "tabSales Invoice.docstatus, tabSales Invoice.modified"
from "tabSales Invoice"
where "tabSales Invoice"."docstatus" = '1' and "tabSales Invoice"."customer" = 'AHmed' and coalesce("tabSales Invoice"."posting_date", '0001-01-01 00:00:00.000000') between '2023-01-01' AND '2023-12-31'
group by company
order by "tabSales Invoice".docstatus asc, "tabSales Invoice"."modified" DESC None
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 69, 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 45, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 83, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/__init__.py", line 1607, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/desk/form/save.py", line 29, in savedocs
run_onload(doc)
File "apps/frappe/frappe/desk/form/load.py", line 370, in run_onload
doc.run_method("onload")
File "apps/frappe/frappe/model/document.py", line 909, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1259, in composer
return composed(self, method, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1241, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "apps/frappe/frappe/model/document.py", line 906, in fn
return method_object(*args, **kwargs)
File "apps/erpnext/erpnext/selling/doctype/customer/customer.py", line 36, in onload
self.load_dashboard_info()
File "apps/erpnext/erpnext/selling/doctype/customer/customer.py", line 39, in load_dashboard_info
info = get_dashboard_info(self.doctype, self.name, self.loyalty_program)
File "apps/erpnext/erpnext/accounts/party.py", line 756, in get_dashboard_info
company_wise_grand_total = frappe.get_all(
File "apps/frappe/frappe/__init__.py", line 1924, in get_all
return get_list(doctype, *args, **kwargs)
File "apps/frappe/frappe/__init__.py", line 1896, in get_list
return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
File "apps/frappe/frappe/model/db_query.py", line 172, in execute
result = self.build_and_run()
File "apps/frappe/frappe/model/db_query.py", line 212, in build_and_run
return frappe.db.sql(
File "apps/frappe/frappe/database/postgres/database.py", line 199, in sql
return super().sql(modify_query(query), modify_values(values), *args, **kwargs)
File "apps/frappe/frappe/database/database.py", line 218, in sql
self._cursor.execute(query, values)
psycopg2.errors.SyntaxError: syntax error at or near "Invoice"
LINE 1: ...tal) as base_grand_total, MAX(docstatus, tabSales Invoice) a...
^
Request Data
{
"type": "POST",
"args": {
"doc": "{\"docstatus\":0,\"doctype\":\"Customer\",\"name\":\"new-customer-1\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"naming_series\":\"CUST-.YYYY.-\",\"customer_type\":\"Individual\",\"is_internal_customer\":0,\"language\":\"en\",\"so_required\":0,\"dn_required\":0,\"is_frozen\":0,\"disabled\":0,\"represents_company\":\"\",\"customer_name\":\"AHmed\",\"territory\":\"Yemen\",\"salutation\":\"Dr\",\"gender\":\"Male\",\"customer_group\":\"Individual\",\"default_price_list\":\"Standard Selling\",\"default_currency\":\"YER\",\"default_bank_account\":\"\"}",
"action": "Save"
},
"btn": {
"jQuery360058155059502218291": {
"events": {
"click": [
{
"type": "click",
"origType": "click",
"guid": 1140,
"namespace": ""
}
]
}
}
},
"freeze": true,
"headers": {},
"error_handlers": {},
"url": "/api/method/frappe.desk.form.save.savedocs"
}
Response Data
{
"exception": ""
}
An employee has no relation with the customer. Have you written some custom queries?