frappe.db.exist used

This commit is contained in:
Neil Trini Lasrado 2015-01-12 12:17:32 +05:30
parent adfdd6f83c
commit 50763d58ce
2 changed files with 14 additions and 5 deletions

View File

@ -443,8 +443,11 @@ class JournalEntry(AccountsController):
Pending Amount is {2}".format(d.idx, d.against_expense_claim, pending_amount)))
def validate_credit_debit_note(self):
count = frappe.db.sql("select count(stock_entry) as c from `tabJournal Entry` where \
stock_entry = %s and docstatus = 1", self.stock_entry, as_dict=1)[0].c
count = frappe.db.exists({
"doctype": "Journal Entry",
"stock_entry":self.stock_entry,
"docstatus":1
})
if count:
frappe.throw(_("{0} already made against stock entry {1}".format(self.voucher_type, self.stock_entry)))

View File

@ -35,9 +35,15 @@ class StockEntry(StockController):
item.update(get_available_qty(item.item_code,
item.s_warehouse))
count = frappe.db.sql("select count(stock_entry) as c from `tabJournal Entry` \
where stock_entry = %s and docstatus = 1",self.name, as_dict=1)[0].c
self.get("__onload").credit_debit_note_exists = count
count = frappe.db.exists({
"doctype": "Journal Entry",
"stock_entry":self.stock_entry,
"docstatus":1
})
if count:
self.get("__onload").credit_debit_note_exists = 1
else:
self.get("__onload").credit_debit_note_exists = 0
def validate(self):
self.validate_posting_time()