diff --git a/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py b/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py index a79109bcd2b..64adce9ec15 100644 --- a/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py +++ b/erpnext/accounts/doctype/loyalty_program/test_loyalty_program.py @@ -80,6 +80,7 @@ class TestLoyaltyProgram(unittest.TestCase): si_original = create_sales_invoice_record() si_original.insert() si_original.submit() + customer.reload() earned_points = get_points_earned(si_original) @@ -102,8 +103,8 @@ class TestLoyaltyProgram(unittest.TestCase): si_redeem.loyalty_points = earned_points si_redeem.insert() si_redeem.submit() + customer.reload() - customer = frappe.get_doc("Customer", {"customer_name": "Test Loyalty Customer"}) earned_after_redemption = get_points_earned(si_redeem) lpe_redeem = frappe.get_doc( diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 978c1ad021c..6e8f1b2bbf2 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1776,7 +1776,8 @@ class SalesInvoice(SellingController): loyalty_program=self.loyalty_program, include_expired_entry=True, ) - frappe.db.set_value("Customer", self.customer, "loyalty_program_tier", lp_details.tier_name) + customer = frappe.get_doc("Customer", self.customer) + customer.db_set("loyalty_program_tier", lp_details.tier_name) def get_returned_amount(self): from frappe.query_builder.functions import Sum