From 86dec8da7af2702a28d1a7a305841537ee8ca743 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 16 May 2012 12:20:21 +0530 Subject: [PATCH] naming series issue fixed in pos settings --- .../doctype/pos_setting/pos_setting.py | 30 ++++++++++--------- .../purchase_common/purchase_common.js | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.py b/erpnext/accounts/doctype/pos_setting/pos_setting.py index 43742ac840..6c1988223a 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.py +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.py @@ -34,18 +34,20 @@ convert_to_lists = webnotes.conn.convert_to_lists class DocType: - def __init__(self,doc,doclist=[]): - self.doc, self.doclist = doc,doclist + def __init__(self,doc,doclist=[]): + self.doc, self.doclist = doc,doclist - #--------------------get naming series from sales invoice----------------- - def get_series(self): - res = sql("select options from `tabDocField` where parent='Sales Invoice' and fieldname = 'naming_series'") - return res and cstr(res[0][0]) or '' - - def validate(self): - res = sql("select name, user from `tabPOS Setting` where ifnull(user, '') = '%s' and name != '%s' and company = '%s'" % (self.doc.user, self.doc.name, self.doc.company)) - if res: - if res[0][1]: - msgprint("POS Setting '%s' already created for user: '%s' and company: '%s'"%(res[0][0], res[0][1], self.doc.company), raise_exception=1) - else: - msgprint("Global POS Setting already created - %s for this company: '%s'" % (res[0][0], self.doc.company), raise_exception=1) + #--------------------get naming series from sales invoice----------------- + def get_series(self): + import webnotes.model.doctype + docfield = webnotes.model.doctype.get('Sales Invoice') + series = [d.options for d in docfield if d.doctype == 'DocField' and d.fieldname == 'naming_series'] + return series and series[0] or '' + + def validate(self): + res = sql("select name, user from `tabPOS Setting` where ifnull(user, '') = '%s' and name != '%s' and company = '%s'" % (self.doc.user, self.doc.name, self.doc.company)) + if res: + if res[0][1]: + msgprint("POS Setting '%s' already created for user: '%s' and company: '%s'"%(res[0][0], res[0][1], self.doc.company), raise_exception=1) + else: + msgprint("Global POS Setting already created - %s for this company: '%s'" % (res[0][0], self.doc.company), raise_exception=1) diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index a8948ffa1b..3ec6977352 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -268,7 +268,7 @@ cur_frm.cscript.import_ref_rate = function(doc, cdt, cdn) { var is_item_table = function(doc,cdt,cdn) { // Step 1 :=>Get all childrens/ rows from Detail Table var cl = getchildren(tname, doc.name, fname); - // Step 2 :=> If there are no rows then set validated = false, I hope this will stop further execution of code. + // Step 2 :=> If there are no rows then set validated = false, this will stop further execution of code. if (cl.length == 0) { alert("There is no item in table"); validated = false; }