You do not have enough permissions to access this resource

When I run on my app.js or console browser this script:

frappe.call({
				method: "frappe.client.get_value",
				args: {
					doctype: "Materiais",
					filters: {
						numero_serie: d.numero_serie,
					},
					fieldname: ["modelo", "descricao", "tag"]
				},
				callback: function (r) {
					console.log(r);
				}
})

Gives me that error:

Traceback (most recent call last):
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/client.py", line 65, in get_value
    check_parent_permission(parent)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/client.py", line 322, in check_parent_permission
    raise frappe.PermissionError
PermissionError
2 Likes

go in role permission manager then give permission of “Materiais” doctype. if is it your solution then mark as solutions.

1 Like

I also have the same permission issue. I am working on my localhost as administrator with all available permissions granted. I am trying to fetch data from a child table, I did many tries in various tables but I am ending with that error. Seems like a bug because some debuging I made in client.py seems the parent parameter is empty

There was a change made to frappe.client recently, you have to pass parent as an argument when you call get_value now as it is set to default to none.

Thank you @DBoobis. Where is this change described?
Can you please provide an example or link of how is the correct call?

@DBoobis here is my unsuccesful call

The commit is here

https://github.com/frappe/frappe/pull/5311

In your call you need to add

args: { 'parent': doc.name
      }

That should allow you to access the child table.

2 Likes

worked, ty!

Materiais is a custom childtable, does not appear in role permission manager.

My doctype is not saved yet, so:

DocType New Maintenance Visit 1 not found

Maybe the problem is a chmod permission, on my dev machine the same app is working fine…

Seems like that’s not a chmod permission, I tried reconfigure that and still with same problem…

I run bench update on my dev machine and got the same error there too :confused:

What is the script you are running now?

Same script:

frappe.ui.form.on("Maintenance Visit Purpose", {
  numero_serie: function (frm, cdt, cdn) {
		  d = locals[cdt][cdn];
		  if (d.numero_serie) {
	  		frappe.call({
      				method: "frappe.client.get_value",
				args: {
					doctype: "Materiais",
					filters: {
						numero_serie: d.numero_serie,
					},
					fieldname: ["modelo", "descricao", "tag"]
				},
				callback: function (r) {
					data = r.message;
					idx = (d.idx - 1);
					cur_frm.doc.purposes[idx].item_name = data['descricao'];
					cur_frm.doc.purposes[idx].modelo_equipamento = data['modelo'];
					cur_frm.doc.purposes[idx].tag = data['tag'];
					cur_frm.refresh_field("purposes");
				}
			});
		}
	}
});

Before I solved problem deleting the machine and launch another based on my production machine, but without bench update.

Are you trying to retrieve a child table value from an unsaved doc? I don’t think this can be done as the child table call has to reference it’s parent, and if the document isn’t saved then it doesn’t exist.

Yes can be done, but after run bench update that’s not possible anymore

Yes this is because of the changes to frappe.client as linked above. get_value requires you to specify what the parent is now, and without saving the document there is no parent.

I don’t think so, parent can be a none arg:

Maybe that commit is the problem?

https://github.com/frappe/frappe/commit/807a300fd8ccf3a2aa29d2a6757bfb11e2087a96#diff-79bda205495231a9eff92b3a33cc319d

My use case is, when I select the equipment serie number, that fetch description, model and tag.