Hi guys,
I have been trying to modify these links under Connections. Where can i edit these links?
https://docs.erpnext.com/docs/v13/user/manual/en/customize-erpnext/customize-form
In there you find “link documents”.
i want to remove the default ones. these are not defined there
Hi Erik,
The only way I know is modifying the related Python code.
This is the path to the file for Patient Appointments:
../apps/erpnext/erpnext/healthcare/doctype/patient_appointment/patient_appointment_dashboard.py
from __future__ import unicode_literals
from frappe import _
def get_data():
return {
'fieldname': 'appointment',
'non_standard_fieldnames': {
'Patient Medical Record': 'reference_name'
},
'transactions': [
{
'label': _('Consultations'),
'items': ['Patient Encounter', 'Vital Signs', 'Patient Medical Record']
}
]
}
i found this also. so i removed the links but they aren’t going away i’m doing something wrong.
in a custom script
frappe.ui.form.on('Sales Order', {
refresh(frm) {
setTimeout(() => {
$("[data-doctype='Auto Repeat']").hide();
$("[data-doctype='Work Order']").hide();
$("[data-doctype='Pick List']").hide();
$("[data-doctype='Material Request']").hide();
$("[data-doctype='Payment Entry']").hide();
$("[data-doctype='Payment Request']").hide();
$("[data-doctype='Journal Entry']").hide();
}, 10);
}
})
if you do changes directly in the python code, dont forget to:
bench build
bench clear-cache
bench restart
@Erik_Jeurissen, there’s also a “Linked Documents” section on the DocType itself. This may do teh trick for you.
A generic function to add links in the Connections area (Transactions section). Use like below.
e.g. to add a link to Wallpaper doctype with some counts and add new button hidden.
frappe.add_dashboard_connection(cur_frm, "Wallpaper", "Related", 10, 5, [ 'WAL-1','WAL-2' ],null,1);
Can be used when add_transactions of frappe dashboard.js cannot be used, for instance when the logic for open count, count or filter for list view is not obvious.
frappe.add_dashboard_connection = function (
frm,
doctype,
group,
open_count,
count,
names,
onclick,
hidden
) {
if (
frm.dashboard.transactions_area.find(
`.document-link[data-doctype="${doctype}"]`
).length > 0
) {
frm.dashboard.set_badge_count(doctype, open_count, count, names);
return;
}
let $group = frm.dashboard.transactions_area
.find(`.form-link-title:contains('${group}')`)
.get(0);
let $link_template = $(`
<div class="document-link" data-doctype="${doctype}">
<div class="document-link-badge" data-doctype="${doctype}">
<span class="count hidden"></span> <a class="badge-link">${doctype}</a>
</div>
<span class="open-notification" title="Open ${doctype}">0</span>
<button ${
hidden ? "hidden" : ""
} class="btn btn-new btn-secondary btn-xs icon-btn" data-doctype="${doctype}">
<svg class="icon icon-sm"><use href="#icon-add"></use></svg>
</button>
</div>
`);
let _to_list_view = function () {
frappe.route_options = {
name: ["in", names],
};
frappe.set_route("List", doctype, "List");
};
$link_template.on("click", onclick || _to_list_view);
frm.dashboard.transactions_area
.find(`.form-link-title:contains('${group}')`)
.after($link_template);
frm.dashboard.set_badge_count(doctype, open_count, count, names);
};