From cea01c72127ca0666085fda069bb1bd12eeec8f0 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 19 Jul 2012 09:15:12 +0530 Subject: [PATCH 1/3] item code get query in customer issue --- erpnext/support/doctype/customer_issue/customer_issue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/support/doctype/customer_issue/customer_issue.js b/erpnext/support/doctype/customer_issue/customer_issue.js index 0749424d92..545ff5669f 100644 --- a/erpnext/support/doctype/customer_issue/customer_issue.js +++ b/erpnext/support/doctype/customer_issue/customer_issue.js @@ -128,7 +128,7 @@ cur_frm.fields_dict['item_code'].get_query = function(doc, cdt, cdn) { else{ return 'SELECT `tabItem`.name, `tabItem`.item_name, `tabItem`.description \ FROM `tabItem` \ - WHERE `tabItem`.docstatus != 2 AND `tabItem`.name LIKE "%s" ORDER BY `tabItem`.name ASC LIMIT 50'; + WHERE `tabItem`.docstatus != 2 AND `tabItem`.%(key)s LIKE "%s" ORDER BY `tabItem`.name ASC LIMIT 50'; } } From 93e82b8742b7d7a069ad5879490448e1102a0896 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 20 Jul 2012 10:40:14 +0530 Subject: [PATCH 2/3] error fixed in landed cost wizard --- erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py index c2df6c1a71..f73845c80a 100644 --- a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py +++ b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py @@ -236,7 +236,7 @@ class DocType: def update_serial_no(self, sr_no, rate): """ update valuation rate in serial no""" - sr_no = sr_no.split('\n') + sr_no = cstr(sr_no).split('\n') for d in sr_no: sql("update `tabSerial No` set purchase_rate = %s where name = %s", (rate, d)) From 454e268109093f96074d7577981843d72951ec79 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 20 Jul 2012 17:17:32 +0530 Subject: [PATCH 3/3] Recurring Invoice repititive mail sending issue fixed --- .../accounts/doctype/gl_control/gl_control.py | 77 +++++++++++++++++-- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/gl_control/gl_control.py b/erpnext/accounts/doctype/gl_control/gl_control.py index bfeddb0c52..78bfeec346 100644 --- a/erpnext/accounts/doctype/gl_control/gl_control.py +++ b/erpnext/accounts/doctype/gl_control/gl_control.py @@ -23,6 +23,7 @@ from webnotes.model.doc import Document, addchild, getchildren, make_autoname from webnotes.model.doclist import getlist, copy_doclist, clone from webnotes.model.code import get_obj from webnotes import session, form, is_testing, msgprint, errprint +from webnotes.utils.email_lib import sendmail in_transaction = webnotes.conn.in_transaction convert_to_lists = webnotes.conn.convert_to_lists @@ -489,14 +490,78 @@ def manage_recurring_invoices(): rv = webnotes.conn.sql("""select name, recurring_id from `tabSales Invoice` \ where ifnull(convert_into_recurring_invoice, 0) = 1 and next_date = %s \ and next_date <= ifnull(end_date, '2199-12-31') and docstatus=1""", nowdate()) - + + + exception_list = [] for d in rv: if not webnotes.conn.sql("""select name from `tabSales Invoice` \ where posting_date = %s and recurring_id = %s and docstatus=1""", (nowdate(), d[1])): - prev_rv = get_obj('Sales Invoice', d[0], with_children=1) - new_rv = create_new_invoice(prev_rv) + try: + prev_rv = get_obj('Sales Invoice', d[0], with_children=1) + new_rv = create_new_invoice(prev_rv) - send_notification(new_rv) + send_notification(new_rv) + webnotes.conn.commit() + except Exception, e: + webnotes.conn.rollback() + + webnotes.conn.begin() + webnotes.conn.sql("update `tabSales Invoice` set \ + convert_into_recurring_invoice = 0 where name = %s", d[0]) + notify_errors(d[0], prev_rv.doc.owner) + webnotes.conn.commit() + + exception_list.append(e) + finally: + webnotes.conn.begin() + + if exception_list: + exception_message = "\n\n".join([cstr(d) for d in exception_list]) + raise Exception, exception_message + + +def notify_errors(inv, owner): + exception_msg = """ + Dear User, + + An error occured while creating recurring invoice from %s. + + May be there are some invalid email ids mentioned in the invoice. + + To stop sending repetitive error notifications from the system, we have unchecked \ + "Convert into Recurring" field in the invoice %s. + + + Please correct the invoice and make the invoice recurring again. + + It is necessary to take this action today itself for the above mentioned recurring invoice \ + to be generated. If delayed, you will have to manually change the "Repeat on Day of Month" field \ + of this invoice for generating the recurring invoice. + + Regards, + Administrator + + """ % (inv, inv) + subj = "[Urgent] Error while creating recurring invoice from %s" % inv + import webnotes.utils + recipients = webnotes.utils.get_system_managers_list() + recipients += ['support@erpnext.com', owner] + assign_task_to_owner(inv, exception_msg, recipients) + sendmail(recipients, subject=subj, msg = exception_msg) + + + +def assign_task_to_owner(inv, msg, users): + for d in users: + from webnotes.widgets.form import assign_to + args = { + 'assign_to' : d, + 'doctype' : 'Sales Invoice', + 'name' : inv, + 'description' : msg, + 'priority' : 'Urgent' + } + assign_to.add(args) def create_new_invoice(prev_rv): @@ -594,5 +659,5 @@ def send_notification(new_rv): msg = hd + tbl + totals - from webnotes.utils.email_lib import sendmail - sendmail(new_rv.doc.notification_email_address.split(", "), subject=subject, msg = msg) \ No newline at end of file + recipients = new_rv.doc.notification_email_address.replace('\n', '').replace(' ', '').split(",") + sendmail(recipients, subject=subject, msg = msg) \ No newline at end of file