[minor] [refactor]

This commit is contained in:
Rushabh Mehta 2015-05-29 15:56:24 +05:30
parent e3035a593c
commit 4a4a6594d1
2 changed files with 5 additions and 3 deletions

View File

@ -44,11 +44,14 @@ class NewsletterList(Document):
return self.update_total_subscribers() return self.update_total_subscribers()
def update_total_subscribers(self): def update_total_subscribers(self):
self.total_subscribers = frappe.db.sql("""select count(*) from `tabNewsletter List Subscriber` self.total_subscribers = self.get_total_subscribers()
where newsletter_list=%s""", self.name)[0][0]
self.db_update() self.db_update()
return self.total_subscribers return self.total_subscribers
def get_total_subscribers(self):
return frappe.db.sql("""select count(*) from `tabNewsletter List Subscriber`
where newsletter_list=%s""", self.name)[0][0]
def on_trash(self): def on_trash(self):
for d in frappe.get_all("Newsletter List Subscriber", "name", {"newsletter_list": self.name}): for d in frappe.get_all("Newsletter List Subscriber", "name", {"newsletter_list": self.name}):
frappe.delete_doc("Newsletter List Subscriber", d.name) frappe.delete_doc("Newsletter List Subscriber", d.name)

View File

@ -12,7 +12,6 @@ from frappe.model.document import Document
class NamingSeriesNotSetError(frappe.ValidationError): pass class NamingSeriesNotSetError(frappe.ValidationError): pass
class NamingSeries(Document): class NamingSeries(Document):
def get_transactions(self, arg=None): def get_transactions(self, arg=None):
doctypes = list(set(frappe.db.sql_list("""select parent doctypes = list(set(frappe.db.sql_list("""select parent
from `tabDocField` where fieldname='naming_series'""") from `tabDocField` where fieldname='naming_series'""")