mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-17 10:36:31 +00:00
fix: warning message for new item standard cost (#56885)
This commit is contained in:
@@ -13,4 +13,33 @@ frappe.ui.form.on("Item Standard Cost", {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
refresh(frm) {
|
||||||
|
frm.trigger("show_backdated_block_warning");
|
||||||
|
},
|
||||||
|
|
||||||
|
item_code(frm) {
|
||||||
|
frm.trigger("show_backdated_block_warning");
|
||||||
|
},
|
||||||
|
|
||||||
|
effective_date(frm) {
|
||||||
|
frm.trigger("show_backdated_block_warning");
|
||||||
|
},
|
||||||
|
|
||||||
|
show_backdated_block_warning(frm) {
|
||||||
|
if (frm.doc.docstatus !== 0 || !frm.doc.item_code || !frm.doc.effective_date) {
|
||||||
|
frm.set_intro("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
frm.set_intro(
|
||||||
|
__(
|
||||||
|
"On submission, stock transactions for Item {0} cannot be posted with a date before {1} — backdated entries will be blocked.",
|
||||||
|
[
|
||||||
|
frappe.utils.escape_html(frm.doc.item_code).bold(),
|
||||||
|
frappe.datetime.str_to_user(frm.doc.effective_date).bold(),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
"yellow"
|
||||||
|
);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,6 +33,25 @@ class ItemStandardCost(Document):
|
|||||||
self.validate_item()
|
self.validate_item()
|
||||||
self.validate_effective_date()
|
self.validate_effective_date()
|
||||||
self.validate_rate()
|
self.validate_rate()
|
||||||
|
self.warn_backdated_transactions_will_be_blocked()
|
||||||
|
|
||||||
|
def warn_backdated_transactions_will_be_blocked(self):
|
||||||
|
# Heads-up while creating (R2 enforces it later on every stock voucher): once this rate is
|
||||||
|
# effective, the item's stock transactions cannot be dated before the effective date.
|
||||||
|
if not self.is_new():
|
||||||
|
return
|
||||||
|
frappe.msgprint(
|
||||||
|
_(
|
||||||
|
"Once this Standard Cost is submitted, stock transactions for Item {0} in {1} cannot be posted with a date before the Effective Date {2}. Post any backdated entries before submitting."
|
||||||
|
).format(
|
||||||
|
get_link_to_form("Item", self.item_code),
|
||||||
|
frappe.bold(self.company),
|
||||||
|
frappe.bold(frappe.format(self.effective_date, "Date")),
|
||||||
|
),
|
||||||
|
title=_("Backdated Entries Will Be Blocked"),
|
||||||
|
indicator="orange",
|
||||||
|
alert=True,
|
||||||
|
)
|
||||||
|
|
||||||
def validate_item(self):
|
def validate_item(self):
|
||||||
if not frappe.get_cached_value("Item", self.item_code, "is_stock_item"):
|
if not frappe.get_cached_value("Item", self.item_code, "is_stock_item"):
|
||||||
|
|||||||
Reference in New Issue
Block a user