mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
fix minor issue and set default value send as pdf
This commit is contained in:
@@ -111,12 +111,13 @@ def get_next_date(dt, mcount, day=None):
|
|||||||
|
|
||||||
def send_notification(new_rv):
|
def send_notification(new_rv):
|
||||||
"""Notify concerned persons about recurring document generation"""
|
"""Notify concerned persons about recurring document generation"""
|
||||||
|
|
||||||
frappe.sendmail(new_rv.notification_email_address,
|
frappe.sendmail(new_rv.notification_email_address,
|
||||||
subject= _("New {0}: #{1}").format(new_rv.doctype, new_rv.name),
|
subject= _("New {0}: #{1}").format(new_rv.doctype, new_rv.name),
|
||||||
message = _("Please find attached {0} #{1}").format(new_rv.doctype, new_rv.name),
|
message = _("Please find attached {0} #{1}").format(new_rv.doctype, new_rv.name),
|
||||||
attachments = [{
|
attachments = [{
|
||||||
"fname": new_rv.name + ".pdf",
|
"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):
|
def notify_errors(doc, doctype, customer, owner):
|
||||||
@@ -186,7 +187,6 @@ def validate_notification_email_id(doc):
|
|||||||
|
|
||||||
def set_next_date(doc, posting_date):
|
def set_next_date(doc, posting_date):
|
||||||
""" Set next date on which recurring document will be created"""
|
""" 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:
|
if not doc.repeat_on_day_of_month:
|
||||||
msgprint(_("Please enter 'Repeat on Day of Month' field value"), raise_exception=1)
|
msgprint(_("Please enter 'Repeat on Day of Month' field value"), raise_exception=1)
|
||||||
@@ -195,3 +195,5 @@ def set_next_date(doc, posting_date):
|
|||||||
cint(doc.repeat_on_day_of_month))
|
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))
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from erpnext.projects.doctype.time_log_batch.test_time_log_batch import *
|
|||||||
def test_recurring_document(obj, test_records):
|
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 frappe.utils import get_first_day, get_last_day, add_to_date, nowdate, getdate, add_days
|
||||||
from erpnext.accounts.utils import get_fiscal_year
|
from erpnext.accounts.utils import get_fiscal_year
|
||||||
|
frappe.db.set_value("Print Settings", "Print Settings", "send_print_as_pdf", 1)
|
||||||
today = nowdate()
|
today = nowdate()
|
||||||
base_doc = frappe.copy_doc(test_records[0])
|
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
|
# change date field but keep recurring day to be today
|
||||||
doc7 = frappe.copy_doc(base_doc)
|
doc7 = frappe.copy_doc(base_doc)
|
||||||
doc7.update({
|
doc7.update({
|
||||||
date_field: add_to_date(today, days=-1)
|
date_field: today,
|
||||||
})
|
})
|
||||||
doc7.insert()
|
doc7.insert()
|
||||||
doc7.submit()
|
doc7.submit()
|
||||||
|
|
||||||
# setting so that _test function works
|
# setting so that _test function works
|
||||||
doc7.set(date_field, today)
|
# doc7.set(date_field, today)
|
||||||
_test_recurring_document(obj, doc7, date_field, True)
|
_test_recurring_document(obj, doc7, date_field, True)
|
||||||
|
|
||||||
def _test_recurring_document(obj, base_doc, date_field, first_and_last_day):
|
def _test_recurring_document(obj, base_doc, date_field, first_and_last_day):
|
||||||
|
|||||||
Reference in New Issue
Block a user