From e3bb247868e749dde3e601f6879c550a3611740d Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Sat, 31 Aug 2019 13:16:14 +0530 Subject: [PATCH] fix: check column in credit limit --- .../v12_0/move_credit_limit_to_customer_credit_limit.py | 9 ++++++--- erpnext/selling/doctype/customer/customer.py | 2 +- 2 files changed, 7 insertions(+), 4 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 344dd82958..58ad337b34 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 @@ -17,10 +17,13 @@ def execute(): def move_credit_limit_to_child_table(): ''' maps data from old field to the new field in the child table ''' + if not frappe.db.has_column('Customer', 'bypass_credit_limit_check_at_sales_order'): + fields = ", bypass_credit_limit_check_at_sales_order" + credit_limit_data = frappe.db.sql(''' SELECT - name, credit_limit, - bypass_credit_limit_check_at_sales_order - FROM `tabCustomer`''', as_dict=1) + name, credit_limit + {0} + FROM `tabCustomer`'''.format(fields), as_dict=1) #nosec companies = frappe.get_all("Company", 'name') diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 0ecb41e98c..3d5fee9423 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -330,7 +330,7 @@ def get_credit_limit(customer, company): credit_limit = frappe.db.get_value("Customer Credit Limit", {'parent': customer, 'company': company}, 'credit_limit') if not credit_limit: - customer_group = frappe.db.get_value("Customer", customer, 'credit_group') + customer_group = frappe.db.get_value("Customer", customer, 'customer_group') credit_limit = frappe.get_cached_value("Customer Group", customer_group, "credit_limit") if not credit_limit: