fix: duplicate acc dimension in test
This commit is contained in:
parent
77deac4fb9
commit
b3f6d991b5
@ -1738,6 +1738,10 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin):
|
|||||||
|
|
||||||
def test_offsetting_entries_for_accounting_dimensions(self):
|
def test_offsetting_entries_for_accounting_dimensions(self):
|
||||||
from erpnext.accounts.doctype.account.test_account import create_account
|
from erpnext.accounts.doctype.account.test_account import create_account
|
||||||
|
from erpnext.accounts.report.trial_balance.test_trial_balance import (
|
||||||
|
clear_dimension_defaults,
|
||||||
|
create_accounting_dimension,
|
||||||
|
)
|
||||||
|
|
||||||
create_account(
|
create_account(
|
||||||
account_name="Offsetting",
|
account_name="Offsetting",
|
||||||
@ -1745,18 +1749,7 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin):
|
|||||||
parent_account="Temporary Accounts - _TC",
|
parent_account="Temporary Accounts - _TC",
|
||||||
)
|
)
|
||||||
|
|
||||||
clear_dimension_defaults("Branch")
|
create_accounting_dimension()
|
||||||
accounting_dimension = frappe.get_doc("Accounting Dimension", "Branch")
|
|
||||||
accounting_dimension.disabled = 0
|
|
||||||
accounting_dimension.append(
|
|
||||||
"dimension_defaults",
|
|
||||||
{
|
|
||||||
"company": "_Test Company",
|
|
||||||
"automatically_post_balancing_accounting_entry": 1,
|
|
||||||
"offsetting_account": "Offsetting - _TC",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
accounting_dimension.save()
|
|
||||||
|
|
||||||
branch1 = frappe.new_doc("Branch")
|
branch1 = frappe.new_doc("Branch")
|
||||||
branch1.branch = "Location 1"
|
branch1.branch = "Location 1"
|
||||||
@ -1797,12 +1790,6 @@ class TestPurchaseInvoice(unittest.TestCase, StockTestMixin):
|
|||||||
clear_dimension_defaults("Branch")
|
clear_dimension_defaults("Branch")
|
||||||
|
|
||||||
|
|
||||||
def clear_dimension_defaults(dimension_name):
|
|
||||||
accounting_dimension = frappe.get_doc("Accounting Dimension", dimension_name)
|
|
||||||
accounting_dimension.dimension_defaults = []
|
|
||||||
accounting_dimension.save()
|
|
||||||
|
|
||||||
|
|
||||||
def set_advance_flag(company, flag, default_account):
|
def set_advance_flag(company, flag, default_account):
|
||||||
frappe.db.set_value(
|
frappe.db.set_value(
|
||||||
"Company",
|
"Company",
|
||||||
|
|||||||
@ -39,10 +39,10 @@ class TestTrialBalance(FrappeTestCase):
|
|||||||
|
|
||||||
branch1 = frappe.new_doc("Branch")
|
branch1 = frappe.new_doc("Branch")
|
||||||
branch1.branch = "Location 1"
|
branch1.branch = "Location 1"
|
||||||
branch1.insert()
|
branch1.insert(ignore_if_duplicate=True)
|
||||||
branch2 = frappe.new_doc("Branch")
|
branch2 = frappe.new_doc("Branch")
|
||||||
branch2.branch = "Location 2"
|
branch2.branch = "Location 2"
|
||||||
branch2.insert()
|
branch2.insert(ignore_if_duplicate=True)
|
||||||
|
|
||||||
si = create_sales_invoice(
|
si = create_sales_invoice(
|
||||||
company=self.company,
|
company=self.company,
|
||||||
@ -91,6 +91,8 @@ def create_accounting_dimension(**args):
|
|||||||
accounting_dimension = frappe.get_doc("Accounting Dimension", document_type)
|
accounting_dimension = frappe.get_doc("Accounting Dimension", document_type)
|
||||||
accounting_dimension.disabled = 0
|
accounting_dimension.disabled = 0
|
||||||
|
|
||||||
|
clear_dimension_defaults(document_type)
|
||||||
|
accounting_dimension.load_from_db()
|
||||||
accounting_dimension.append(
|
accounting_dimension.append(
|
||||||
"dimension_defaults",
|
"dimension_defaults",
|
||||||
{
|
{
|
||||||
@ -109,3 +111,9 @@ def disable_dimension(**args):
|
|||||||
dimension = frappe.get_doc("Accounting Dimension", document_type)
|
dimension = frappe.get_doc("Accounting Dimension", document_type)
|
||||||
dimension.disabled = 1
|
dimension.disabled = 1
|
||||||
dimension.save()
|
dimension.save()
|
||||||
|
|
||||||
|
|
||||||
|
def clear_dimension_defaults(dimension_name):
|
||||||
|
accounting_dimension = frappe.get_doc("Accounting Dimension", dimension_name)
|
||||||
|
accounting_dimension.dimension_defaults = []
|
||||||
|
accounting_dimension.save()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user