Hello,
I have a method in the e.g. docA.py file which using frappe.db.get_list
to get data from a child table e.g. docY which parent table is docX. However, application is throwing error Please specify a valid parent DocType for docY
. This is not happening as Administrator, but any other user. I know this is a permission issue. The user has permission to the parent table i.e. docX. But, I do not know how to give permission to child table.
Please help.
PS: @nabinhait requesting someone from frappe may look into this, as this is a core development issue, I assume.
@mujeerhashmi did you face such issues? As such, kindly share your solution.
Tammam
September 4, 2022, 12:07pm
3
hi @mijan1373
you can try this example !!!
‘docX’ is Parent DocType ;
‘docY’ is Child DocType ;
frappe.call({
method: ‘frappe.client.get_list’,
args: {doctype: ‘docY’,
fields: [ ’ ’ , ’ ’ ],
filters: { // your filters},
parent: ‘docX’},
callback: function(res) {
console.log(res);
}
});
Getting following error:
jquery.js:10109 POST http://localhost:5050/api/method/frappe.client.get_list 403 (FORBIDDEN)
send @ jquery.js:10109
ajax @ jquery.js:9690
frappe.request.call @ request.js:253
frappe.call @ request.js:103
temp_id @ ministry_assessment_format__js:315
_handler @ script_manager.js:30
runner @ script_manager.js:108
(anonymous) @ script_manager.js:126
Promise.then (async)
(anonymous) @ dom.js:265
frappe.run_serially @ dom.js:263
trigger @ script_manager.js:140
(anonymous) @ form.js:264
(anonymous) @ model.js:480
Promise.then (async)
(anonymous) @ dom.js:265
frappe.run_serially @ dom.js:263
trigger @ model.js:498
(anonymous) @ model.js:441
Promise.then (async)
(anonymous) @ dom.js:265
frappe.run_serially @ dom.js:263
set_value @ model.js:450
set_model_value @ base_control.js:213
(anonymous) @ base_control.js:177
Promise.then (async)
(anonymous) @ dom.js:265
frappe.run_serially @ dom.js:263
set @ base_control.js:175
(anonymous) @ base_control.js:195
Promise.then (async)
validate_and_set_in_model @ base_control.js:195
parse_validate_and_set_in_model @ link.js:110
(anonymous) @ link.js:341
dispatch @ jquery.js:5430
elemData.handle @ jquery.js:5234
$2.fire @ awesomplete.js:504
select @ awesomplete.js:282
click @ awesomplete.js:117
request.js:438 Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 66, 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 31, in handle
data = execute_cmd(cmd)
File "apps/frappe/frappe/handler.py", line 68, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File "apps/frappe/frappe/__init__.py", line 1259, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/client.py", line 31, in get_list
check_parent_permission(parent, doctype)
File "apps/frappe/frappe/model/db_query.py", line 855, in check_parent_permission
raise frappe.PermissionError
frappe.exceptions.PermissionError
@tammam I am using “Pluck”, but field labels are still coming out, any suggestions?
{message: Array(5)}
message
:
Array(5)
0
:
{mode: 'Loan/Credit', gob_total: 18553.8, gob_fe: 0, pa_total: 127937.17, pa_rpa: 0, …}
1
:
{mode: 'Grant', gob_total: 0, gob_fe: 0, pa_total: 0, pa_rpa: 0, …}
2
:
{mode: 'Equity', gob_total: 27830.7, gob_fe: 0, pa_total: 0, pa_rpa: 0, …}
3
:
{mode: 'Others(Specify)', gob_total: 0, gob_fe: 0, pa_total: 0, pa_rpa: 0, …}
4
:
{mode: 'Total', gob_total: 46384.49, gob_fe: 0, pa_total: 127937.17, pa_rpa: 0, …}
This has been resolved by using frappe.db.get_all
instead of frappe.db.get_list
.