From 737d8e4d9fa61aadc815071d5b6100dd0c881563 Mon Sep 17 00:00:00 2001 From: ankitjavalkarwork Date: Mon, 1 Sep 2014 16:18:44 +0530 Subject: [PATCH] fix minor issue and set default value send as pdf --- erpnext/controllers/recurring_document.py | 10 ++++++---- erpnext/controllers/tests/test_recurring_document.py | 7 ++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/erpnext/controllers/recurring_document.py b/erpnext/controllers/recurring_document.py index d9326792f3..729c6f7f9c 100644 --- a/erpnext/controllers/recurring_document.py +++ b/erpnext/controllers/recurring_document.py @@ -111,12 +111,13 @@ def get_next_date(dt, mcount, day=None): def send_notification(new_rv): """Notify concerned persons about recurring document generation""" + frappe.sendmail(new_rv.notification_email_address, subject= _("New {0}: #{1}").format(new_rv.doctype, new_rv.name), message = _("Please find attached {0} #{1}").format(new_rv.doctype, new_rv.name), attachments = [{ "fname": new_rv.name + ".pdf", - "fcontent": frappe.get_print_format(new_rv.doctype, new_rv.name, as_pdf=True).encode('utf-8') + "fcontent": frappe.get_print_format(new_rv.doctype, new_rv.name, as_pdf=True) }]) def notify_errors(doc, doctype, customer, owner): @@ -186,12 +187,13 @@ def validate_notification_email_id(doc): def set_next_date(doc, posting_date): """ Set next date on which recurring document will be created""" - from erpnext.controllers.recurring_document import get_next_date - + if not doc.repeat_on_day_of_month: msgprint(_("Please enter 'Repeat on Day of Month' field value"), raise_exception=1) next_date = get_next_date(posting_date, month_map[doc.recurring_type], cint(doc.repeat_on_day_of_month)) - frappe.db.set(doc, 'next_date', next_date) \ No newline at end of file + frappe.db.set(doc, 'next_date', next_date) + + msgprint(_("Next Recurring {0} will be created on {1}").format(doc.doctype, next_date)) diff --git a/erpnext/controllers/tests/test_recurring_document.py b/erpnext/controllers/tests/test_recurring_document.py index 5332ae0541..0e7cb1bc5e 100644 --- a/erpnext/controllers/tests/test_recurring_document.py +++ b/erpnext/controllers/tests/test_recurring_document.py @@ -12,6 +12,7 @@ from erpnext.projects.doctype.time_log_batch.test_time_log_batch import * def test_recurring_document(obj, test_records): from frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate, add_days from erpnext.accounts.utils import get_fiscal_year + frappe.db.set_value("Print Settings", "Print Settings", "send_print_as_pdf", 1) today = nowdate() base_doc = frappe.copy_doc(test_records[0]) @@ -104,13 +105,13 @@ def test_recurring_document(obj, test_records): # change date field but keep recurring day to be today doc7 = frappe.copy_doc(base_doc) doc7.update({ - date_field: add_to_date(today, days=-1) + date_field: today, }) doc7.insert() doc7.submit() # setting so that _test function works - doc7.set(date_field, today) + # doc7.set(date_field, today) _test_recurring_document(obj, doc7, date_field, True) def _test_recurring_document(obj, base_doc, date_field, first_and_last_day): @@ -162,4 +163,4 @@ def _test_recurring_document(obj, base_doc, date_field, first_and_last_day): # if yearly, test 1 repetition, else test 5 repetitions count = 1 if (no_of_months == 12) else 5 for i in xrange(count): - base_doc = _test(i) \ No newline at end of file + base_doc = _test(i)