[fix] posting date, time is always current unless explicitly set

This commit is contained in:
Rushabh Mehta
2017-03-14 16:59:11 +05:30
parent 6a053a989e
commit 6b53792aea
19 changed files with 498 additions and 298 deletions

View File

@@ -18,6 +18,36 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({
});
},
setup_posting_date_time_check: function() {
// make posting date default and read only unless explictly checked
frappe.ui.form.on(this.frm.doctype, 'set_posting_date_and_time_read_only', function(frm) {
if(frm.doc.docstatus == 0 && frm.doc.set_posting_time) {
frm.set_df_property('posting_date', 'read_only', 0);
frm.set_df_property('posting_time', 'read_only', 0);
} else {
frm.set_df_property('posting_date', 'read_only', 1);
frm.set_df_property('posting_time', 'read_only', 1);
}
})
frappe.ui.form.on(this.frm.doctype, 'set_posting_time', function(frm) {
frm.trigger('set_posting_date_and_time_read_only');
});
frappe.ui.form.on(this.frm.doctype, 'refresh', function(frm) {
// set default posting date / time
if(frm.doc.docstatus==0) {
if(!frm.doc.posting_date) {
frm.set_value('posting_date', frappe.datetime.nowdate());
}
if(!frm.doc.posting_time) {
frm.set_value('posting_time', frappe.datetime.now_time());
}
frm.trigger('set_posting_date_and_time_read_only');
}
});
},
show_stock_ledger: function() {
var me = this;
if(this.frm.doc.docstatus===1) {