fix: handle duplicate acctount row for the same company

This commit is contained in:
Navin-S-R
2026-02-03 13:12:11 +05:30
parent 2c6054d51a
commit 7d14833856

View File

@@ -210,13 +210,16 @@ class TestAssetRepair(IntegrationTestCase):
self.assertRaises(frappe.ValidationError, asset_repair2.save) self.assertRaises(frappe.ValidationError, asset_repair2.save)
def test_gl_entries_with_perpetual_inventory(self): def test_gl_entries_with_perpetual_inventory(self):
set_depreciation_settings_in_company(company="_Test Company with perpetual inventory") company = "_Test Company with perpetual inventory"
set_depreciation_settings_in_company(company)
asset_category = frappe.get_doc("Asset Category", "Computers") asset_category = frappe.get_doc("Asset Category", "Computers")
if not any(row.company_name == company for row in asset_category.accounts):
asset_category.append( asset_category.append(
"accounts", "accounts",
{ {
"company_name": "_Test Company with perpetual inventory", "company_name": company,
"fixed_asset_account": "_Test Fixed Asset - TCP1", "fixed_asset_account": "_Test Fixed Asset - TCP1",
"accumulated_depreciation_account": "_Test Accumulated Depreciations - TCP1", "accumulated_depreciation_account": "_Test Accumulated Depreciations - TCP1",
"depreciation_expense_account": "_Test Depreciations - TCP1", "depreciation_expense_account": "_Test Depreciations - TCP1",
@@ -229,7 +232,7 @@ class TestAssetRepair(IntegrationTestCase):
capitalize_repair_cost=1, capitalize_repair_cost=1,
stock_consumption=1, stock_consumption=1,
warehouse="Stores - TCP1", warehouse="Stores - TCP1",
company="_Test Company with perpetual inventory", company=company,
pi_expense_account1="Administrative Expenses - TCP1", pi_expense_account1="Administrative Expenses - TCP1",
pi_expense_account2="Legal Expenses - TCP1", pi_expense_account2="Legal Expenses - TCP1",
item="_Test Non Stock Item", item="_Test Non Stock Item",