notsql("select name from `tabStock Ledger Entry` where serial_no = %s and ifnull(is_cancelled, 'No') = 'No'",self.doc.name):
self.make_stock_ledger_entry(1)
webnotes.conn.set(self.doc,'sle_exists',1)
# ------------------------
# make stock ledger entry
# ------------------------
defmake_stock_ledger_entry(self,qty):
fromwebnotes.model.codeimportget_obj
values=[{
@ -91,21 +94,13 @@ class DocType(TransactionBase):
'incoming_rate':self.doc.purchase_rate,
'company':self.doc.company,
'fiscal_year':self.doc.fiscal_year,
'is_cancelled':'No',# is_cancelled is always 'No' because while deleted it can not find creation entry if it not created directly, voucher no != serial no.
'is_cancelled':'No',# is_cancelled is always 'No' because while deleted it can not find creation entry if it not created directly, voucher no != serial no
ifself.doc.localnameandself.doc.warehouseandself.doc.status=='In Store'andnotsql("select name from `tabStock Ledger Entry` where serial_no = '%s' and ifnull(is_cancelled, 'No') = 'No'"%(self.doc.name)):
batch_bal=flt(sql("select sum(actual_qty) from `tabStock Ledger Entry` where warehouse = '%s' and item_code = '%s' and batch_no = '%s'"%(self.doc.warehouse,self.doc.item_code,self.doc.batch_no))[0][0])
self.doc.fields.update({'batch_bal':batch_bal})
if(batch_bal+self.doc.actual_qty)<0:
msgprint("""Not enough quantity (requested: %(actual_qty)s, current: %(batch_bal)s in Batch