From ac2b5ed84f4cfcaf7f7fef059ae03d53dcd608e5 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 5 Sep 2019 16:57:26 +0530 Subject: [PATCH] fix: credit limit patch --- .../move_credit_limit_to_customer_credit_limit.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 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 30acfe68ea..3bcdb8fc7f 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 @@ -21,10 +21,10 @@ def move_credit_limit_to_child_table(): if frappe.db.has_column('Customer', 'bypass_credit_limit_check_at_sales_order'): fields = ", bypass_credit_limit_check_at_sales_order" - credit_limit_record = frappe.db.sql(''' SELECT - name, credit_limit - {0} - FROM `tabCustomer`'''.format(fields), as_dict=1) #nosec + credit_limit_record = frappe.db.sql(''' + SELECT name, credit_limit {0} + FROM `tabCustomer` where credit_limit > 0 + '''.format(fields), as_dict=1) #nosec companies = frappe.get_all("Company", 'name') @@ -36,4 +36,5 @@ def move_credit_limit_to_child_table(): 'bypass_credit_limit_check': record.bypass_credit_limit_check_at_sales_order, 'company': company.name }) - customer.db_insert() + for row in customer.credit_limit_reference: + row.db_insert()