This commit is contained in:
Rushabh Mehta 2014-09-12 15:04:25 +05:30
parent e10cf021d9
commit 7fb79f6062

View File

@ -12,15 +12,27 @@ from frappe.model.document import Document
class NamingSeries(Document):
def get_transactions(self, arg=None):
doctypes = list(set(frappe.db.sql_list("""select parent
from `tabDocField` where fieldname='naming_series'""")
+ frappe.db.sql_list("""select dt from `tabCustom Field`
where fieldname='naming_series'""")))
prefixes = ""
for d in doctypes:
print d
try:
options = self.get_options(d)
except frappe.DoesNotExistError:
continue
prefixes = prefixes + "\n" + options
prefixes.replace("\n\n", "\n")
prefixes = "\n".join(sorted(prefixes.split()))
return {
"transactions": "\n".join([''] + sorted(list(set(
frappe.db.sql_list("""select parent
from `tabDocField` where fieldname='naming_series'""")
+ frappe.db.sql_list("""select dt from `tabCustom Field`
where fieldname='naming_series'""")
)))),
"prefixes": "\n".join([''] + [i[0] for i in
frappe.db.sql("""select name from tabSeries order by name""")])
"transactions": "\n".join([''] + sorted(doctypes)),
"prefixes": prefixes
}
def scrub_options_list(self, ol):
@ -110,8 +122,8 @@ class NamingSeries(Document):
if not re.match("^[a-zA-Z0-9- /.#]*$", n):
throw(_('Special Characters except "-" and "/" not allowed in naming series'))
def get_options(self, arg=''):
return frappe.get_meta(self.select_doc_for_series).get_field("naming_series").options
def get_options(self, arg=None):
return frappe.get_meta(arg or self.select_doc_for_series).get_field("naming_series").options
def get_current(self, arg=None):
"""get series current"""