Skip to content

Commit

Permalink
fix: get stock accounts from the doc instead of db in validate_stock_…
Browse files Browse the repository at this point in the history
…accounts

(cherry picked from commit 3095458)
  • Loading branch information
vishakhdesai authored and mergify[bot] committed Oct 22, 2024
1 parent 29fe23b commit 39387e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion erpnext/accounts/doctype/journal_entry/journal_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def validate_depr_entry_voucher_type(self):
frappe.throw(_("Journal Entry type should be set as Depreciation Entry for asset depreciation"))

def validate_stock_accounts(self):
stock_accounts = get_stock_accounts(self.company, self.doctype, self.name)
stock_accounts = get_stock_accounts(self.company, accounts=self.accounts)
for account in stock_accounts:
account_bal, stock_bal, warehouse_list = get_stock_and_account_balance(
account, self.posting_date, self.company
Expand Down
8 changes: 6 additions & 2 deletions erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,12 +1547,16 @@ def compare_existing_and_expected_gle(existing_gle, expected_gle, precision):
return matched


def get_stock_accounts(company, voucher_type=None, voucher_no=None):
def get_stock_accounts(company, voucher_type=None, voucher_no=None, accounts=None):
stock_accounts = [
d.name
for d in frappe.db.get_all("Account", {"account_type": "Stock", "company": company, "is_group": 0})
]
if voucher_type and voucher_no:

if accounts:
stock_accounts = [row.account for row in accounts if row.account in stock_accounts]

elif voucher_type and voucher_no:
if voucher_type == "Journal Entry":
stock_accounts = [
d.account
Expand Down

0 comments on commit 39387e9

Please sign in to comment.