Error in JV amending after upgrade to V. 5

After upgrading to V.5, amending a journal voucher brings the following error;

Traceback (innermost last):
File “/home/user/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 18, in savedocs
doc.save()
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 238, in save
self.run_post_save_methods()
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 563, in run_post_save_methods
self.run_method(“on_submit”)
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 508, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 621, in composer
return composed(self, method, *args, **kwargs)
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 604, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 502, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/user/frappe-bench/apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py”, line 45, in on_submit
self.check_credit_limit()
File “/home/user/frappe-bench/apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py”, line 88, in check_credit_limit
check_credit_limit(customer, self.company)
File “/home/user/frappe-bench/apps/erpnext/erpnext/selling/doctype/customer/customer.py”, line 157, in check_credit_limit
credit_limit = get_credit_limit(customer, company)
File “/home/user/frappe-bench/apps/erpnext/erpnext/selling/doctype/customer/customer.py”, line 211, in get_credit_limit
credit_limit, customer_group = frappe.db.get_value(“Customer”, customer, [“credit_limit”, “customer_group”])
TypeError: ‘NoneType’ object is not iterable

Traceback (innermost last):
File “/home/user/frappe-bench/apps/frappe/frappe/app.py”, line 51, in application
response = frappe.handler.handle()
File “/home/user/frappe-bench/apps/frappe/frappe/handler.py”, line 66, in handle
execute_cmd(cmd)
File “/home/user/frappe-bench/apps/frappe/frappe/handler.py”, line 89, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/user/frappe-bench/apps/frappe/frappe/init.py”, line 741, in call
return fn(*args, **newargs)
File “/home/user/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 18, in savedocs
doc.save()
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 238, in save
self.run_post_save_methods()
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 563, in run_post_save_methods
self.run_method(“on_submit”)
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 508, in run_method
return Document.hook(fn)(self, *args, **kwargs)
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 621, in composer
return composed(self, method, *args, **kwargs)
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 604, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 502, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/user/frappe-bench/apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py”, line 45, in on_submit
self.check_credit_limit()
File “/home/user/frappe-bench/apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py”, line 88, in check_credit_limit
check_credit_limit(customer, self.company)
File “/home/user/frappe-bench/apps/erpnext/erpnext/selling/doctype/customer/customer.py”, line 157, in check_credit_limit
credit_limit = get_credit_limit(customer, company)
File “/home/user/frappe-bench/apps/erpnext/erpnext/selling/doctype/customer/customer.py”, line 211, in get_credit_limit
credit_limit, customer_group = frappe.db.get_value(“Customer”, customer, [“credit_limit”, “customer_group”])
TypeError: ‘NoneType’ object is not iterable

IN v5, individual account for customer/supplier has been deleted, and in JV and Gl Entry, customer and supplier are directly linked. But somehow in your case, customer and supplier are not migrated properly. Check whether the customer and supplier account are still exists in your system.

You can study the following code to understand the migration.
https://github.com/frappe/erpnext/blob/develop/erpnext/patches/v4_2/party_model.py

Thanks @nabinhait your explanation makes sense…I could not find an explicit reason from the code why the customer JV entries were erroneous but in 2 scenarios I managed to fix the problem;

  1. Running bench update again seemed to solve the error.
  2. I restored a backup copy and fixed the JV entries and then I upgraded to V.5