disable due date field if form has payment schedule data

This commit is contained in:
tunde 2017-08-31 14:30:53 +01:00
parent 50ec45d3b6
commit 229b583715
2 changed files with 38 additions and 0 deletions

View File

@ -372,3 +372,22 @@ frappe.ui.form.on("Purchase Invoice", {
frm.toggle_reqd("supplier_warehouse", frm.doc.is_subcontracted==="Yes");
}
})
frappe.ui.form.on("Purchase Invoice", {
payment_terms_template: function() {
cur_frm.trigger("disable_due_date");
},
disable_due_date: function() {
const disable = !cur_frm.doc.payment_terms_template && cur_frm.doc.payment_schedule.length == 0;
cur_frm.set_df_property("due_date", "read_only", disable ? 1 : 0);
},
});
frappe.ui.form.on("Payment Schedule", {
payment_schedule_remove: function() {
cur_frm.trigger("disable_due_date");
},
});

View File

@ -564,3 +564,22 @@ var calculate_total_billing_amount = function(frm) {
refresh_field('total_billing_amount')
}
frappe.ui.form.on("Sales Invoice", {
payment_terms_template: function() {
cur_frm.trigger("disable_due_date");
},
disable_due_date: function() {
const disable = !cur_frm.doc.payment_terms_template && cur_frm.doc.payment_schedule.length == 0;
cur_frm.set_df_property("due_date", "read_only", disable ? 1 : 0);
},
});
frappe.ui.form.on("Payment Schedule", {
payment_schedule_remove: function() {
cur_frm.trigger("disable_due_date");
},
});