mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 13:09:17 +00:00
set is_cancelled=no when serial no deleted
This commit is contained in:
@@ -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]
|
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:
|
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)
|
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]])
|
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
|
# get first stock ledger entry
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class DocType(TransactionBase):
|
|||||||
# ------------------------
|
# ------------------------
|
||||||
# make stock ledger entry
|
# 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
|
from webnotes.model.code import get_obj
|
||||||
values = [{
|
values = [{
|
||||||
'item_code' : self.doc.item_code,
|
'item_code' : self.doc.item_code,
|
||||||
@@ -70,12 +70,12 @@ class DocType(TransactionBase):
|
|||||||
'voucher_type' : 'Serial No',
|
'voucher_type' : 'Serial No',
|
||||||
'voucher_no' : self.doc.name,
|
'voucher_no' : self.doc.name,
|
||||||
'voucher_detail_no' : '',
|
'voucher_detail_no' : '',
|
||||||
'actual_qty' : 1,
|
'actual_qty' : qty,
|
||||||
'stock_uom' : webnotes.conn.get_value('Item', self.doc.item_code, 'stock_uom'),
|
'stock_uom' : webnotes.conn.get_value('Item', self.doc.item_code, 'stock_uom'),
|
||||||
'incoming_rate' : self.doc.purchase_rate,
|
'incoming_rate' : self.doc.purchase_rate,
|
||||||
'company' : self.doc.company,
|
'company' : self.doc.company,
|
||||||
'fiscal_year' : self.doc.fiscal_year,
|
'fiscal_year' : self.doc.fiscal_year,
|
||||||
'is_cancelled' : update_stock and 'No' or 'Yes',
|
'is_cancelled' : 'No',
|
||||||
'batch_no' : '',
|
'batch_no' : '',
|
||||||
'serial_no' : self.doc.name
|
'serial_no' : self.doc.name
|
||||||
}]
|
}]
|
||||||
@@ -87,7 +87,7 @@ class DocType(TransactionBase):
|
|||||||
# ----------
|
# ----------
|
||||||
def on_update(self):
|
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)):
|
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)
|
msgprint("Cannot trash Serial No : %s as it is already Delivered" % (self.doc.name), raise_exception = 1)
|
||||||
else:
|
else:
|
||||||
webnotes.conn.set(self.doc, 'status', 'Not in Use')
|
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):
|
def on_cancel(self):
|
||||||
@@ -108,4 +108,4 @@ class DocType(TransactionBase):
|
|||||||
# on restore
|
# on restore
|
||||||
# -----------
|
# -----------
|
||||||
def on_restore(self):
|
def on_restore(self):
|
||||||
self.make_stock_ledger_entry(update_stock = 1)
|
self.make_stock_ledger_entry(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user