removed unwanted import

This commit is contained in:
Nabin Hait 2013-01-21 14:12:36 +05:30
parent ec44cd763e
commit 30b142b563

View File

@ -17,12 +17,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import add_days, cint, cstr, flt, getdate, now from webnotes.utils import add_days, cint, cstr, flt
from webnotes.model import db_exists from webnotes.model.doc import addchild
from webnotes.model.doc import Document, addchild from webnotes.model.wrapper import getlist
from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj from webnotes.model.code import get_obj
from webnotes import form, msgprint, _ from webnotes import msgprint, _
sql = webnotes.conn.sql sql = webnotes.conn.sql
@ -405,60 +404,67 @@ class DocType(TransactionBase):
def validate_doc(self, obj, prevdoc_doctype, prevdoc_docname): def validate_doc(self, obj, prevdoc_doctype, prevdoc_docname):
if prevdoc_docname : if prevdoc_docname :
get_name = sql("select name from `tab%s` where name = '%s'" % (prevdoc_doctype, prevdoc_docname)) get_name = sql("select name from `tab%s` where name = '%s'" %
(prevdoc_doctype, prevdoc_docname))
name = get_name and get_name[0][0] or '' name = get_name and get_name[0][0] or ''
if name: #check for incorrect docname if name: #check for incorrect docname
dt = sql("select company, docstatus from `tab%s` where name = '%s'" % (prevdoc_doctype, name)) dt = sql("select company, docstatus from `tab%s` where name = '%s'" %
(prevdoc_doctype, name))
company_name = dt and cstr(dt[0][0]) or '' company_name = dt and cstr(dt[0][0]) or ''
docstatus = dt and dt[0][1] or 0 docstatus = dt and dt[0][1] or 0
# check for docstatus # check for docstatus
if (docstatus != 1): if (docstatus != 1):
msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) + " is not Submitted Document.") msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) +
" is not Submitted Document.")
raise Exception raise Exception
# check for company # check for company
if (company_name != obj.doc.company): if (company_name != obj.doc.company):
msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) + " does not belong to the Company: " + cstr(obj.doc.company)) msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) +
" does not belong to the Company: " + cstr(obj.doc.company))
raise Exception raise Exception
if prevdoc_doctype in ['Purchase Order', 'Purchase Receipt']: if prevdoc_doctype in ['Purchase Order', 'Purchase Receipt']:
dt = sql("select supplier, currency from `tab%s` where name = '%s'" % (prevdoc_doctype, name)) dt = sql("select supplier, currency from `tab%s` where name = '%s'" %
(prevdoc_doctype, name))
supplier = dt and dt[0][0] or '' supplier = dt and dt[0][0] or ''
currency = dt and dt[0][1] or '' currency = dt and dt[0][1] or ''
# check for supplier # check for supplier
if (supplier != obj.doc.supplier): if (supplier != obj.doc.supplier):
msgprint("Purchase Order: " + cstr(d.prevdoc_docname) + " supplier :" + cstr(supplier) + " does not match with supplier of current document.") msgprint("Purchase Order: " + cstr(prevdoc_docname) + " supplier :" +
cstr(supplier) + " does not match with supplier of current document.")
raise Exception raise Exception
# check for curency # check for curency
if (currency != obj.doc.currency): if (currency != obj.doc.currency):
msgprint("Purchase Order: " + cstr(d.prevdoc_docname) + " currency :" + cstr(currency) + " does not match with currency of current document.") msgprint("Purchase Order: " + cstr(prevdoc_docname) + " currency :" +
cstr(currency) + " does not match with currency of current document.")
raise Exception raise Exception
else: # if not name than else: # if not name than
msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) + " is not a valid " + cstr(prevdoc_doctype)) msgprint(cstr(prevdoc_doctype) + ": " + cstr(prevdoc_docname) +
" is not a valid " + cstr(prevdoc_doctype))
raise Exception raise Exception
# Validate values with reference document
#---------------------------------------
def validate_reference_value(self, obj): def validate_reference_value(self, obj):
ref_doc = [] ref_doc = []
for d in getlist(obj.doclist, obj.fname): for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname and d.prevdoc_doctype not in ref_doc: if d.prevdoc_doctype and d.prevdoc_docname and d.prevdoc_doctype not in ref_doc:
mapper_name = d.prevdoc_doctype + '-' + obj.doc.doctype mapper_name = d.prevdoc_doctype + '-' + obj.doc.doctype
get_obj('DocType Mapper', mapper_name, with_children = 1).validate_reference_value(obj, obj.doc.name) get_obj('DocType Mapper', mapper_name, with_children = 1).\
validate_reference_value(obj, obj.doc.name)
ref_doc.append(d.prevdoc_doctype) ref_doc.append(d.prevdoc_doctype)
# Check for Stopped status # Check for Stopped status
def check_for_stopped_status(self, doctype, docname): def check_for_stopped_status(self, doctype, docname):
stopped = sql("select name from `tab%s` where name = '%s' and status = 'Stopped'" % ( doctype, docname)) stopped = sql("select name from `tab%s` where name = '%s' and status = 'Stopped'" %
( doctype, docname))
if stopped: if stopped:
msgprint("One cannot do any transaction against %s : %s, it's status is 'Stopped'" % ( doctype, docname)) msgprint("One cannot do any transaction against %s : %s, it's status is 'Stopped'" %
raise Exception ( doctype, docname), raise_exception=1)
# Check Docstatus of Next DocType on Cancel AND of Previous DocType on Submit # Check Docstatus of Next DocType on Cancel AND of Previous DocType on Submit
def check_docstatus(self, check, doctype, docname , detail_doctype = ''): def check_docstatus(self, check, doctype, docname , detail_doctype = ''):
@ -631,9 +637,6 @@ class DocType(TransactionBase):
idx += 1 idx += 1
return obj.doclist return obj.doclist
# Get Tax rate if account type is TAX
# =========================================================================
def get_rate(self, arg, obj): def get_rate(self, arg, obj):
arg = eval(arg) arg = eval(arg)
rate = sql("select account_type, tax_rate from `tabAccount` where name = '%s'" %(arg['account_head']), as_dict=1) rate = sql("select account_type, tax_rate from `tabAccount` where name = '%s'" %(arg['account_head']), as_dict=1)
@ -644,18 +647,11 @@ class DocType(TransactionBase):
#msgprint(ret) #msgprint(ret)
return ret return ret
# Get total in words
# ==================================================================
def get_total_in_words(self, currency, amount): def get_total_in_words(self, currency, amount):
from webnotes.utils import money_in_words from webnotes.utils import money_in_words
return money_in_words(amount, currency) return money_in_words(amount, currency)
# get against document date
#-----------------------------
def get_prevdoc_date(self, obj): def get_prevdoc_date(self, obj):
import datetime
for d in getlist(obj.doclist, obj.fname): for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname: if d.prevdoc_doctype and d.prevdoc_docname:
dt = sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname)) dt = sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))