From f79ef5d8cf91d9c4a3d7d390e024c47cb1ec963c Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Wed, 19 May 2021 13:04:44 +0530 Subject: [PATCH] fix: missing cost center message on creating gl entries --- erpnext/accounts/doctype/gl_entry/gl_entry.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index 78febf9c2e..948c51364e 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -75,8 +75,13 @@ class GLEntry(Document): def pl_must_have_cost_center(self): if frappe.get_cached_value("Account", self.account, "report_type") == "Profit and Loss": if not self.cost_center and self.voucher_type != 'Period Closing Voucher': - frappe.throw(_("{0} {1}: Cost Center is required for 'Profit and Loss' account {2}. Please set up a default Cost Center for the Company.") - .format(self.voucher_type, self.voucher_no, self.account)) + msg = _("{0} {1}: Cost Center is required for 'Profit and Loss' account {2}.").format( + self.voucher_type, self.voucher_no, self.account) + msg += " " + msg += _("Please set the cost center field in {0} or setup a default Cost Center for the Company.").format( + self.voucher_type) + + frappe.throw(msg, title=_("Missing Cost Center")) def validate_dimensions_for_pl_and_bs(self): account_type = frappe.db.get_value("Account", self.account, "report_type")