diff --git a/frappe/desk/doctype/auto_repeat/auto_repeat.js b/frappe/desk/doctype/auto_repeat/auto_repeat.js index 1abf726466..c52711ba23 100644 --- a/frappe/desk/doctype/auto_repeat/auto_repeat.js +++ b/frappe/desk/doctype/auto_repeat/auto_repeat.js @@ -116,7 +116,6 @@ frappe.auto_repeat.render_schedule = function(frm) { doc: frm.doc }).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() ; diff --git a/frappe/desk/doctype/auto_repeat/auto_repeat.json b/frappe/desk/doctype/auto_repeat/auto_repeat.json index 7a085e1963..1a0fba42a5 100644 --- a/frappe/desk/doctype/auto_repeat/auto_repeat.json +++ b/frappe/desk/doctype/auto_repeat/auto_repeat.json @@ -458,7 +458,7 @@ "remember_last_selected_value": 0, "report_hide": 0, "reqd": 0, - "search_index": 0, + "search_index": 1, "set_only_once": 0, "translatable": 0, "unique": 0 @@ -468,7 +468,7 @@ "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, - "collapsible": 0, + "collapsible": 1, "columns": 0, "fieldname": "section_break_13", "fieldtype": "Section Break", @@ -965,7 +965,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-06-27 19:28:27.704807", + "modified": "2018-07-13 15:14:34.524098", "modified_by": "Administrator", "module": "Desk", "name": "Auto Repeat", diff --git a/frappe/desk/doctype/auto_repeat/auto_repeat.py b/frappe/desk/doctype/auto_repeat/auto_repeat.py index b752827bfe..c0a3339b94 100644 --- a/frappe/desk/doctype/auto_repeat/auto_repeat.py +++ b/frappe/desk/doctype/auto_repeat/auto_repeat.py @@ -18,7 +18,7 @@ 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()) + self.set_onload("auto_repeat_schedule", self.get_auto_repeat_schedule()) def validate(self): self.update_status() @@ -105,10 +105,14 @@ class AutoRepeat(Document): start_date_copy = getdate(self.start_date) end_date_copy = getdate(self.end_date) today_copy = frappe.utils.datetime.date.today() + if start_date_copy < today_copy: start_date_copy = today_copy + if not self.end_date: - end_date_copy = add_days(today_copy, 365) + days = 60 if self.frequency in ['Daily', 'Weekly'] else 365 + end_date_copy = add_days(today_copy, days) + while (getdate(start_date_copy) < getdate(end_date_copy)): start_date_copy = get_next_schedule_date(start_date_copy, self.frequency, self.repeat_on_day) row = { @@ -117,6 +121,7 @@ class AutoRepeat(Document): "next_scheduled_date" : start_date_copy } schedule_details.append(row) + return schedule_details def get_next_schedule_date(start_date, frequency, repeat_on_day): @@ -131,21 +136,21 @@ def get_next_schedule_date(start_date, frequency, repeat_on_day): def make_auto_repeat_entry(date=None): date = date or today() for data in get_auto_repeat_entries(date): + schedule_date = getdate(data.next_schedule_date) while schedule_date <= getdate(today()): create_documents(data, schedule_date) - schedule_date = get_next_schedule_date( - schedule_date, data.frequency, data.repeat_on_day) + schedule_date = get_next_schedule_date(schedule_date, data.frequency, data.repeat_on_day) - if schedule_date and not frappe.db.get_value('Auto Repeat', data.name, 'disabled'): - frappe.db.set_value('Auto Repeat', data.name, 'next_schedule_date', schedule_date) + if schedule_date and not frappe.db.get_value('Auto Repeat', data.name, 'disabled'): + frappe.db.set_value('Auto Repeat', data.name, 'next_schedule_date', schedule_date) def get_auto_repeat_entries(date): return frappe.db.sql(""" select * from `tabAuto Repeat` where docstatus = 1 and next_schedule_date <=%s and reference_document is not null and reference_document != '' and next_schedule_date <= ifnull(end_date, '2199-12-31') - and ifnull(disabled, 0) = 0 and status != 'Stopped' """, (date), as_dict=1) + and disabled = 0 and status != 'Stopped' """, (date), as_dict=1) def create_documents(data, schedule_date): try: @@ -370,4 +375,4 @@ def update_reference(docname, reference): return "success" except Exception as e: raise e - return "error" \ No newline at end of file + return "error"