From 3f5afb9cac22a8399c2157bca32a1793f6b31e8b Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Wed, 19 Jul 2023 18:15:59 +0530 Subject: [PATCH] fix: reset dimension defaults when company changedin test --- .../purchase_invoice/test_purchase_invoice.py | 2 +- .../report/trial_balance/test_trial_balance.py | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 4180beff8a..d2f19a1b25 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -1750,7 +1750,7 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin): parent_account="Temporary Accounts - _TC", ) - create_accounting_dimension() + create_accounting_dimension(company="_Test Company", offsetting_account="Offsetting - _TC") branch1 = frappe.new_doc("Branch") branch1.branch = "Location 1" diff --git a/erpnext/accounts/report/trial_balance/test_trial_balance.py b/erpnext/accounts/report/trial_balance/test_trial_balance.py index 732035dc9f..cd0429be4c 100644 --- a/erpnext/accounts/report/trial_balance/test_trial_balance.py +++ b/erpnext/accounts/report/trial_balance/test_trial_balance.py @@ -84,14 +84,14 @@ def create_company(**args): def create_accounting_dimension(**args): args = frappe._dict(args) document_type = args.document_type or "Branch" - if not frappe.db.exists("Accounting Dimension", {"document_type": "Branch"}): - accounting_dimension = frappe.get_doc( - {"doctype": "Accounting Dimension", "document_type": document_type} - ).insert() - else: + if frappe.db.exists("Accounting Dimension", document_type): accounting_dimension = frappe.get_doc("Accounting Dimension", document_type) accounting_dimension.disabled = 0 - + else: + accounting_dimension = frappe.new_doc("Accounting Dimension") + accounting_dimension.document_type = document_type + accounting_dimension.insert() + accounting_dimension.save() accounting_dimension.append( "dimension_defaults", { @@ -101,7 +101,6 @@ def create_accounting_dimension(**args): }, ) accounting_dimension.save() - return accounting_dimension.name def disable_dimension(**args):