[cleanup] [minor] deprecated cancelled stock ledger entry
diff --git a/controllers/stock_controller.py b/controllers/stock_controller.py
index c578005..2bf635b 100644
--- a/controllers/stock_controller.py
+++ b/controllers/stock_controller.py
@@ -72,7 +72,6 @@
"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 @@
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 @@
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 0000000..abb9d68
--- /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 b91ef81..d508aa3 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 @@
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 6fea593..430cc61 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -258,4 +258,5 @@
"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 4efc6de..84f956e 100644
--- a/selling/doctype/sales_common/sales_common.py
+++ b/selling/doctype/sales_common/sales_common.py
@@ -336,7 +336,6 @@
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 0f6d4fe..e619619 100644
--- a/startup/report_data_map.py
+++ b/startup/report_data_map.py
@@ -81,7 +81,6 @@
"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 146191f..788642f 100644
--- a/stock/doctype/bin/bin.py
+++ b/stock/doctype/bin/bin.py
@@ -65,7 +65,6 @@
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 9ae1bfd..74d15f3 100644
--- a/stock/doctype/item/item.py
+++ b/stock/doctype/item/item.py
@@ -194,7 +194,7 @@
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 @@
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 34f7646..0818db5 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"
},
@@ -318,18 +318,6 @@
},
{
"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",
"fieldtype": "Column Break",
"read_only": 0,
@@ -469,13 +457,6 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
- "role": "System Manager",
- "write": 1
- },
- {
- "cancel": 1,
- "create": 1,
- "doctype": "DocPerm",
"role": "Material Master Manager",
"write": 1
},
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index 98ee7ad..c3b9a15 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -228,7 +228,7 @@
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 @@
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 5b65e97..cee1d0e 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"
},
@@ -273,20 +273,6 @@
"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,
"create": 0,
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 67b7a2b..6bbfe8b 100644
--- a/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -244,7 +244,6 @@
"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 @@
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 29feb65..bed314c 100644
--- a/stock/doctype/warehouse/warehouse.py
+++ b/stock/doctype/warehouse/warehouse.py
@@ -146,8 +146,7 @@
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 e198b8e..db0c240 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 @@
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 34df640..a40be1d 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 4d42c22..a1f7d44 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 @@
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 f80e4db..457a066 100644
--- a/stock/stock_ledger.py
+++ b/stock/stock_ledger.py
@@ -145,7 +145,6 @@
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""" % {