Merge pull request #2306 from nabinhait/stock_reco
Negative stock in perpetual inventory
This commit is contained in:
commit
50c29c7d0f
@ -14,9 +14,6 @@ class AccountsSettings(Document):
|
||||
frappe.db.set_default("auto_accounting_for_stock", self.auto_accounting_for_stock)
|
||||
|
||||
if cint(self.auto_accounting_for_stock):
|
||||
if cint(frappe.db.get_value("Stock Settings", None, "allow_negative_stock")):
|
||||
frappe.throw(_("Negative stock is not allowed in case of Perpetual Inventory, please disable it from Stock Settings"))
|
||||
|
||||
# set default perpetual account in company
|
||||
for company in frappe.db.sql("select name from tabCompany"):
|
||||
frappe.get_doc("Company", company[0]).save()
|
||||
|
@ -277,6 +277,9 @@ class BuyingController(StockController):
|
||||
"qty": -1 * required_qty,
|
||||
"serial_no": rm.serial_no
|
||||
})
|
||||
if not item_rate:
|
||||
from erpnext.controllers.stock_controller import get_valuation_rate
|
||||
item_rate = get_valuation_rate(bom_item.item_code, self.supplier_warehouse)
|
||||
rm.rate = item_rate or bom_item.rate
|
||||
else:
|
||||
rm.rate = bom_item.rate
|
||||
|
@ -30,7 +30,7 @@ class StockController(AccountsController):
|
||||
def get_gl_entries(self, warehouse_account=None, default_expense_account=None,
|
||||
default_cost_center=None, allow_negative_stock=False):
|
||||
|
||||
block_negative_stock(allow_negative_stock)
|
||||
# block_negative_stock(allow_negative_stock)
|
||||
|
||||
if not warehouse_account:
|
||||
warehouse_account = get_warehouse_account()
|
||||
@ -319,4 +319,7 @@ def get_valuation_rate(item_code, warehouse):
|
||||
if not valuation_rate:
|
||||
valuation_rate = frappe.db.get_value("Item Price", {"item_code": item_code, "buying": 1}, "price_list_rate")
|
||||
|
||||
if not valuation_rate:
|
||||
frappe.throw(_("Purchase rate for item: {0} not found, which is required to book accounting entry. Please mention item price against a buying price list.").format(item_code))
|
||||
|
||||
return valuation_rate
|
||||
|
@ -287,7 +287,7 @@ class PurchaseReceipt(BuyingController):
|
||||
from erpnext.accounts.general_ledger import process_gl_map
|
||||
from erpnext.controllers.stock_controller import block_negative_stock
|
||||
|
||||
block_negative_stock(allow_negative_stock)
|
||||
# block_negative_stock(allow_negative_stock)
|
||||
|
||||
stock_rbnb = self.get_company_default("stock_received_but_not_billed")
|
||||
expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
|
||||
|
@ -269,7 +269,7 @@ def get_moving_average_values(qty_after_transaction, sle, valuation_rate):
|
||||
elif not valuation_rate:
|
||||
valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse)
|
||||
|
||||
return abs(valuation_rate)
|
||||
return abs(flt(valuation_rate))
|
||||
|
||||
def get_fifo_values(qty_after_transaction, sle, stock_queue):
|
||||
incoming_rate = flt(sle.incoming_rate)
|
||||
|
Loading…
Reference in New Issue
Block a user