Okay I have made it work by copying the parameters called from front end.
So I’ve got to specify metadata_loaded param as: [“Purchase Receipt”,“Purchase Receipt Item”,“Purchase Taxes and Charges”,“Purchase Receipt Item Supplied”,“Page”,“Page Role”,“Purchase Order”,“Purchase Order Item”,“Purchase Order Item Supplied”,“Purchase Invoice”,“Purchase Invoice Item”,“Purchase Invoice Advance”]
Initially i thought just “Purchase Receipt” and related doctype are enough but turned out, it requires the whole array. Can someone explain a bit what is this metadata_loaded for ?
This applies also to the normal api call: /api/method/frappe.widgets.form.utils.get_linked_docs?doctype=Purchase Order&name=PO9999
Meaning if you don’t specify same parameter for this api call, it will not return correct information.
Instead it dumps all the fields available in Purchase Receipt, something like:
{
“docs”: [
{
“fields”: [
{
“creation”: “2013-05-21 16:16:39”,
“search_fields”: null,
“doctype”: “DocField”,
“owner”: “Administrator”,
“modified_by”: “Administrator”,
“label”: “Supplier”,
“docstatus”: 0,
“permlevel”: 0,
“link_doctype”: null,
“parent”: “Purchase Invoice”,
“name”: “FL07961”,
“idx”: 1,
“modified”: “2014-07-04 11:25:34.977669”,
“parenttype”: “DocType”,
“fieldname”: “supplier_section”,
“fieldtype”: “Section Break”,
“options”: “icon-user”,
“parentfield”: “fields”
},
{
“oldfieldtype”: “Column Break”,
“creation”: “2013-05-21 16:16:39”,
“search_fields”: null,
“doctype”: “DocField”,
“owner”: “Administrator”,
“read_only”: 0,
“modified_by”: “Administrator”,
“width”: “50%”,
“docstatus”: 0,
“permlevel”: 0,
“link_doctype”: null,
“parent”: “Purchase Invoice”,
“name”: “FL07962”,
“idx”: 2,
“modified”: “2014-07-04 11:25:34.977669”,
“parenttype”: “DocType”,
“fieldname”: “column_break0”,
“fieldtype”: “Column Break”,
“parentfield”: “fields”
}
…
Should I report this as a bug ? Seem to be these 2 lines in get_linked_docs:
if not dt in metadata_loaded:
frappe.local.response.docs.extend(link_meta_bundle)
Thank you!
On Wednesday, July 30, 2014 10:00:08 AM UTC+8, Nguyen Do Le Bao wrote:
Sorry, I made you confused about the question. Here’s what I was trying to do:
Question should just be ‘How to get linked doc using Server code’ … Sorry about that!
On Tuesday, July 29, 2014 6:28:40 PM UTC+8, rushabh wrote:
On 29-Jul-2014, at 3:49 pm, Nguyen Do Le Bao <
na…@gmail.com> wrote:
Is there a way just to use
frappe.model.db_query to retrieve linked doc ???
On Tuesday, July 29, 2014 4:04:38 PM UTC+8, Nguyen Do Le Bao wrote:
Oh, the linked docs are not the final result. That’s why i can’t just call directly from client.
In the customized API, I need to query the linked docs of a PO.
Calling frappe.widgets.form.utils.get_linked_docs directly on server didn’t actually work. So still wonder how to retrieve it.
Why? this should work:
/api/method/frappe.widgets.form.utils.get_linked_docs?doctype=Purchase Order&name=PO9999
Do you get an error?
Thanks!!!
On Tuesday, July 29, 2014 3:42:52 PM UTC+8, Pratik Vyas wrote:
On Tue, Jul 29, 2014 at 12:59 PM, Nguyen Do Le Bao
<na…@gmail.com> wrote:
> Okay I was writing an API and really need to find out what PR associated
> with a PO by po_name.
>
> Although figured out the function that is supposed to return it is
> frappe.widgets.form.utils.get_linked_docs.
> Anyone has experience of doing this ? Can I retrieve this directly from a
> arbitrary model ?
frappe.widgets.form.utils.get_linked_docs is whitelisted.
You can call a whitelisted function with path,
/api/method/dotted.path.to.func
Thanks,
–
Pratik
erpnext
–
Note:
If you are posting an issue,
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
End of Note
—
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
To unsubscribe from this group and stop receiving emails from it, send an email toerpnext-developer-forum+un…@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/bd438574-343e-4c35-8dd0-26d447042874%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
1. ERPNext is a free and open source software and support is given on this forum by a team (
). So please consider donating if you find this forum useful (
). Even a small amount would be helpful.
2. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
3. Paste your code at
4. For sending images, use
or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
You received this message because you are subscribed to the Google Groups “ERPNext Developer Forum” group.
To unsubscribe from this group and stop receiving emails from it, send an email to
.
.
.