From 7bd850a133871ab5bf778030d29dcb62209ed2a4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 20 Aug 2013 17:40:26 +0530 Subject: [PATCH] [patch] [minor] fix sle against cancelled stock entry for production --- .../production_order/production_order.py | 3 ++- .../p06_fix_sle_against_stock_entry.py | 23 +++++++++++++++++++ patches/patch_list.py | 1 + stock/doctype/stock_entry/stock_entry.js | 11 --------- 4 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 patches/august_2013/p06_fix_sle_against_stock_entry.py diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py index 6cdbc2f046a..6a133e78fa0 100644 --- a/manufacturing/doctype/production_order/production_order.py +++ b/manufacturing/doctype/production_order/production_order.py @@ -162,5 +162,6 @@ def make_stock_entry(production_order_id, purpose): else: stock_entry.doc.from_warehouse = production_order.doc.wip_warehouse stock_entry.doc.to_warehouse = production_order.doc.fg_warehouse - + + stock_entry.run_method("get_items") return [d.fields for d in stock_entry.doclist] diff --git a/patches/august_2013/p06_fix_sle_against_stock_entry.py b/patches/august_2013/p06_fix_sle_against_stock_entry.py new file mode 100644 index 00000000000..4413eeaa094 --- /dev/null +++ b/patches/august_2013/p06_fix_sle_against_stock_entry.py @@ -0,0 +1,23 @@ +import webnotes +def execute(): + from stock.stock_ledger import update_entries_after + + stock_entries = webnotes.conn.sql("""select name from `tabStock Entry` + where docstatus < 2 and modified >= '2013-08-15' + and ifnull(production_order, '') != '' and ifnull(bom_no, '') != ''""") + + for entry in stock_entries: + webnotes.conn.sql("""update `tabStock Ledger Entry` set is_cancelled = 'Yes' + where voucher_type = 'Stock Entry' and voucher_no = %s""", entry[0]) + + item_warehouse = webnotes.conn.sql("""select distinct item_code, warehouse + from `tabStock Ledger Entry` + where voucher_type = 'Stock Entry' and voucher_no = %s""", entry[0], as_dict=1) + + for d in item_warehouse: + update_entries_after({ + "item_code": d.item_code, + "warehouse": d.warehouse, + "posting_date": "2013-08-15", + "posting_date": "01:00" + }) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 41160aad67b..3dc6c76401b 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -256,4 +256,5 @@ patch_list = [ "patches.august_2013.p05_update_serial_no_status", "patches.august_2013.p05_employee_birthdays", "execute:webnotes.reload_doc('accounts', 'Print Format', 'POS Invoice') # 2013-08-16", + "patches.august_2013.p06_fix_sle_against_stock_entry", ] \ No newline at end of file diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js index 8843a35fe8f..e3690817267 100644 --- a/stock/doctype/stock_entry/stock_entry.js +++ b/stock/doctype/stock_entry/stock_entry.js @@ -103,12 +103,8 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }, callback: function(r) { if (!r.exc) me.frm.set_value("expense_adjustment_account", r.message); - - me.get_items_onload(); } }); - } else { - me.get_items_onload(); } }, @@ -121,13 +117,6 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ } }, - get_items_onload: function() { - if (this.frm.doc.__islocal && !getchildren('Stock Entry Detail', this.frm.doc.name, - 'mtn_details').length) { - this.get_items() - } - }, - get_items: function() { if(this.frm.doc.production_order || this.frm.doc.bom_no) { // if production order / bom is mentioned, get items