fix(setup): fetch driver address by supplier link

(cherry picked from commit 3ffb888d26)
This commit is contained in:
Mihir Kandoi
2026-08-11 15:09:48 +05:30
committed by Mergify
parent 5c3063fa43
commit 2a4a9fff3d

View File

@@ -23,15 +23,20 @@ frappe.ui.form.on("Driver", {
}, },
transporter: function (frm, cdt, cdn) { transporter: function (frm, cdt, cdn) {
// this assumes that supplier's address has same title as supplier's name
if (!frm.doc.transporter) return; if (!frm.doc.transporter) return;
frappe.db
.get_doc("Address", null, { address_title: frm.doc.transporter }) const transporter = frm.doc.transporter;
.then((r) => { frappe.call({
frappe.model.set_value(cdt, cdn, "address", r.name); method: "frappe.contacts.doctype.address.address.get_default_address",
}) args: {
.catch((err) => { doctype: "Supplier",
console.log(err); name: transporter,
}); },
callback: function (r) {
if (frm.doc.transporter === transporter) {
frappe.model.set_value(cdt, cdn, "address", r.message);
}
},
});
}, },
}); });