Fetching items of one doctype from another doctype

I have created a new doctype “bid” in buying module and i want to fetch lits of bid doc type from the purchase order doctype using the “get items from” button same as get items from material request and supplier quotation. please can any one help me how to proceed.

Thank you for your help.

Hi @letayt! you just have to make sure that field for “bid” is present in this doctypes with exactly the same name. When you use the button “get items from”, it will automatically get all the info from the doctype you are getting and setting it to the current doctype as long as the field exists.

Thanks for your reply @creamdory. to make more clear, i have created the button bid Management as shown in the image below.

on clicking the bid management button it will not bring the list rather it gives me the option to create new bid managementand am confused what to do

Hi @letayt! Can you let us see your script for the “Get From Bid Management” dialog? Let’s see if you have set query to the dropdown field.

Hii @letayt
This is how items from Supplier Quotation is mapped into Purchase Order.

  • A custom buttons is added with a function calling map_current_doc with query filters
  • A python mapping function is given as a parameter to map_current_doc
    Its this python function in the case of Supplier Quotation

Try to identify the pattern that is used in mapping the doc.
You can refer other doctypes also, like Sales Invoice Sales Order relationship etc.

Hope it helps
Thank you

1 Like

Hi @creamdory , sorry for referencing a question of other post but could you please tell me how can you get the doctypes list in python script.
Like i want to check on a custom doctype on validate if a item of that name is present.
How could i get and compare all item names with the field? -
i did item_doctype = frappe.db.sql("select name from tabItem") but that doens’t give me the right answer on if not package_item in item_doctype: as the query returns in tuple format.
then i saw you post Fetch value of fieldname from another doctype - #7 by creamdory
and thought if i can get it in a object i can maybe do something like if not package_item in item_doctype.item_code:
but how would i write the query or achieve this?

Thanks and sorry for explicit mention.