fix(perpetual inventory): Get warehouse account map only if perpetual inventory enabled (#15743)

* fix(perpetual inventory): Get warehouse account map only if perpetual inventory enabled

* fix(perpetual inventory): Get warehouse account map only if perpetual inventory enabled
This commit is contained in:
Nabin Hait 2018-10-19 18:03:13 +05:30 committed by GitHub
parent b4cf72c770
commit 5d1171678e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -209,7 +209,8 @@ class PurchaseInvoice(BuyingController):
if self.update_stock:
self.validate_item_code()
self.validate_warehouse()
warehouse_account = get_warehouse_account_map()
if auto_accounting_for_stock:
warehouse_account = get_warehouse_account_map()
for item in self.get("items"):
# in case of auto inventory accounting,
@ -402,7 +403,8 @@ class PurchaseInvoice(BuyingController):
# item gl entries
stock_items = self.get_stock_items()
expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
warehouse_account = get_warehouse_account_map()
if self.update_stock and self.auto_accounting_for_stock:
warehouse_account = get_warehouse_account_map()
voucher_wise_stock_value = {}
if self.update_stock:

View File

@ -53,9 +53,9 @@ def get_warehouse_account(warehouse, warehouse_account=None):
if not account and warehouse.company:
account = get_company_default_inventory_account(warehouse.company)
if not account:
if not account and warehouse.company:
frappe.throw(_("Please set Account in Warehouse {0} or Default Inventory Account in Company {1}")
.format(warehouse, warehouse.company))
.format(warehouse.name, warehouse.company))
return account
def get_company_default_inventory_account(company):

View File

@ -22,10 +22,11 @@ class Warehouse(NestedSet):
def onload(self):
'''load account name for General Ledger Report'''
account = self.account or get_warehouse_account(self)
if self.company and cint(frappe.db.get_value("Company", self.company, "enable_perpetual_inventory")):
account = self.account or get_warehouse_account(self)
if account:
self.set_onload('account', account)
if account:
self.set_onload('account', account)
load_address_and_contact(self)