[fix] [minor] insert cancelled sl entry for serialized inventory and at the end delete

This commit is contained in:
Nabin Hait
2013-08-20 15:37:33 +05:30
parent c13c193bbc
commit 9653f60e89
8 changed files with 76 additions and 54 deletions

View File

@@ -75,6 +75,7 @@ class StockController(AccountsController):
"batch_no": cstr(d.batch_no).strip(),
"serial_no": d.serial_no,
"project": d.project_name,
"is_cancelled": self.doc.docstatus==2 and "Yes" or "No"
}
sl_dict.update(args)
@@ -84,29 +85,6 @@ class StockController(AccountsController):
from stock.stock_ledger import make_sl_entries
make_sl_entries(sl_entries, is_amended)
def delete_and_repost_sle(self):
""" Delete Stock Ledger Entries related to this voucher
and repost future Stock Ledger Entries"""
from stock.stock_ledger import update_entries_after
existing_entries = webnotes.conn.sql("""select distinct item_code, warehouse
from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s""",
(self.doc.doctype, self.doc.name), as_dict=1)
# delete entries
webnotes.conn.sql("""delete from `tabStock Ledger Entry`
where voucher_type=%s and voucher_no=%s""", (self.doc.doctype, self.doc.name))
# repost future entries for selected item_code, warehouse
for entries in existing_entries:
update_entries_after({
"item_code": entries.item_code,
"warehouse": entries.warehouse,
"posting_date": self.doc.posting_date,
"posting_time": self.doc.posting_time
})
def get_stock_ledger_entries(self, item_list=None, warehouse_list=None):
out = {}