mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-06 15:00:27 +00:00
[minor] [fix] make sl entry
This commit is contained in:
@@ -412,18 +412,16 @@ class AccountsController(TransactionBase):
|
||||
return get_company_default(self.doc.company, fieldname)
|
||||
|
||||
|
||||
@property
|
||||
def stock_items(self):
|
||||
if not hasattr(self, "_stock_items"):
|
||||
self._stock_items = []
|
||||
item_codes = list(set(item.item_code for item in
|
||||
self.doclist.get({"parentfield": self.fname})))
|
||||
if item_codes:
|
||||
self._stock_items = [r[0] for r in webnotes.conn.sql("""select name
|
||||
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \
|
||||
(", ".join((["%s"]*len(item_codes))),), item_codes)]
|
||||
def get_stock_items(self):
|
||||
stock_items = []
|
||||
item_codes = list(set(item.item_code for item in
|
||||
self.doclist.get({"parentfield": self.fname})))
|
||||
if item_codes:
|
||||
stock_items = [r[0] for r in webnotes.conn.sql("""select name
|
||||
from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \
|
||||
(", ".join((["%s"]*len(item_codes))),), item_codes)]
|
||||
|
||||
return self._stock_items
|
||||
return stock_items
|
||||
|
||||
@property
|
||||
def company_abbr(self):
|
||||
|
||||
@@ -65,7 +65,7 @@ class BuyingController(StockController):
|
||||
raise_exception=WrongWarehouseCompany)
|
||||
|
||||
def validate_stock_or_nonstock_items(self):
|
||||
if not self.stock_items:
|
||||
if not self.get_stock_items():
|
||||
tax_for_valuation = [d.account_head for d in
|
||||
self.doclist.get({"parentfield": "purchase_tax_details"})
|
||||
if d.category in ["Valuation", "Valuation and Total"]]
|
||||
|
||||
@@ -113,13 +113,13 @@ class SellingController(StockController):
|
||||
item_sales_bom.setdefault(d.parent_item, []).append(new_d)
|
||||
|
||||
if stock_ledger_entries:
|
||||
stock_items = self.get_stock_items()
|
||||
for item in self.doclist.get({"parentfield": self.fname}):
|
||||
if item.item_code in self.stock_items or \
|
||||
if item.item_code in stock_items or \
|
||||
(item_sales_bom and item_sales_bom.get(item.item_code)):
|
||||
buying_amount = get_buying_amount(item.item_code, item.warehouse, -1*item.qty,
|
||||
self.doc.doctype, self.doc.name, item.name, stock_ledger_entries,
|
||||
item_sales_bom)
|
||||
|
||||
item.buying_amount = buying_amount >= 0.01 and buying_amount or 0
|
||||
webnotes.conn.set_value(item.doctype, item.name, "buying_amount",
|
||||
item.buying_amount)
|
||||
|
||||
Reference in New Issue
Block a user