validate notification_email_ids in recurring invoice and if user is administrator set email id from profile
This commit is contained in:
parent
7839ea9687
commit
e8ff96565c
@ -553,6 +553,9 @@ def notify_errors(inv, owner):
|
||||
|
||||
def assign_task_to_owner(inv, msg, users):
|
||||
for d in users:
|
||||
if d.lower() == 'administrator':
|
||||
d = webnotes.conn.sql("select ifnull(email_id, '') \
|
||||
from `tabProfile` where name = 'Administrator'")[0][0]
|
||||
from webnotes.widgets.form import assign_to
|
||||
args = {
|
||||
'assign_to' : d,
|
||||
|
@ -499,12 +499,9 @@ cur_frm.cscript.view_ledger_entry = function(){
|
||||
}
|
||||
|
||||
// Default values for recurring invoices
|
||||
cur_frm.cscript.convert_into_recurring_invoice = function(doc) {
|
||||
if (doc.convert_into_recurring_invoice) {
|
||||
doc.repeat_on_day_of_month = doc.posting_date.split('-')[2];
|
||||
doc.notification_email_address = [doc.owner, doc.contact_email].join(', ');
|
||||
refresh_field(['repeat_on_day_of_month', 'notification_email_address']);
|
||||
}
|
||||
cur_frm.cscript.convert_into_recurring_invoice = function(doc, dt, dn) {
|
||||
if (doc.convert_into_recurring_invoice)
|
||||
get_server_fields('set_default_recurring_values','','',doc, dt, dn, 0);
|
||||
}
|
||||
|
||||
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
|
||||
|
@ -679,10 +679,31 @@ class DocType(TransactionBase):
|
||||
webnotes.conn.set(self.doc,'outstanding_amount',flt(self.doc.grand_total) - flt(self.doc.total_advance) - flt(self.doc.paid_amount) - flt(self.doc.write_off_amount))
|
||||
|
||||
#-------------------------------------------------------------------------------------
|
||||
|
||||
def set_default_recurring_values(self):
|
||||
owner_email = self.doc.owner
|
||||
if owner_email.lower() == 'administrator':
|
||||
owner_email = webnotes.conn.sql("select ifnull(email, '') \
|
||||
from `tabProfile` where name = 'Administrator'")[0][0]
|
||||
ret = {
|
||||
'repeat_on_day_of_month' : getdate(self.doc.posting_date).day,
|
||||
'notification_email_address' : ', '.join([cstr(owner_email), self.doc.contact_email])
|
||||
}
|
||||
return ret
|
||||
|
||||
def validate_notification_email_id(self):
|
||||
from webnotes.utils import validate_email_add
|
||||
email_ids = self.doc.notification_email_address.replace('\n', '').replace(' ', '').split(",")
|
||||
for add in email_ids:
|
||||
if add and not validate_email_add(add):
|
||||
msgprint("%s is not a valid email address" % add, raise_exception=1)
|
||||
|
||||
|
||||
def on_update_after_submit(self):
|
||||
self.validate_notification_email_id()
|
||||
self.convert_into_recurring()
|
||||
|
||||
|
||||
|
||||
def convert_into_recurring(self):
|
||||
if self.doc.convert_into_recurring_invoice:
|
||||
if not self.doc.recurring_type:
|
||||
|
Loading…
x
Reference in New Issue
Block a user