fix: Headline rendered twice on first save

- `refresh` gets triggered twice and that renders the note twice
- Remove any existing note before rendering

(cherry picked from commit bf62f9ad57)
This commit is contained in:
marination
2025-03-17 19:26:45 +01:00
committed by Mergify
parent d9636018f5
commit f94a14c06a

View File

@@ -2776,8 +2776,14 @@ erpnext.apply_putaway_rule = (frm, purpose=null) => {
erpnext.set_unit_price_items_note = (frm) => {
if (frm.doc.has_unit_price_items && !frm.is_new()) {
frm.dashboard.set_headline_alert(
__("The {0} contains Unit Price Items with 0 Qty.", [__(frm.doc.doctype)]),
// Remove existing note
const $note = $(frm.layout.wrapper.find(".unit-price-items-note"));
if ($note.length) { $note.parent().remove(); }
frm.layout.show_message(
`<div class="unit-price-items-note">
${__("The {0} contains Unit Price Items.", [__(frm.doc.doctype)])}
</div>`,
"yellow",
true
);