diff --git a/erpnext/controllers/recurring_document.py b/erpnext/controllers/recurring_document.py index d5499a3769..a853e10d87 100644 --- a/erpnext/controllers/recurring_document.py +++ b/erpnext/controllers/recurring_document.py @@ -166,6 +166,9 @@ def validate_recurring_document(doc): if doc.is_recurring: validate_notification_email_id(doc) + if not doc.recurring_id: + doc.recurring_id = doc.name + if not doc.recurring_type: msgprint(_("Please select {0}").format(doc.meta.get_label("recurring_type")), raise_exception=1) @@ -176,9 +179,6 @@ def validate_recurring_document(doc): # def convert_to_recurring(doc, posting_date): if doc.is_recurring: - if not doc.recurring_id: - frappe.db.set(doc, "recurring_id", doc.name) - set_next_date(doc, posting_date) elif doc.recurring_id: diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 8c4b36de0d..c1e801d2fa 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -839,6 +839,12 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ is_recurring: function() { // set default values for recurring documents + if(this.frm.doc.is_recurring && this.frm.doc.__islocal) { + frappe.msgprint(__("Please set recurring after saving")); + this.frm.set_value('is_recurring', 0); + return; + } + if(!this.frm.doc.recurring_id) { this.frm.set_value('recurring_id', this.frm.doc.name); }