[minor] [fix] make sl entry

This commit is contained in:
Nabin Hait
2013-08-02 14:50:12 +05:30
parent bbe1448fca
commit a36adbd1e0
10 changed files with 31 additions and 30 deletions

View File

@@ -295,7 +295,8 @@ class DocType(SellingController):
def update_stock_ledger(self):
sl_entries = []
for d in self.get_item_list():
if d.item_code in self.stock_items and d.warehouse:
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes" \
and d.warehouse:
if d['reserved_qty'] < 0 :
# Reduce reserved qty from reserved warehouse mentioned in so
args = {
@@ -312,7 +313,6 @@ class DocType(SellingController):
sl_entries.append(self.get_sl_entries(d, {
"actual_qty": -1*flt(d['qty']),
}))
self.make_sl_entries(sl_entries)
def get_item_list(self):
@@ -331,14 +331,13 @@ class DocType(SellingController):
def make_gl_entries(self):
if not cint(webnotes.defaults.get_global_default("auto_inventory_accounting")):
return
gl_entries = []
for item in self.doclist.get({"parentfield": "delivery_note_details"}):
self.check_expense_account(item)
if item.buying_amount:
gl_entries += self.get_gl_entries_for_stock(item.expense_account, -1*item.buying_amount,
cost_center=item.cost_center)
gl_entries += self.get_gl_entries_for_stock(item.expense_account,
-1*item.buying_amount, cost_center=item.cost_center)
if gl_entries:
from accounts.general_ledger import make_gl_entries

View File

@@ -173,8 +173,9 @@ class DocType(BuyingController):
def update_stock(self):
pc_obj = get_obj('Purchase Common')
sl_entries = []
stock_items = self.get_stock_items()
for d in getlist(self.doclist, 'purchase_receipt_details'):
if d.item_code in self.stock_items and d.warehouse:
if d.item_code in stock_items and d.warehouse:
ord_qty = 0
pr_qty = flt(d.qty) * flt(d.conversion_factor)
@@ -325,9 +326,9 @@ class DocType(BuyingController):
def get_total_valuation_amount(self):
total_valuation_amount = 0.0
stock_items = self.get_stock_items()
for item in self.doclist.get({"parentfield": "purchase_receipt_details"}):
if item.item_code in self.stock_items:
if item.item_code in stock_items:
total_valuation_amount += flt(item.valuation_rate) * \
flt(item.qty) * flt(item.conversion_factor)

View File

@@ -93,8 +93,9 @@ class DocType(StockController):
sl_obj.validate_serial_no(self, 'mtn_details')
def validate_item(self):
stock_items = self.get_stock_items()
for item in self.doclist.get({"parentfield": "mtn_details"}):
if item.item_code not in self.stock_items:
if item.item_code not in stock_items:
msgprint(_("""Only Stock Items are allowed for Stock Entry"""),
raise_exception=True)

View File

@@ -283,7 +283,6 @@ class TestStockEntry(unittest.TestCase):
from stock.doctype.delivery_note.delivery_note import make_sales_invoice
actual_qty_0 = self._get_actual_qty()
# make a delivery note based on this invoice
dn = webnotes.bean(copy=delivery_note_test_records[0])
dn.doclist[1].item_code = item_code