fix minor issue and set default value send as pdf

This commit is contained in:
ankitjavalkarwork 2014-09-01 16:18:44 +05:30
parent aaac7c17b8
commit 737d8e4d9f
2 changed files with 10 additions and 7 deletions

View File

@ -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)
frappe.db.set(doc, 'next_date', next_date)
msgprint(_("Next Recurring {0} will be created on {1}").format(doc.doctype, next_date))

View File

@ -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)
base_doc = _test(i)