Updating field value based on another doctype field value,

Hi @ibalajib,

If not work then try this, please.
It’s working on my side.
So apply and check it.


Document Type: Holiday List
DocType Event: After Save


test_name = frappe.db.get_value("Custom DocType",{'working_id':doc.name}, 'name');
if test_name:
    test_doc = frappe.get_doc("Custom DocType",test_name)
    holidays = frappe.utils.date_diff(doc.to_date, doc.from_date)
    final_holidays = holidays - doc.total_holidays + 1;
    test_doc.duration = final_holidays;
    test_doc.number_of_leaves = doc.total_holidays;
    test_doc.save()

Custom DocType = You can also use core doctype or set doctype which you can update a value in DocType.

Thank You!