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 <sagar@resilient.tech>
This commit is contained in:
Joseph Marie Alba 2020-10-19 19:32:04 +08:00 committed by GitHub
parent 174019a838
commit 8115be58a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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());
}
},