From 4ae729bfd287c052348d6279c01ec37a1f2e9e09 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 20 Aug 2013 12:04:46 +0530 Subject: [PATCH] [cleanup] [minor] deprecated cancelled stock ledger entry --- controllers/stock_controller.py | 7 ++----- .../p06_deprecate_cancelled_sl_entry.py | 8 +++++++ .../packing_list_cleanup_and_serial_no.py | 2 +- patches/patch_list.py | 1 + selling/doctype/sales_common/sales_common.py | 1 - startup/report_data_map.py | 1 - stock/doctype/bin/bin.py | 1 - stock/doctype/item/item.py | 4 +--- stock/doctype/serial_no/serial_no.txt | 21 +------------------ stock/doctype/stock_entry/stock_entry.py | 3 +-- .../stock_ledger_entry/stock_ledger_entry.txt | 16 +------------- .../stock_reconciliation.py | 4 +--- stock/doctype/warehouse/warehouse.py | 3 +-- .../batch_wise_balance_history.py | 2 +- stock/report/stock_ledger/stock_ledger.txt | 4 ++-- .../warehouse_wise_stock_balance.py | 2 +- stock/stock_ledger.py | 1 - 17 files changed, 22 insertions(+), 59 deletions(-) create mode 100644 patches/august_2013/p06_deprecate_cancelled_sl_entry.py diff --git a/controllers/stock_controller.py b/controllers/stock_controller.py index c578005e82..2bf635ba06 100644 --- a/controllers/stock_controller.py +++ b/controllers/stock_controller.py @@ -72,7 +72,6 @@ class StockController(AccountsController): "incoming_rate": 0, "company": self.doc.company, "fiscal_year": self.doc.fiscal_year, - "is_cancelled": self.doc.docstatus==2 and "Yes" or "No", "batch_no": cstr(d.batch_no).strip(), "serial_no": d.serial_no, "project": d.project_name, @@ -116,8 +115,7 @@ class StockController(AccountsController): res = webnotes.conn.sql("""select item_code, voucher_type, voucher_no, voucher_detail_no, posting_date, posting_time, stock_value, warehouse, actual_qty as qty from `tabStock Ledger Entry` - where ifnull(`is_cancelled`, "No") = "No" and company = %s - and item_code in (%s) and warehouse in (%s) + where company = %s and item_code in (%s) and warehouse in (%s) order by item_code desc, warehouse desc, posting_date desc, posting_time desc, name desc""" % ('%s', ', '.join(['%s']*len(item_list)), ', '.join(['%s']*len(warehouse_list))), @@ -143,6 +141,5 @@ class StockController(AccountsController): def make_cancel_gl_entries(self): if webnotes.conn.sql("""select name from `tabGL Entry` where voucher_type=%s - and voucher_no=%s and ifnull(is_cancelled, 'No')='No'""", - (self.doc.doctype, self.doc.name)): + and voucher_no=%s""", (self.doc.doctype, self.doc.name)): self.make_gl_entries() \ No newline at end of file diff --git a/patches/august_2013/p06_deprecate_cancelled_sl_entry.py b/patches/august_2013/p06_deprecate_cancelled_sl_entry.py new file mode 100644 index 0000000000..abb9d6839e --- /dev/null +++ b/patches/august_2013/p06_deprecate_cancelled_sl_entry.py @@ -0,0 +1,8 @@ +import webnotes +def execute(): + webnotes.reload_doc("stock", "doctype", "stock_ledger_entry") + webnotes.reload_doc("stock", "doctype", "serial_no") + webnotes.reload_doc("stock", "report", "stock_ledger") + + webnotes.conn.sql("""delete from `tabStock Ledger Entry` + where ifnull(is_cancelled, 'No') = 'Yes'""") \ No newline at end of file diff --git a/patches/july_2012/packing_list_cleanup_and_serial_no.py b/patches/july_2012/packing_list_cleanup_and_serial_no.py index b91ef810f1..d508aa3e67 100644 --- a/patches/july_2012/packing_list_cleanup_and_serial_no.py +++ b/patches/july_2012/packing_list_cleanup_and_serial_no.py @@ -37,7 +37,7 @@ def execute(): limit 1 """% (s, s, s, s, d['parent']), as_dict=1) - status = 'Not in Use' + status = 'Not Available' if sle and flt(sle[0]['actual_qty']) > 0: status = 'Available' elif sle and flt(sle[0]['actual_qty']) < 0: diff --git a/patches/patch_list.py b/patches/patch_list.py index 6fea593d86..430cc61e35 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -258,4 +258,5 @@ patch_list = [ "patches.august_2013.p05_employee_birthdays", "execute:webnotes.reload_doc('accounts', 'Print Format', 'POS Invoice') # 2013-08-16", "execute:webnotes.delete_doc('DocType', 'Stock Ledger')", + "patches.august_2013.p06_deprecate_cancelled_sl_entry", ] \ No newline at end of file diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py index 4efc6ded82..84f956ec7a 100644 --- a/selling/doctype/sales_common/sales_common.py +++ b/selling/doctype/sales_common/sales_common.py @@ -336,7 +336,6 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters): return webnotes.conn.sql("""select batch_no from `tabStock Ledger Entry` sle where item_code = '%(item_code)s' and warehouse = '%(warehouse)s' - and ifnull(is_cancelled, 'No') = 'No' and batch_no like '%(txt)s' and exists(select * from `tabBatch` where name = sle.batch_no diff --git a/startup/report_data_map.py b/startup/report_data_map.py index 0f6d4fe194..e619619c3f 100644 --- a/startup/report_data_map.py +++ b/startup/report_data_map.py @@ -81,7 +81,6 @@ data_map = { "columns": ["name", "posting_date", "posting_time", "item_code", "warehouse", "actual_qty as qty", "voucher_type", "voucher_no", "project", "ifnull(incoming_rate,0) as incoming_rate", "stock_uom", "serial_no"], - "conditions": ["ifnull(is_cancelled, 'No')='No'"], "order_by": "posting_date, posting_time, name", "links": { "item_code": ["Item", "name"], diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py index 146191f9b1..788642fe4f 100644 --- a/stock/doctype/bin/bin.py +++ b/stock/doctype/bin/bin.py @@ -65,7 +65,6 @@ class DocType: select * from `tabStock Ledger Entry` where item_code = %s and warehouse = %s - and ifnull(is_cancelled, 'No') = 'No' order by timestamp(posting_date, posting_time) asc, name asc limit 1 """, (self.doc.item_code, self.doc.warehouse), as_dict=1) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index 9ae1bfd83c..74d15f3d46 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -194,7 +194,7 @@ class DocType(DocListController): def check_if_sle_exists(self): sle = webnotes.conn.sql("""select name from `tabStock Ledger Entry` - where item_code = %s and ifnull(is_cancelled, 'No') = 'No'""", self.doc.name) + where item_code = %s""", self.doc.name) return sle and 'exists' or 'not exists' def validate_name_with_item_group(self): @@ -255,8 +255,6 @@ class DocType(DocListController): def on_trash(self): webnotes.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code) - webnotes.conn.sql("""delete from `tabStock Ledger Entry` - where item_code=%s and is_cancelled='Yes' """, self.doc.item_code) if self.doc.page_name: from webnotes.webutils import clear_cache diff --git a/stock/doctype/serial_no/serial_no.txt b/stock/doctype/serial_no/serial_no.txt index 34f7646cbe..0818db5289 100644 --- a/stock/doctype/serial_no/serial_no.txt +++ b/stock/doctype/serial_no/serial_no.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-16 10:59:15", "docstatus": 0, - "modified": "2013-08-16 10:16:00", + "modified": "2013-08-20 11:52:13", "modified_by": "Administrator", "owner": "Administrator" }, @@ -316,18 +316,6 @@ "no_copy": 1, "read_only": 1 }, - { - "doctype": "DocField", - "fieldname": "is_cancelled", - "fieldtype": "Select", - "hidden": 1, - "label": "Is Cancelled", - "oldfieldname": "is_cancelled", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "read_only": 0, - "report_hide": 1 - }, { "doctype": "DocField", "fieldname": "column_break5", @@ -465,13 +453,6 @@ "reqd": 1, "search_index": 1 }, - { - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "role": "System Manager", - "write": 1 - }, { "cancel": 1, "create": 1, diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index 98ee7ad78d..c3b9a15d41 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -228,7 +228,7 @@ class DocType(StockController): sle = webnotes.conn.sql("""select name, posting_date, posting_time, actual_qty, stock_value, warehouse from `tabStock Ledger Entry` where voucher_type = %s and voucher_no = %s and - item_code = %s and ifnull(is_cancelled, 'No') = 'No' limit 1""", + item_code = %s limit 1""", ((self.doc.delivery_note_no and "Delivery Note" or "Sales Invoice"), self.doc.delivery_note_no or self.doc.sales_invoice_no, args.item_code), as_dict=1) if sle: @@ -770,7 +770,6 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters): from `tabStock Ledger Entry` sle where item_code = '%(item_code)s' and warehouse = '%(s_warehouse)s' - and ifnull(is_cancelled, 'No') = 'No' and batch_no like '%(txt)s' and exists(select * from `tabBatch` where name = sle.batch_no diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt b/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt index 5b65e973d4..cee1d0e796 100644 --- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt +++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-29 19:25:42", "docstatus": 0, - "modified": "2013-07-25 16:39:10", + "modified": "2013-08-20 11:56:25", "modified_by": "Administrator", "owner": "Administrator" }, @@ -272,20 +272,6 @@ "search_index": 0, "width": "150px" }, - { - "doctype": "DocField", - "fieldname": "is_cancelled", - "fieldtype": "Select", - "in_filter": 1, - "label": "Is Cancelled", - "oldfieldname": "is_cancelled", - "oldfieldtype": "Select", - "options": "\nYes\nNo", - "print_width": "100px", - "read_only": 1, - "search_index": 0, - "width": "100px" - }, { "amend": 0, "cancel": 0, diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py index 67b7a2bf24..6bbfe8b679 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -244,7 +244,6 @@ class DocType(StockController): "voucher_type": self.doc.doctype, "voucher_no": self.doc.name, "company": self.doc.company, - "is_cancelled": "No", "voucher_detail_no": row.voucher_detail_no, "fiscal_year": self.doc.fiscal_year, }) @@ -305,8 +304,7 @@ class DocType(StockController): if not self.doc.expense_account: msgprint(_("Please enter Expense Account"), raise_exception=1) - elif not webnotes.conn.sql("""select * from `tabStock Ledger Entry` - where ifnull(is_cancelled, 'No') = 'No'"""): + elif not webnotes.conn.sql("""select * from `tabStock Ledger Entry`"""): if webnotes.conn.get_value("Account", self.doc.expense_account, "is_pl_account") == "Yes": msgprint(_("""Expense Account can not be a PL Account, as this stock \ diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py index 29feb651d5..bed314c63a 100644 --- a/stock/doctype/warehouse/warehouse.py +++ b/stock/doctype/warehouse/warehouse.py @@ -146,8 +146,7 @@ class DocType: sql("delete from `tabBin` where name = %s", d['name']) # delete cancelled sle - if sql("""select name from `tabStock Ledger Entry` - where warehouse = %s and ifnull('is_cancelled', '') = 'No'""", self.doc.name): + if sql("""select name from `tabStock Ledger Entry` where warehouse = %s""", self.doc.name): msgprint("""Warehosue can not be deleted as stock ledger entry exists for this warehouse.""", raise_exception=1) else: diff --git a/stock/report/batch_wise_balance_history/batch_wise_balance_history.py b/stock/report/batch_wise_balance_history/batch_wise_balance_history.py index e198b8ee47..db0c24057f 100644 --- a/stock/report/batch_wise_balance_history/batch_wise_balance_history.py +++ b/stock/report/batch_wise_balance_history/batch_wise_balance_history.py @@ -52,7 +52,7 @@ def get_stock_ledger_entries(filters): return webnotes.conn.sql("""select item_code, batch_no, warehouse, posting_date, actual_qty from `tabStock Ledger Entry` - where ifnull(is_cancelled, 'No') = 'No' %s order by item_code, warehouse""" % + where docstatus < 2 %s order by item_code, warehouse""" % conditions, as_dict=1) def get_item_warehouse_batch_map(filters): diff --git a/stock/report/stock_ledger/stock_ledger.txt b/stock/report/stock_ledger/stock_ledger.txt index 34df640f91..a40be1de23 100644 --- a/stock/report/stock_ledger/stock_ledger.txt +++ b/stock/report/stock_ledger/stock_ledger.txt @@ -2,14 +2,14 @@ { "creation": "2013-01-14 15:26:21", "docstatus": 0, - "modified": "2013-02-22 15:53:01", + "modified": "2013-08-20 11:53:43", "modified_by": "Administrator", "owner": "Administrator" }, { "doctype": "Report", "is_standard": "Yes", - "json": "{\"filters\":[[\"Stock Ledger Entry\",\"is_cancelled\",\"=\",\"No\"]],\"columns\":[[\"item_code\",\"Stock Ledger Entry\"],[\"warehouse\",\"Stock Ledger Entry\"],[\"posting_date\",\"Stock Ledger Entry\"],[\"posting_time\",\"Stock Ledger Entry\"],[\"actual_qty\",\"Stock Ledger Entry\"],[\"qty_after_transaction\",\"Stock Ledger Entry\"],[\"voucher_type\",\"Stock Ledger Entry\"],[\"voucher_no\",\"Stock Ledger Entry\"]],\"sort_by\":\"Stock Ledger Entry.posting_date\",\"sort_order\":\"desc\",\"sort_by_next\":\"Stock Ledger Entry.posting_time\",\"sort_order_next\":\"desc\"}", + "json": "{\"filters\":[],\"columns\":[[\"item_code\",\"Stock Ledger Entry\"],[\"warehouse\",\"Stock Ledger Entry\"],[\"posting_date\",\"Stock Ledger Entry\"],[\"posting_time\",\"Stock Ledger Entry\"],[\"actual_qty\",\"Stock Ledger Entry\"],[\"qty_after_transaction\",\"Stock Ledger Entry\"],[\"voucher_type\",\"Stock Ledger Entry\"],[\"voucher_no\",\"Stock Ledger Entry\"]],\"sort_by\":\"Stock Ledger Entry.posting_date\",\"sort_order\":\"desc\",\"sort_by_next\":\"Stock Ledger Entry.posting_time\",\"sort_order_next\":\"desc\"}", "name": "__common__", "ref_doctype": "Stock Ledger Entry", "report_name": "Stock Ledger", diff --git a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py index 4d42c229f2..a1f7d446f3 100644 --- a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py +++ b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py @@ -52,7 +52,7 @@ def get_stock_ledger_entries(filters): return webnotes.conn.sql("""select item_code, warehouse, posting_date, actual_qty, company from `tabStock Ledger Entry` - where ifnull(is_cancelled, 'No') = 'No' %s order by item_code, warehouse""" % + where docstatus < 2 %s order by item_code, warehouse""" % conditions, as_dict=1) def get_item_warehouse_map(filters): diff --git a/stock/stock_ledger.py b/stock/stock_ledger.py index f80e4db5d5..457a0661f2 100644 --- a/stock/stock_ledger.py +++ b/stock/stock_ledger.py @@ -145,7 +145,6 @@ def get_stock_ledger_entries(args, conditions=None, order="desc", limit=None, fo return webnotes.conn.sql("""select * from `tabStock Ledger Entry` where item_code = %%(item_code)s and warehouse = %%(warehouse)s - and ifnull(is_cancelled, 'No') = 'No' %(conditions)s order by timestamp(posting_date, posting_time) %(order)s, name %(order)s %(limit)s %(for_update)s""" % {