From 8115be58a3e4b0a4aaf2d3b1c7f617b3d6a4af7c Mon Sep 17 00:00:00 2001 From: Joseph Marie Alba Date: Mon, 19 Oct 2020 19:32:04 +0800 Subject: [PATCH] fix: Posting Date bug in load_defaults (#23415) this.frm.posting_date is always invalid and should be changed to this.frm.doc.posting_date The effect of this bug fix is, a default Posting Date value may now be set in Custom Script's onload event, and the default value will be honored. Example: (Assuming posting date has been included in standard filter) ``` frappe.ui.form.on('Journal Entry', { before_load(frm) { var posting_date = $("input[data-fieldname='posting_date']")[0].value posting_date = moment(posting_date)._d frm.set_value('posting_date', posting_date ) } }) ``` Without the fix, the posting date will always be today's date. With the bug fix, the default value for posting date which is taken from the posting date's Standard Filter vale is honored. Co-authored-by: Sagar Vora --- erpnext/accounts/doctype/journal_entry/journal_entry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 409c15f75ce..ff12967155f 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -210,7 +210,7 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ $.each(this.frm.doc.accounts || [], function(i, jvd) { frappe.model.set_default_values(jvd); }); - var posting_date = this.frm.posting_date; + var posting_date = this.frm.doc.posting_date; if(!this.frm.doc.amended_from) this.frm.set_value('posting_date', posting_date || frappe.datetime.get_today()); } },