fix: remove frm call for priority change

This commit is contained in:
Himanshu Warekar 2019-06-28 19:07:13 +05:30
parent 130dcffcc8
commit 5cec89d1ab
4 changed files with 12 additions and 25 deletions

View File

@ -18,6 +18,8 @@ def set_issue_priority():
"name": priority
}).insert(ignore_permissions=True)
frappe.delete_doc_if_exists("Property Setter", {"field_name": "priority", "property": "options"})
def set_priority_for_issue():
# Sets priority for Issues as Select field is changed to Link field.
issue_priority = frappe.get_list("Issue", fields=["name", "priority"])

View File

@ -73,27 +73,6 @@ frappe.ui.form.on("Issue", {
}
},
priority: function(frm) {
if (frm.doc.service_level_agreement) {
frm.call('change_service_level_agreement_and_priority', {
"priority": frm.doc.priority,
"service_level_agreement": frm.doc.service_level_agreement
}).then(() => {
frappe.msgprint(__("Issue Priority changed to {0}.", [frm.doc.priority]));
frm.refresh();
});
}
},
service_level_agreement: function(frm) {
frm.call('change_service_level_agreement_and_priority', {
"service_level_agreement": frm.doc.service_level_agreement
}).then(() => {
frappe.msgprint(__("Service Level Agreement changed to {0}.", [frm.doc.service_level_agreement]));
frm.refresh();
});
},
timeline_refresh: function(frm) {
// create button for "Help Article"
if(frappe.model.can_create('Help Article')) {

View File

@ -29,6 +29,7 @@ class Issue(Document):
if not self.raised_by:
self.raised_by = frappe.session.user
self.change_service_level_agreement_and_priority()
self.update_status()
self.set_lead_contact(self.raised_by)
@ -173,9 +174,14 @@ class Issue(Document):
self.response_by_variance = round(time_diff_in_hours(self.response_by, now_datetime()))
self.resolution_by_variance = round(time_diff_in_hours(self.resolution_by, now_datetime()))
def change_service_level_agreement_and_priority(self, priority=None, service_level_agreement=None):
self.set_response_and_resolution_time(priority=priority, service_level_agreement=service_level_agreement)
self.save(ignore_permissions=True)
def change_service_level_agreement_and_priority(self):
if not self.priority == frappe.db.get_value("Issue", self.name, "priority"):
self.set_response_and_resolution_time(priority=self.priority, service_level_agreement=self.service_level_agreement)
frappe.msgprint("Priority has been updated.")
if not self.service_level_agreement == frappe.db.get_value("Issue", self.name, "service_level_agreement"):
self.set_response_and_resolution_time(priority=self.priority, service_level_agreement=self.service_level_agreement)
frappe.msgprint("Service Level Agreement has been updated.")
def get_expected_time_for(parameter, service_level, start_date_time):
current_date_time = start_date_time

View File

@ -18,7 +18,7 @@ class ServiceLevelAgreement(Document):
if self.start_date >= self.end_date:
frappe.throw(_("Start Date of Agreement can't be greater than or equal to End Date."))
if self.end_date < frappe.utils.getdate():
if self.end_date < frappe.utils.nowdate():
frappe.throw(_("End Date of Agreement can't be less than today."))
if self.entity_type and self.entity: