diff --git a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py index 57fc9ffea2e..4e1c2b82985 100644 --- a/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py +++ b/erpnext/accounts/doctype/pos_invoice/test_pos_invoice.py @@ -1002,9 +1002,10 @@ class TestPOSInvoice(ERPNextTestSuite): se.cancel() def test_ignore_pricing_rule(self): + frappe.set_user("Administrator") from erpnext.accounts.doctype.pricing_rule.test_pricing_rule import make_pricing_rule - item_price = frappe.get_doc( + item_price = self.truncate_make_item_price( { "doctype": "Item Price", "item_code": "_Test Item", @@ -1012,7 +1013,7 @@ class TestPOSInvoice(ERPNextTestSuite): "price_list_rate": "450", } ) - item_price.insert() + pr = make_pricing_rule(selling=1, priority=5, discount_percentage=10) pr.save() diff --git a/erpnext/tests/utils.py b/erpnext/tests/utils.py index ee54d027251..fb204c87dca 100644 --- a/erpnext/tests/utils.py +++ b/erpnext/tests/utils.py @@ -145,6 +145,13 @@ class ERPNextTestSuite(unittest.TestCase): records = load_test_records_for(doctype) cls.globalTestRecords[doctype] = records[doctype] + @classmethod + def truncate_make_item_price(cls, record): + frappe.db.truncate("Item Price") + item_price = frappe.get_doc(record) + item_price.insert() + return item_price + @classmethod def make_presets(cls): from frappe.desk.page.setup_wizard.install_fixtures import update_genders, update_salutations