Get linked doc on API

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 ?

Thank you!!!



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 to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/f5a8ed58-0c1b-4dba-aa62-fbe1314c21a5%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.

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

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.

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 to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/8ef810bd-22bc-453a-967e-c0dae19575a8%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
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.

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 to erpnext-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.

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 to erpnext-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.



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 to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/A42A000D-469B-49FD-AD6C-2B2D8D62E6E4%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.

Sorry, I made you confused about the question. Here’s what I was trying to do: 

https://gist.github.com/nathando/a37ba1d64945e1b07c99

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 to erpnext-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.



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 to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/906628bf-1584-44f2-b628-e490305a97d0%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
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 to erpnext-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.



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 to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/fdcd0960-b3c8-470b-a133-b48e16bfb9a3%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
To render the list correctly the client needs the metadata (doctype info) from the server along with the list. If there is already metadata loaded, it will not reload it, hence it sends a list of metadata already loaded.

For your case, You can add a new parameter no_metadata and skip the metadata part if you want only the linked data.

If you want, send a PR too.


On 30-Jul-2014, at 9:19 am, Nguyen Do Le Bao <na...@gmail.com> wrote:

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.


-- 
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 to erpnext-developer-forum+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/fdcd0960-b3c8-470b-a133-b48e16bfb9a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



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 to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/0B73E538-2092-41AF-B7F1-E931C31840D0%40gmail.com.

    For more options, visit https://groups.google.com/d/optout.

Thanks, got it!!!

And created a PR as well 

On Wednesday, July 30, 2014 12:47:51 PM UTC+8, rushabh wrote:
To render the list correctly the client needs the metadata (doctype info) from the server along with the list. If there is already metadata loaded, it will not reload it, hence it sends a list of metadata already loaded.

For your case, You can add a new parameter no_metadata and skip the metadata part if you want only the linked data.

If you want, send a PR too.


On 30-Jul-2014, at 9:19 am, Nguyen Do Le Bao <na…@gmail.com> wrote:

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.


 
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 to erpnext-developer-forum+un…@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/fdcd0960-b3c8-470b-a133-b48e16bfb9a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



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 to erpnext-developer-forum+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/aef73345-bd1b-4fd2-963a-02d0a99a5589%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.