Issue Statement:
When I create a Quality Inspection from a Delivery Note using a custom button with frappe.new_doc({ reference_type: ‘Delivery Note’, reference_name: frm.doc.name }), I get this error when clicking the Item Code field in the new Quality Inspection:
Issue Detailed Description:
Insufficient Permission for Delivery Note Item. Note: In V15, it worked.
Current behavior:
-
If I create the Quality Inspection from the Quality Inspection list view, or manually select the Reference Type and Reference Name, the error does not occur.
-
The user has full read/write permissions on Delivery Note and Delivery Note Item.
-
I suspect the issue is that frappe.new_doc does not trigger the usual frm.trigger events for reference_type and reference_name.
Expected behavior:
I’m looking for a proper way to programmatically create a Quality Inspection from a Delivery Note without causing this permission error.
Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 121, in application
response = frappe.api.handle(request)
File "apps/frappe/frappe/api/__init__.py", line 63, in handle
data = endpoint(**arguments)
File "apps/frappe/frappe/api/v1.py", line 40, in handle_rpc_call
return frappe.handler.handle()
~~~~~~~~~~~~~~~~~~~~~^^
File "apps/frappe/frappe/handler.py", line 53, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 86, in execute_cmd
return frappe.call(method, **frappe.form_dict)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/__init__.py", line 1124, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/utils/typing_validations.py", line 36, in wrapper
return func(*args, **kwargs)
File "apps/frappe/frappe/utils/caching.py", line 248, in inner
ret = func(*args, **kwargs)
File "apps/frappe/frappe/desk/search.py", line 51, in search_link
results = search_widget(
doctype,
...<7 lines>...
link_fieldname=link_fieldname,
)
File "apps/frappe/frappe/utils/typing_validations.py", line 36, in wrapper
return func(*args, **kwargs)
File "apps/frappe/frappe/desk/search.py", line 115, in search_widget
return frappe.call(
~~~~~~~~~~~^
query,
^^^^^^
...<9 lines>...
link_fieldname=link_fieldname,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "apps/frappe/frappe/__init__.py", line 1124, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/utils/typing_validations.py", line 36, in wrapper
return func(*args, **kwargs)
File "apps/frappe/frappe/__init__.py", line 1551, in wrapper
return fn(**kwargs)
File "apps/erpnext/erpnext/stock/doctype/quality_inspection/quality_inspection.py", line 360, in item_query
mcond = get_match_cond(from_doctype)
File "apps/frappe/frappe/desk/reportview.py", line 801, in get_match_cond
cond = engine.build_match_conditions(as_condition=as_condition)
File "apps/frappe/frappe/database/query.py", line 1597, in build_match_conditions
condition = self.get_permission_conditions(self.doctype, self.table)
File "apps/frappe/frappe/database/query.py", line 1507, in get_permission_conditions
self._raise_permission_error(doctype=doctype)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "apps/frappe/frappe/database/query.py", line 1322, in raisepermission_error
frappe.throw(
~~~~~~~~~~~~^
_("Insufficient Permission for {0}").format(frappe.bold(doctype or self.doctype)),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
frappe.PermissionError,
^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "apps/frappe/frappe/utils/messages.py", line 148, in throw
msgprint(
~~~~~~~~^
msg,
^^^^
...<6 lines>...
primary_action=primary_action,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "apps/frappe/frappe/utils/messages.py", line 109, in msgprint
raiseexception()
~~~~~~~~~~~~~~~~^^
File "apps/frappe/frappe/utils/messages.py", line 58, in raiseexception
raise exc
frappe.exceptions.PermissionError: Insufficient Permission for Delivery Note Item
