Hello,
I have a case where Sales Partners receive their commission when payments are received from customers. Customers have the chance to pay the total of a Sales Order along a 12 months period, but the Sales Partners have to collect payments on time.
You know that ‘Payment Entry’ and ‘Payment Entry Reference’ doesn’t use same names at fields like are at ‘Sales Order’. I need to fetch ‘Sales Partner’ and ‘Commission rate’ relative to the ‘Sales Order’.
I’ve being trying doing changes with this, but no luck. It has to be with javascript, because the account is hosted at Frappe.
With this…
frappe.ui.form.on("Payment Entry",{
onload: function(frm) {
frappe.call({
method: "frappe.client.get",
args: {
doctype: "Sales Order",
name: frm.doc.reference_name,
},
callback: function(r) {
$.each(frm.doc.references || [], function(i, v) {
frappe.model.set_value(v.doctype, v.name, "sales_partner", r.sales_partner),
frappe.model.set_value(v.doctype, v.name, "commission_rate", r.commission_rate)
})
frm.refresh_field('references');
}
})
}
})
I get…
With this (Payment Entry Reference)…
frappe.ui.form.on("Payment Entry Reference",{
onload: function(frm) {
frappe.call({
method: "frappe.client.get",
args: {
doctype: "Sales Order",
name: frm.doc.reference_name,
},
I get nothing when load. But if I erase the Sales Order (‘Name’), then…
I have 3 days trying make it work…
Any help would be really appreciated!