You do not have enough permissions to access this resource

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.

That commit has been overwritten by the one I linked. The problem is in the check_parent_permission function:

def check_parent_permission(parent):
	if parent:
		if frappe.permissions.has_permission(parent):
			return
	# Either parent not passed or the user doesn't have permission on parent doctype of child table!
	raise frappe.PermissionError

As you can see, the error is raised if you either do not have permission on the parent or there is no parent passed.

See… so this can be done just after_save trigger, that’s not good for my use case…
@rmehta can you help me with that please?

Or you can make a white listed API in the server side in your custom app that accept your filters as parameters and then let it returns your result based on your frappe.get_value(“Child Table”, filters={“fieldname”: para1, “another_fieldname”: para20}, fieldname = [“f1”,“f2”,“f3”]) function and then call it from the client side by the frappe call something like:

frappe.call({
      	method: "yourApp.path.to.your.api",
	args: {
					
		paras:["para1", "para2"],
	},
	callback: function (r) {
		data = r.message;
	}
});

Yeah I did that in the first time, but after I choose change to frappe API…