[cleanup] [minor] deprecated cancelled stock ledger entry
This commit is contained in:
parent
05652874fc
commit
4ae729bfd2
@ -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()
|
8
patches/august_2013/p06_deprecate_cancelled_sl_entry.py
Normal file
8
patches/august_2013/p06_deprecate_cancelled_sl_entry.py
Normal file
@ -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'""")
|
@ -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:
|
||||
|
@ -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",
|
||||
]
|
@ -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
|
||||
|
@ -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"],
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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 \
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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",
|
||||
|
@ -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):
|
||||
|
@ -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""" % {
|
||||
|
Loading…
x
Reference in New Issue
Block a user