Merge with 3.3.8
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index de76bb9..be0b95f 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -73,6 +73,9 @@
self.update_current_stock()
self.validate_with_previous_doc()
+ from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
+ self.doclist = make_packing_list(self, 'delivery_note_details')
+
self.doc.status = 'Draft'
if not self.doc.installation_status: self.doc.installation_status = 'Not Installed'
@@ -142,10 +145,6 @@
bin = webnotes.conn.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
-
- def on_update(self):
- from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
- self.doclist = make_packing_list(self, 'delivery_note_details')
def on_submit(self):
self.validate_packed_qty()
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.txt b/erpnext/stock/doctype/delivery_note/delivery_note.txt
index 1dc3cd3..480d45d 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.txt
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:09",
"docstatus": 0,
- "modified": "2013-12-09 16:24:08",
+ "modified": "2013-12-14 17:26:12",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -1058,7 +1058,7 @@
},
{
"doctype": "DocPerm",
- "match": "customer_name",
+ "match": "customer",
"role": "Customer"
}
]
\ No newline at end of file
diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
index 7b6b0ad..4213d19 100644
--- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
@@ -58,11 +58,6 @@
self.assertEqual(stock_value, 0)
self.assertEqual(stock_value_difference, -375)
-
- gl_entries = webnotes.conn.sql("""select account, debit, credit
- from `tabGL Entry` where voucher_type='Delivery Note' and voucher_no=%s
- order by account desc""", dn.doc.name, as_dict=1)
-
self.assertFalse(get_gl_entries("Delivery Note", dn.doc.name))
def test_delivery_note_gl_entry(self):
@@ -111,8 +106,8 @@
gl_entries = get_gl_entries("Delivery Note", dn.doc.name)
self.assertTrue(gl_entries)
expected_values = {
- stock_in_hand_account: [0.0, 666.65],
- "Cost of Goods Sold - _TC": [666.65, 0.0]
+ stock_in_hand_account: [0.0, 666.67],
+ "Cost of Goods Sold - _TC": [666.67, 0.0]
}
for i, gle in enumerate(gl_entries):
self.assertEquals([gle.debit, gle.credit], expected_values.get(gle.account))
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 637d1cd..f9763cd 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import cstr, flt, cint
+from webnotes.utils import cstr, flt
from webnotes.model.doc import addchild
from webnotes.model.bean import getlist
from webnotes import msgprint, _
@@ -49,6 +49,7 @@
def on_update(self):
self.validate_name_with_item_group()
self.update_website()
+ self.update_item_price()
def check_warehouse_is_set_for_stock_item(self):
if self.doc.is_stock_item=="Yes" and not self.doc.default_warehouse:
@@ -112,40 +113,29 @@
self.doc.is_pro_applicable = "No"
if self.doc.is_pro_applicable == 'Yes' and self.doc.is_stock_item == 'No':
- msgprint("As Production Order can be made for this Item, then Is Stock Item Should be 'Yes' as we maintain it's stock. Refer Manufacturing and Inventory section.", raise_exception=1)
+ webnotes.throw(_("As Production Order can be made for this item, \
+ it must be a stock item."))
if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No':
msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1)
def check_for_active_boms(self):
- def _check_for_active_boms(field_label):
- if field_label in ['Is Active', 'Is Purchase Item']:
- bom_mat = webnotes.conn.sql("""select distinct t1.parent
- from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent
- and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1
- and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name)
- if bom_mat and bom_mat[0][0]:
- msgprint(_(field_label) + _(" should be 'Yes'. As Item: ") + self.doc.name +
- _(" is present in one or many Active BOMs"), raise_exception=1)
-
- if ((field_label == 'Allow Production Order'
- and self.doc.is_sub_contracted_item != 'Yes')
- or (field_label == 'Is Sub Contracted Item'
- and self.doc.is_manufactured_item != 'Yes')):
- bom = webnotes.conn.sql("""select name from `tabBOM` where item = %s
- and is_active = 1""", (self.doc.name,))
- if bom and bom[0][0]:
- msgprint(_(field_label) + _(" should be 'Yes'. As Item: ") + self.doc.name +
- _(" is present in one or many Active BOMs"), raise_exception=1)
-
- if not cint(self.doc.fields.get("__islocal")):
- fl = {'is_manufactured_item' :'Allow Bill of Materials',
- 'is_sub_contracted_item':'Is Sub Contracted Item',
- 'is_purchase_item' :'Is Purchase Item',
- 'is_pro_applicable' :'Allow Production Order'}
- for d in fl:
- if cstr(self.doc.fields.get(d)) != 'Yes':
- _check_for_active_boms(fl[d])
+ if self.doc.is_purchase_item != "Yes":
+ bom_mat = webnotes.conn.sql("""select distinct t1.parent
+ from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent
+ and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1
+ and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name)
+
+ if bom_mat and bom_mat[0][0]:
+ webnotes.throw(_("Item must be a purchase item, \
+ as it is present in one or many Active BOMs"))
+
+ if self.doc.is_manufactured_item != "Yes":
+ bom = webnotes.conn.sql("""select name from `tabBOM` where item = %s
+ and is_active = 1""", (self.doc.name,))
+ if bom and bom[0][0]:
+ webnotes.throw(_("""Allow Bill of Materials should be 'Yes'. Because one or many \
+ active BOMs present for this item"""))
def fill_customer_code(self):
""" Append all the customer codes and insert into "customer_code" field of item table """
@@ -215,6 +205,11 @@
WebsiteGenerator.on_update(self)
+ def update_item_price(self):
+ webnotes.conn.sql("""update `tabItem Price` set item_name=%s,
+ item_description=%s, modified=NOW() where item_code=%s""",
+ (self.doc.item_name, self.doc.description, self.doc.name))
+
def get_page_title(self):
if self.doc.name==self.doc.item_name:
page_name_from = self.doc.name
@@ -251,6 +246,9 @@
def before_rename(self, olddn, newdn, merge=False):
if merge:
# Validate properties before merging
+ if not webnotes.conn.exists("Item", newdn):
+ webnotes.throw(_("Item ") + newdn +_(" does not exists"))
+
field_list = ["stock_uom", "is_stock_item", "has_serial_no", "has_batch_no"]
new_properties = [cstr(d) for d in webnotes.conn.get_value("Item", newdn, field_list)]
if new_properties != [cstr(self.doc.fields[fld]) for fld in field_list]:
diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py
index 2f0fcb7..28ec508 100644
--- a/erpnext/stock/doctype/material_request/material_request.py
+++ b/erpnext/stock/doctype/material_request/material_request.py
@@ -37,20 +37,25 @@
for so_no in so_items.keys():
for item in so_items[so_no].keys():
- already_indented = webnotes.conn.sql("select sum(qty) from `tabMaterial Request Item` where item_code = '%s' and sales_order_no = '%s' and docstatus = 1 and parent != '%s'" % (item, so_no, self.doc.name))
+ already_indented = webnotes.conn.sql("""select sum(qty) from `tabMaterial Request Item`
+ where item_code = %s and sales_order_no = %s and
+ docstatus = 1 and parent != %s""", (item, so_no, self.doc.name))
already_indented = already_indented and flt(already_indented[0][0]) or 0
- actual_so_qty = webnotes.conn.sql("select sum(qty) from `tabSales Order Item` where parent = '%s' and item_code = '%s' and docstatus = 1 group by parent" % (so_no, item))
+ actual_so_qty = webnotes.conn.sql("""select sum(qty) from `tabSales Order Item`
+ where parent = %s and item_code = %s and docstatus = 1
+ group by parent""", (so_no, item))
actual_so_qty = actual_so_qty and flt(actual_so_qty[0][0]) or 0
- if flt(so_items[so_no][item]) + already_indented > actual_so_qty:
- msgprint("You can raise indent of maximum qty: %s for item: %s against sales order: %s\n Anyway, you can add more qty in new row for the same item." % (actual_so_qty - already_indented, item, so_no), raise_exception=1)
+ if actual_so_qty and (flt(so_items[so_no][item]) + already_indented > actual_so_qty):
+ webnotes.throw("You can raise indent of maximum qty: %s for item: %s against sales order: %s\
+ \n Anyway, you can add more qty in new row for the same item."
+ % (actual_so_qty - already_indented, item, so_no))
def validate_schedule_date(self):
for d in getlist(self.doclist, 'indent_details'):
if d.schedule_date < self.doc.transaction_date:
- msgprint("Expected Date cannot be before Material Request Date")
- raise Exception
+ webnotes.throw(_("Expected Date cannot be before Material Request Date"))
# Validate
# ---------------------
@@ -80,8 +85,8 @@
for d in getlist(self.doclist, 'indent_details'):
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes":
if not d.warehouse:
- msgprint("Please Enter Warehouse for Item %s as it is stock item"
- % cstr(d.item_code), raise_exception=1)
+ webnotes.throw("Please Enter Warehouse for Item %s as it is stock item"
+ % cstr(d.item_code))
qty =flt(d.qty)
if is_stopped:
@@ -96,16 +101,17 @@
update_bin(args)
def on_submit(self):
- webnotes.conn.set(self.doc,'status','Submitted')
+ webnotes.conn.set(self.doc, 'status', 'Submitted')
self.update_bin(is_submit = 1, is_stopped = 0)
def check_modified_date(self):
- mod_db = webnotes.conn.sql("select modified from `tabMaterial Request` where name = '%s'" % self.doc.name)
- date_diff = webnotes.conn.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
+ mod_db = webnotes.conn.sql("""select modified from `tabMaterial Request` where name = %s""",
+ self.doc.name)
+ date_diff = webnotes.conn.sql("""select TIMEDIFF('%s', '%s')"""
+ % (mod_db[0][0], cstr(self.doc.modified)))
if date_diff and date_diff[0][0]:
- msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ")
- raise Exception
+ webnotes.throw(cstr(self.doc.doctype) + " => " + cstr(self.doc.name) + " has been modified. Please Refresh.")
def update_status(self, status):
self.check_modified_date()
@@ -113,10 +119,10 @@
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
# Step 2:=> Set status
- webnotes.conn.set(self.doc,'status',cstr(status))
+ webnotes.conn.set(self.doc, 'status', cstr(status))
# Step 3:=> Acknowledge User
- msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)) )
+ msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)))
def on_cancel(self):
@@ -177,9 +183,9 @@
mr_doctype = webnotes.get_doctype("Material Request")
if mr_obj.doc.status in ["Stopped", "Cancelled"]:
- msgprint(_("Material Request") + ": %s, " % mr_obj.doc.name
+ webnotes.throw(_("Material Request") + ": %s, " % mr_obj.doc.name
+ _(mr_doctype.get_label("status")) + " = %s. " % _(mr_obj.doc.status)
- + _("Cannot continue."), raise_exception=webnotes.InvalidStatusError)
+ + _("Cannot continue."), exc=webnotes.InvalidStatusError)
_update_requested_qty(controller, mr_obj, mr_items)
diff --git a/erpnext/stock/doctype/material_request_item/material_request_item.txt b/erpnext/stock/doctype/material_request_item/material_request_item.txt
index 15884a3..e0b9330 100644
--- a/erpnext/stock/doctype/material_request_item/material_request_item.txt
+++ b/erpnext/stock/doctype/material_request_item/material_request_item.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-02-22 01:28:02",
"docstatus": 0,
- "modified": "2013-11-03 20:36:45",
+ "modified": "2013-12-18 14:52:02",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -219,7 +219,7 @@
"fieldname": "sales_order_no",
"fieldtype": "Link",
"label": "Sales Order No",
- "no_copy": 1,
+ "no_copy": 0,
"options": "Sales Order",
"print_hide": 1,
"read_only": 1
diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index a58444d..ba3cb30 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -56,9 +56,6 @@
pi.batch_no = cstr(line.batch_no)
pi.idx = packing_list_idx
- # saved, since this function is called on_update of delivery note
- pi.save()
-
packing_list_idx += 1
@@ -87,19 +84,13 @@
for d in obj.doclist.get({"parentfield": "packing_details"}):
if [d.parent_item, d.parent_detail_docname] not in parent_items:
# mark for deletion from doclist
- delete_list.append(d.name)
+ delete_list.append([d.parent_item, d.parent_detail_docname])
if not delete_list:
return obj.doclist
# delete from doclist
- obj.doclist = webnotes.doclist(filter(lambda d: d.name not in delete_list, obj.doclist))
-
- # delete from db
- webnotes.conn.sql("""\
- delete from `tabPacked Item`
- where name in (%s)"""
- % (", ".join(["%s"] * len(delete_list))),
- tuple(delete_list))
+ obj.doclist = webnotes.doclist(filter(lambda d: [d.parent_item, d.parent_detail_docname]
+ not in delete_list, obj.doclist))
return obj.doclist
\ No newline at end of file
diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py
index 226b9da..d0e5d2b 100644
--- a/erpnext/stock/doctype/price_list/price_list.py
+++ b/erpnext/stock/doctype/price_list/price_list.py
@@ -44,5 +44,5 @@
def update_item_price(self):
webnotes.conn.sql("""update `tabItem Price` set currency=%s,
- buying_or_selling=%s where price_list=%s""",
+ buying_or_selling=%s, modified=NOW() where price_list=%s""",
(self.doc.currency, self.doc.buying_or_selling, self.doc.name))
\ No newline at end of file
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
index 22ded6d..9a641c2 100755
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:10",
"docstatus": 0,
- "modified": "2013-11-02 19:41:45",
+ "modified": "2013-12-18 10:38:39",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -326,7 +326,7 @@
"fieldname": "schedule_date",
"fieldtype": "Date",
"label": "Required By",
- "no_copy": 1,
+ "no_copy": 0,
"oldfieldname": "schedule_date",
"oldfieldtype": "Date",
"print_hide": 1,
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index 1690cad..9c1da65 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -150,7 +150,7 @@
where serial_no like %s and item_code=%s and ifnull(is_cancelled, 'No')='No'
order by posting_date desc, posting_time desc, name desc""",
("%%%s%%" % self.doc.name, self.doc.item_code), as_dict=1):
- if self.doc.name in get_serial_nos(sle.serial_no):
+ if self.doc.name.upper() in get_serial_nos(sle.serial_no):
if sle.actual_qty > 0:
sle_dict.setdefault("incoming", []).append(sle)
else:
@@ -268,7 +268,8 @@
from tabItem where name=%s""", item_code, as_dict=True)[0]
def get_serial_nos(serial_no):
- return [s.strip() for s in cstr(serial_no).strip().replace(',', '\n').split('\n') if s.strip()]
+ return [s.strip() for s in cstr(serial_no).strip().upper().replace(',', '\n').split('\n')
+ if s.strip()]
def make_serial_no(serial_no, sle):
sr = webnotes.new_bean("Serial No")
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 1596039..ec46685 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -243,7 +243,7 @@
cur_frm.cscript.toggle_related_fields = function(doc) {
disable_from_warehouse = inList(["Material Receipt", "Sales Return"], doc.purpose);
- disable_to_warehouse = inList(["Material Issue", "Purchase Return"], doc.purpose)
+ disable_to_warehouse = inList(["Material Issue", "Purchase Return"], doc.purpose);
cur_frm.toggle_enable("from_warehouse", !disable_from_warehouse);
cur_frm.toggle_enable("to_warehouse", !disable_to_warehouse);
@@ -301,7 +301,7 @@
}
cur_frm.cscript.purpose = function(doc, cdt, cdn) {
- cur_frm.cscript.toggle_related_fields(doc, cdt, cdn);
+ cur_frm.cscript.toggle_related_fields(doc);
}
// Overloaded query for link batch_no
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 6001220..3ba0deb 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -285,9 +285,15 @@
# validate quantity <= ref item's qty - qty already returned
ref_item = ref.doclist.getone({"item_code": item.item_code})
returnable_qty = ref_item.qty - flt(already_returned_item_qty.get(item.item_code))
- self.validate_value("transfer_qty", "<=", returnable_qty, item,
- raise_exception=StockOverReturnError)
-
+ if not returnable_qty:
+ webnotes.throw("{item}: {item_code} {returned}".format(
+ item=_("Item"), item_code=item.item_code,
+ returned=_("already returned though some other documents")))
+ elif item.transfer_qty > returnable_qty:
+ webnotes.throw("{item}: {item_code}, {returned}: {qty}".format(
+ item=_("Item"), item_code=item.item_code,
+ returned=_("Max Returnable Qty"), qty=returnable_qty))
+
def get_already_returned_item_qty(self, ref_fieldname):
return dict(webnotes.conn.sql("""select item_code, sum(transfer_qty) as qty
from `tabStock Entry Detail` where parent in (
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index 2b7473c..7729b2e 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -20,6 +20,19 @@
if self.doc.email_id and not validate_email_add(self.doc.email_id):
msgprint("Please enter valid Email Id", raise_exception=1)
+ self.update_parent_account()
+
+ def update_parent_account(self):
+ if not self.doc.__islocal and (self.doc.create_account_under !=
+ webnotes.conn.get_value("Warehouse", self.doc.name, "create_account_under")):
+ warehouse_account = webnotes.conn.get_value("Account",
+ {"account_type": "Warehouse", "company": self.doc.company,
+ "master_name": self.doc.name}, ["name", "parent_account"])
+ if warehouse_account and warehouse_account[1] != self.doc.create_account_under:
+ acc_bean = webnotes.bean("Account", warehouse_account[0])
+ acc_bean.doc.parent_account = self.doc.create_account_under
+ acc_bean.save()
+
def on_update(self):
self.create_account_head()
@@ -84,6 +97,9 @@
new_warehouse = get_name_with_abbr(newdn, self.doc.company)
if merge:
+ if not webnotes.conn.exists("Warehouse", newdn):
+ webnotes.throw(_("Warehouse ") + newdn +_(" does not exists"))
+
if self.doc.company != webnotes.conn.get_value("Warehouse", new_warehouse, "company"):
webnotes.throw(_("Both Warehouse must belong to same Company"))
diff --git a/erpnext/stock/page/stock_home/stock_home.js b/erpnext/stock/page/stock_home/stock_home.js
index 4be5a46..3b6fd4c 100644
--- a/erpnext/stock/page/stock_home/stock_home.js
+++ b/erpnext/stock/page/stock_home/stock_home.js
@@ -138,7 +138,7 @@
items: [
{
"label":wn._("Stock Ledger"),
- doctype: "Delivery Note",
+ doctype: "Item",
route: "query-report/Stock Ledger"
},
{
@@ -146,12 +146,14 @@
page: "stock-balance"
},
{
- "page":"stock-level",
- "label": wn._("Stock Level")
+ "label":wn._("Stock Projected Qty"),
+ doctype: "Item",
+ route: "query-report/Stock Projected Qty"
},
{
- "page":"stock-ageing",
- "label": wn._("Stock Ageing")
+ "label":wn._("Stock Ageing"),
+ doctype: "Item",
+ route: "query-report/Stock Ageing"
},
]
},
diff --git a/erpnext/stock/report/item_prices/item_prices.py b/erpnext/stock/report/item_prices/item_prices.py
index 9a25c13..da8b500 100644
--- a/erpnext/stock/report/item_prices/item_prices.py
+++ b/erpnext/stock/report/item_prices/item_prices.py
@@ -15,8 +15,8 @@
bom_rate = get_item_bom_rate()
val_rate_map = get_valuation_rate()
- precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2
-
+ precision = get_currency_precision or 2
+
data = []
for item in sorted(item_map):
data.append([item, item_map[item]["item_name"],
@@ -30,6 +30,14 @@
])
return columns, data
+
+def get_currency_precision():
+ company_currency = webnotes.conn.get_value("Company",
+ webnotes.conn.get_default("company"), "default_currency")
+ currency_format = webnotes.conn.get_value("Currency", company_currency, "number_format")
+
+ from webnotes.utils import get_number_format_info
+ return get_number_format_info(currency_format)[2]
def get_columns(filters):
"""return columns based on filters"""
diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.py b/erpnext/stock/report/stock_ledger/stock_ledger.py
index ea1a60f..38308c2 100644
--- a/erpnext/stock/report/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/report/stock_ledger/stock_ledger.py
@@ -3,7 +3,6 @@
from __future__ import unicode_literals
import webnotes
-from webnotes import _
def execute(filters=None):
columns = get_columns()
@@ -13,10 +12,14 @@
data = []
for sle in sl_entries:
item_detail = item_details[sle.item_code]
+ voucher_link_icon = """<a href="%s"><i class="icon icon-share"
+ style="cursor: pointer;"></i></a>""" \
+ % ("/".join(["#Form", sle.voucher_type, sle.voucher_no]),)
+
data.append([sle.date, sle.item_code, item_detail.item_name, item_detail.item_group,
item_detail.brand, item_detail.description, sle.warehouse, item_detail.stock_uom,
sle.actual_qty, sle.qty_after_transaction, sle.stock_value, sle.voucher_type,
- sle.voucher_no, sle.batch_no, sle.serial_no, sle.company])
+ sle.voucher_no, voucher_link_icon, sle.batch_no, sle.serial_no, sle.company])
return columns, data
@@ -25,17 +28,10 @@
"Item Group:Link/Item Group:100", "Brand:Link/Brand:100",
"Description::200", "Warehouse:Link/Warehouse:100",
"Stock UOM:Link/UOM:100", "Qty:Float:50", "Balance Qty:Float:80",
- "Balance Value:Currency:100", "Voucher Type::100", "Voucher #::100",
+ "Balance Value:Currency:100", "Voucher Type::100", "Voucher #::100", "Link::30",
"Batch:Link/Batch:100", "Serial #:Link/Serial No:100", "Company:Link/Company:100"]
def get_stock_ledger_entries(filters):
- if not filters.get("company"):
- webnotes.throw(_("Company is mandatory"))
- if not filters.get("from_date"):
- webnotes.throw(_("From Date is mandatory"))
- if not filters.get("to_date"):
- webnotes.throw(_("To Date is mandatory"))
-
return webnotes.conn.sql("""select concat_ws(" ", posting_date, posting_time) as date,
item_code, warehouse, actual_qty, qty_after_transaction,
stock_value, voucher_type, voucher_no, batch_no, serial_no, company
@@ -66,6 +62,10 @@
def get_sle_conditions(filters):
conditions = []
+ item_conditions=get_item_conditions(filters)
+ if item_conditions:
+ conditions.append("""item_code in (select name from tabItem
+ {item_conditions})""".format(item_conditions=item_conditions))
if filters.get("warehouse"):
conditions.append("warehouse=%(warehouse)s")
if filters.get("voucher_no"):
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index e6a402c..860bb76 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -113,7 +113,14 @@
(qty_after_transaction * valuation_rate) or 0
else:
stock_value = sum((flt(batch[0]) * flt(batch[1]) for batch in stock_queue))
-
+
+ # rounding as per precision
+ from webnotes.model.meta import get_field_precision
+ meta = webnotes.get_doctype("Stock Ledger Entry")
+
+ stock_value = flt(stock_value, get_field_precision(meta.get_field("stock_value"),
+ webnotes._dict({"fields": sle})))
+
stock_value_difference = stock_value - prev_stock_value
prev_stock_value = stock_value