From cf901da25d2e17657c1ad21823eb6a6e900b653e Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Mon, 2 Sep 2019 23:18:36 +0530 Subject: [PATCH] test: create customer credit limit on change --- .../v12_0/move_credit_limit_to_customer_credit_limit.py | 2 +- erpnext/selling/doctype/customer/test_customer.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/patches/v12_0/move_credit_limit_to_customer_credit_limit.py b/erpnext/patches/v12_0/move_credit_limit_to_customer_credit_limit.py index 6f59b46ee7..ca01c604dd 100644 --- a/erpnext/patches/v12_0/move_credit_limit_to_customer_credit_limit.py +++ b/erpnext/patches/v12_0/move_credit_limit_to_customer_credit_limit.py @@ -29,7 +29,7 @@ def move_credit_limit_to_child_table(): companies = frappe.get_all("Company", 'name') for record in credit_limit_record: - customer = frappe.get_doc("Customer", customer.name) + customer = frappe.get_doc("Customer", record.name) for company in companies: customer.append("credit_limit_reference", { 'credit_limit': record.credit_limit, diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index e5771b2359..35d1b2cf1c 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -252,7 +252,10 @@ class TestCustomer(unittest.TestCase): def test_customer_credit_limit_on_change(self): outstanding_amt = self.get_customer_outstanding_amount() customer = frappe.get_doc("Customer", '_Test Customer') - customer.credit_limit_reference[0].credit_limit = flt(outstanding_amt - 100) + customer.append('credit_limit_reference', {'credit_limit': flt(outstanding_amt - 100), 'company': '_Test Company'}) + + ''' define new credit limit for same company ''' + customer.append('credit_limit_reference', {'credit_limit': flt(outstanding_amt - 100), 'company': '_Test Company'}) self.assertRaises(frappe.ValidationError, customer.save) def test_customer_payment_terms(self):