fix(projects): Remove hardcode of expected end date for new Tasks (#17716)

This commit is contained in:
Rohan
2019-06-05 14:16:57 +05:30
committed by Nabin Hait
parent 88832daae4
commit b20eda9996

View File

@@ -19,43 +19,38 @@ frappe.ui.form.on("Task", {
},
refresh: function(frm) {
frm.fields_dict['parent_task'].get_query = function() {
frm.fields_dict['parent_task'].get_query = function () {
return {
filters: {
"is_group": 1,
}
}
}
if(!frm.is_group){
var doc = frm.doc;
if(doc.__islocal) {
if(!frm.doc.exp_end_date) {
frm.set_value("exp_end_date", frappe.datetime.add_days(new Date(), 7));
}
}
if(!doc.__islocal) {
if(frappe.model.can_read("Timesheet")) {
frm.add_custom_button(__("Timesheet"), function() {
frappe.route_options = {"project": doc.project, "task": doc.name}
if (!frm.doc.is_group) {
if (!frm.is_new()) {
if (frappe.model.can_read("Timesheet")) {
frm.add_custom_button(__("Timesheet"), () => {
frappe.route_options = { "project": frm.doc.project, "task": frm.doc.name }
frappe.set_route("List", "Timesheet");
}, __("View"), true);
}
if(frappe.model.can_read("Expense Claim")) {
frm.add_custom_button(__("Expense Claims"), function() {
frappe.route_options = {"project": doc.project, "task": doc.name}
if (frappe.model.can_read("Expense Claim")) {
frm.add_custom_button(__("Expense Claims"), () => {
frappe.route_options = { "project": frm.doc.project, "task": frm.doc.name }
frappe.set_route("List", "Expense Claim");
}, __("View"), true);
}
if(frm.perm[0].write) {
if(frm.doc.status!=="Closed" && frm.doc.status!=="Cancelled") {
frm.add_custom_button(__("Close"), function() {
if (frm.perm[0].write) {
if (!["Closed", "Cancelled"].includes(frm.doc.status)) {
frm.add_custom_button(__("Close"), () => {
frm.set_value("status", "Closed");
frm.save();
});
} else {
frm.add_custom_button(__("Reopen"), function() {
frm.add_custom_button(__("Reopen"), () => {
frm.set_value("status", "Open");
frm.save();
});