mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-02 08:03:21 +00:00
naming series changes now saved as property setter
This commit is contained in:
@@ -34,14 +34,6 @@ class DocType:
|
||||
def get_transactions(self):
|
||||
return "\n".join([''] + [i[0] for i in sql("SELECT `tabDocField`.`parent` FROM `tabDocField`, `tabDocType` WHERE `tabDocField`.`fieldname` = 'naming_series' and `tabDocType`.name=`tabDocField`.parent order by `tabDocField`.parent")])
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
def get_options_for(self, doctype):
|
||||
sr = webnotes.model.doctype.get_property(doctype, 'naming_series')
|
||||
if sr:
|
||||
return sr.split("\n")
|
||||
else:
|
||||
return []
|
||||
|
||||
def scrub_options_list(self, ol):
|
||||
options = filter(lambda x: x, [cstr(n.upper()).strip() for n in ol])
|
||||
return options
|
||||
@@ -60,6 +52,7 @@ class DocType:
|
||||
default = options[0]
|
||||
|
||||
# update in property setter
|
||||
from webnotes.model.doc import Document
|
||||
prop_dict = {'options': "\n".join(options), 'default': default}
|
||||
for prop in prop_dict:
|
||||
ps_exists = webnotes.conn.sql("""SELECT name FROM `tabProperty Setter`
|
||||
@@ -82,6 +75,9 @@ class DocType:
|
||||
ps.save(1)
|
||||
|
||||
self.doc.set_options = "\n".join(options)
|
||||
|
||||
from webnotes.utils.cache import CacheItem
|
||||
CacheItem(doctype).clear()
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
def update_series(self):
|
||||
@@ -95,7 +91,7 @@ class DocType:
|
||||
dt = DocType()
|
||||
|
||||
parent = sql("select parent from `tabDocField` where fieldname='naming_series' and parent != %s", self.doc.select_doc_for_series)
|
||||
sr = ([p[0], webnotes.model.doctype.get_property(p[0], 'naming_series')] for p in parent)
|
||||
sr = ([webnotes.model.doctype.get_property(p[0], 'options', 'naming_series'), p[0]] for p in parent)
|
||||
options = self.scrub_options_list(self.doc.set_options.split("\n"))
|
||||
for series in options:
|
||||
dt.validate_series(series, self.doc.select_doc_for_series)
|
||||
@@ -113,9 +109,8 @@ class DocType:
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
def get_options(self, arg=''):
|
||||
so = sql("select options from `tabDocField` where parent=%s and fieldname='naming_series'", self.doc.select_doc_for_series)
|
||||
if so:
|
||||
return so[0][0] or ''
|
||||
sr = webnotes.model.doctype.get_property(self.doc.select_doc_for_series, 'options', 'naming_series')
|
||||
return sr
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user