fix: incorrect schedule showing in the draft mode

This commit is contained in:
Rohit Waghchaure 2019-05-24 18:21:48 +05:30
parent e6b8b1de0b
commit 30c401deee
2 changed files with 15 additions and 11 deletions

View file

@ -29,9 +29,9 @@ frappe.ui.form.on('Auto Repeat', {
},
refresh: function(frm) {
if(frm.doc.docstatus == 1) {
let label = __('View {0}', [__(frm.doc.reference_doctype)]);
frm.add_custom_button(__(label),
function() {
@ -57,12 +57,13 @@ frappe.ui.form.on('Auto Repeat', {
}
);
}
if(frm.doc.docstatus!= 0 && !frm.doc.status.includes('Stopped', 'Cancelled') && frm.doc.next_schedule_date >= frappe.datetime.get_today()){
frappe.auto_repeat.render_schedule(frm);
}
}
frm.toggle_display('auto_repeat_schedule', !in_list(['Stopped', 'Cancelled'], frm.doc.status));
if(frm.doc.start_date && !in_list(['Stopped', 'Cancelled'], frm.doc.status)){
frappe.auto_repeat.render_schedule(frm);
}
},
stop_resume_auto_repeat: function(frm, status) {
@ -138,6 +139,6 @@ frappe.auto_repeat.render_schedule = function(frm) {
}).done((r) => {
var wrapper = $(frm.fields_dict["auto_repeat_schedule"].wrapper);
wrapper.html(frappe.render_template ("auto_repeat_schedule", {"schedule_details" : r.message || []} ));
frm.refresh_fields();
});
frm.refresh_fields() ;
};

View file

@ -19,9 +19,6 @@ month_map = {'Monthly': 1, 'Quarterly': 3, 'Half-yearly': 6, 'Yearly': 12}
class AutoRepeat(Document):
def onload(self):
self.set_onload("auto_repeat_schedule", self.get_auto_repeat_schedule())
def validate(self):
self.update_status()
self.validate_reference_doctype()
@ -41,6 +38,9 @@ class AutoRepeat(Document):
def on_submit(self):
self.update_auto_repeat_id()
def on_cancel(self):
self.update_status()
def on_update_after_submit(self):
self.validate_dates()
self.set_next_schedule_date()
@ -103,6 +103,9 @@ class AutoRepeat(Document):
if status and status != 'Resumed':
self.status = status
if self.docstatus == 2:
self.db_set("status", self.status)
def get_auto_repeat_schedule(self):
schedule_details = []
start_date_copy = getdate(self.start_date)