mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
[fix] [minor] insert cancelled sl entry for serialized inventory and at the end delete
This commit is contained in:
@@ -292,15 +292,11 @@ class DocType(SellingController):
|
||||
and d.warehouse:
|
||||
self.update_reserved_qty(d)
|
||||
|
||||
if self.doc.docstatus == 1:
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"actual_qty": -1*flt(d['qty']),
|
||||
}))
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"actual_qty": -1*flt(d['qty']),
|
||||
}))
|
||||
|
||||
if self.doc.docstatus == 1:
|
||||
self.make_sl_entries(sl_entries)
|
||||
else:
|
||||
self.delete_and_repost_sle()
|
||||
self.make_sl_entries(sl_entries)
|
||||
|
||||
def update_reserved_qty(self, d):
|
||||
if d['reserved_qty'] < 0 :
|
||||
|
||||
@@ -153,27 +153,23 @@ class DocType(BuyingController):
|
||||
pr_qty = flt(d.qty) * flt(d.conversion_factor)
|
||||
self.update_ordered_qty(pr_qty, d)
|
||||
|
||||
if self.doc.docstatus == 1:
|
||||
if pr_qty:
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"actual_qty": flt(pr_qty),
|
||||
"serial_no": cstr(d.serial_no).strip(),
|
||||
"incoming_rate": d.valuation_rate
|
||||
}))
|
||||
|
||||
if flt(d.rejected_qty) > 0:
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"warehouse": self.doc.rejected_warehouse,
|
||||
"actual_qty": flt(d.rejected_qty) * flt(d.conversion_factor),
|
||||
"serial_no": cstr(d.rejected_serial_no).strip(),
|
||||
"incoming_rate": d.valuation_rate
|
||||
}))
|
||||
if pr_qty:
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"actual_qty": flt(pr_qty),
|
||||
"serial_no": cstr(d.serial_no).strip(),
|
||||
"incoming_rate": d.valuation_rate
|
||||
}))
|
||||
|
||||
if flt(d.rejected_qty) > 0:
|
||||
sl_entries.append(self.get_sl_entries(d, {
|
||||
"warehouse": self.doc.rejected_warehouse,
|
||||
"actual_qty": flt(d.rejected_qty) * flt(d.conversion_factor),
|
||||
"serial_no": cstr(d.rejected_serial_no).strip(),
|
||||
"incoming_rate": d.valuation_rate
|
||||
}))
|
||||
|
||||
if self.doc.docstatus == 1:
|
||||
self.bk_flush_supp_wh(sl_entries)
|
||||
self.make_sl_entries(sl_entries)
|
||||
else:
|
||||
self.delete_and_repost_sle()
|
||||
self.bk_flush_supp_wh(sl_entries)
|
||||
self.make_sl_entries(sl_entries)
|
||||
|
||||
def update_ordered_qty(self, pr_qty, d):
|
||||
pc_obj = get_obj('Purchase Common')
|
||||
|
||||
@@ -56,7 +56,7 @@ class DocType(StockController):
|
||||
self.make_gl_entries()
|
||||
|
||||
def on_cancel(self):
|
||||
self.delete_and_repost_sle()
|
||||
self.update_stock_ledger()
|
||||
self.update_serial_no(0)
|
||||
self.update_production_order(0)
|
||||
self.make_cancel_gl_entries()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-01-29 19:25:42",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-08-20 11:56:25",
|
||||
"modified": "2013-08-20 15:02:48",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -272,6 +272,15 @@
|
||||
"search_index": 0,
|
||||
"width": "150px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "is_cancelled",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 1,
|
||||
"label": "Is Cancelled",
|
||||
"options": "\nNo\nYes",
|
||||
"report_hide": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
|
||||
@@ -252,6 +252,27 @@ class DocType(StockController):
|
||||
|
||||
# append to entries
|
||||
self.entries.append(args)
|
||||
|
||||
def delete_and_repost_sle(self):
|
||||
""" Delete Stock Ledger Entries related to this voucher
|
||||
and repost future Stock Ledger Entries"""
|
||||
|
||||
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 set_stock_value_difference(self):
|
||||
"""stock_value_difference is the increment in the stock value"""
|
||||
|
||||
Reference in New Issue
Block a user