i want to fetch values from one doctype for filling another doctype fields…the two doctypes are not linked to each other… but have one common column named prospect_id in it… can someone know how to get that done…the code below show error like " pymysql.err.ProgrammingError: (‘DocType’, ‘Doctype’) ".
import frappe
from frappe.model.document import Document
class Policy(Document):
def copy(motor,sub_model,make,model,reg_number,policy,target_fields,prospect_id):
motors = frappe.get_all(motor)
for moto in motors:
source_doc = frappe.get_doc(motor,moto.name)
source_value = source_doc.get(sub_model,make,model,reg_number)
target_doc = frappe.get_doc(policy,{prospect_id:source_value})
if target_doc:
for target_field in target_fields:
target_doc.set(target_field,sub_model,make,model,reg_number)
target_doc.save()
copy("motor","sub_model","make","model","reg_number","policy",["sub_model","make","model","reg_number"],"prospect_id")