ERP Helpdesk module bug detected

Dear Frappe/ERPNext Team,

Action Required:
Apply the below-attached code change in permissions.py at the apps/frappe/frappe/permissions/has_permission.

Issue
We get an error (AttributeError: ‘int’ object has no attribute ‘doctype’) when creating and assigning HD Tickets.

Cause
This issue is due to the permissions.py file in the frappe app not validating the doc type when it is an integer.

Resolution
The code was updated in the permissions.py file to handle cases where the doc is an integer.

Updated Code
Path - apps/frappe/frappe/permissions.py
if isinstance(doc, str):
doc = frappe.get_doc(meta.name, doc)
# ---------------------------------------------------------------------
if isinstance(doc, int):
doc = frappe.get_doc(meta.name, doc)
# These two lines were added by MP Arunkumar to fix the AttributeError:
‘int’ object has no attribute ‘doctype’ issue.
# ---------------------------------------------------------------------

Issue Details

App Versions

{
	"cmr": "0.0.1",
	"cs_bo": "0.0.1",
	"erpnext": "14.61.3",
	"frappe": "14.64.0",
	"helpdesk": "0.10.0",
	"hrms": "14.21.4"
}

Route

Form/HD Ticket/26583

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 95, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, 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 31, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 309, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 361, in _save
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1088, in run_post_save_methods
    self.run_method("on_update")
  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 1261, in runner
    add_to_return_value(self, f(self, method, *args, **kwargs))
  File "apps/frappe/frappe/automation/doctype/assignment_rule/assignment_rule.py", line 263, in apply
    new_apply = assignment_rule.apply_assign(doc)
  File "apps/frappe/frappe/automation/doctype/assignment_rule/assignment_rule.py", line 48, in apply_assign
    return self.do_assignment(doc)
  File "apps/frappe/frappe/automation/doctype/assignment_rule/assignment_rule.py", line 57, in do_assignment
    assign_to.add(
  File "apps/frappe/frappe/desk/form/assign_to.py", line 107, in add
    frappe.share.add(doc.doctype, doc.name, assign_to)
  File "apps/frappe/frappe/share.py", line 23, in add
    return add_docshare(
  File "apps/frappe/frappe/share.py", line 44, in add_docshare
    check_share_permission(doctype, name)
  File "apps/frappe/frappe/share.py", line 228, in check_share_permission
    if not frappe.has_permission(doctype, ptype="share", doc=name):
  File "apps/frappe/frappe/__init__.py", line 966, in has_permission
    out = frappe.permissions.has_permission(
  File "apps/frappe/frappe/permissions.py", line 56, in inner
    result = func(*args, **kwargs)
  File "apps/frappe/frappe/permissions.py", line 120, in has_permission
    perm = get_doc_permissions(doc, user=user, ptype=ptype).get(ptype)
  File "apps/frappe/frappe/permissions.py", line 181, in get_doc_permissions
    if frappe.is_table(doc.doctype):
AttributeError: 'int' object has no attribute 'doctype'

### Response Data

{
“exception”: “AttributeError: ‘int’ object has no attribute ‘doctype’”
}



kindly check and fix this bug.

Thank you

You should create an issue on the GitHub repo.