From 982763cbfad8820f2b3373a76e342ebb129e91fa Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 26 Aug 2011 18:53:27 +0530 Subject: [PATCH] set is_cancelled=no when serial no deleted --- stock/doctype/bin/bin.py | 2 +- stock/doctype/serial_no/serial_no.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py index fc51d76829..cd2fa28049 100644 --- a/stock/doctype/bin/bin.py +++ b/stock/doctype/bin/bin.py @@ -61,8 +61,8 @@ class DocType: sr_count = sql("select count(name) from `tabSerial No` where item_code = '%s' and warehouse = '%s' and status ='In Store' and docstatus != 2" % (self.doc.item_code, self.doc.warehouse))[0][0] if sr_count != self.doc.actual_qty: msg = "Actual Qty(%s) in Bin is mismatched with total number(%s) of serial no in store for item: '%s' and warehouse: '%s'" % (self.doc.actual_qty, sr_count, self.doc.item_code, self.doc.warehouse) - msgprint(msg, raise_exception=1) sendmail(['developer@iwebnotes.com'], sender='automail@webnotestech.com', subject='Serial No Count vs Bin Actual Qty', parts=[['text/plain', msg]]) + msgprint(msg, raise_exception=1) # -------------------------------- # get first stock ledger entry diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py index cf7fd50607..02ce0f804e 100644 --- a/stock/doctype/serial_no/serial_no.py +++ b/stock/doctype/serial_no/serial_no.py @@ -59,7 +59,7 @@ class DocType(TransactionBase): # ------------------------ # make stock ledger entry # ------------------------ - def make_stock_ledger_entry(self, update_stock): + def make_stock_ledger_entry(self, qty): from webnotes.model.code import get_obj values = [{ 'item_code' : self.doc.item_code, @@ -70,12 +70,12 @@ class DocType(TransactionBase): 'voucher_type' : 'Serial No', 'voucher_no' : self.doc.name, 'voucher_detail_no' : '', - 'actual_qty' : 1, + 'actual_qty' : qty, 'stock_uom' : webnotes.conn.get_value('Item', self.doc.item_code, 'stock_uom'), 'incoming_rate' : self.doc.purchase_rate, 'company' : self.doc.company, 'fiscal_year' : self.doc.fiscal_year, - 'is_cancelled' : update_stock and 'No' or 'Yes', + 'is_cancelled' : 'No', 'batch_no' : '', 'serial_no' : self.doc.name }] @@ -87,7 +87,7 @@ class DocType(TransactionBase): # ---------- def on_update(self): if self.doc.localname and self.doc.warehouse and self.doc.status == 'In Store' and not sql("select name from `tabStock Ledger Entry` where serial_no = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (self.doc.name)): - self.make_stock_ledger_entry(update_stock = 1) + self.make_stock_ledger_entry(1) # --------- @@ -98,7 +98,7 @@ class DocType(TransactionBase): msgprint("Cannot trash Serial No : %s as it is already Delivered" % (self.doc.name), raise_exception = 1) else: webnotes.conn.set(self.doc, 'status', 'Not in Use') - self.make_stock_ledger_entry(update_stock = 0) + self.make_stock_ledger_entry(-1) def on_cancel(self): @@ -108,4 +108,4 @@ class DocType(TransactionBase): # on restore # ----------- def on_restore(self): - self.make_stock_ledger_entry(update_stock = 1) + self.make_stock_ledger_entry(1)