Customer Group Credit Limit has strange values after patch

When updating ERPNext from v10 to v12, there is a patch that moves the credit limit (move_credit_limit_to_customer_credit_limit). However, if no credit limit was used, this will actually apply random values between 0,1 and 1 to the customer group credit limit.

We have a case where orders are placed through the API, which is after the upgrade then always failing due to this strange initial/patch value.


frappe.exceptions.ValidationError: Please contact to the user who have Sales Master Manager  role

For anyone who has a similar issue with credit limits:

  • check credit limit on customer
  • check credit limit on customer group
  • check credit limit on company

Hope this helps someone.

1 Like

Thanks for this report - could you possibly post the full traceback?


Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/woocommerceconnector/woocommerceconnector/", line 28, in sync_woocommerce_orders
	create_order(woocommerce_order, woocommerce_settings)
  File "/home/frappe/frappe-bench/apps/woocommerceconnector/woocommerceconnector/", line 193, in create_order
	so = create_sales_order(woocommerce_order, woocommerce_settings, company)
  File "/home/frappe/frappe-bench/apps/woocommerceconnector/woocommerceconnector/", line 247, in create_sales_order
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 857, in submit
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 846, in _submit
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 271, in save
	return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 324, in _save
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 920, in run_post_save_methods
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 786, in run_method
	out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 1056, in composer
	return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 1039, in runner
	add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 780, in <lambda>
	fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/selling/doctype/sales_order/", line 170, in on_submit
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/selling/doctype/sales_order/", line 214, in check_credit_limit
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/selling/doctype/customer/", line 266, in check_credit_limit
	.format(" / " + credit_controller if credit_controller else ""))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 360, in throw
	msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 346, in msgprint
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 315, in _raise_exception
	raise raise_exception(msg)
frappe.exceptions.ValidationError: Please contact to the user who have Sales Master Manager  role

Problematic credit limit values:

The patch has a history of updates in September that relate to Customer and Company and to bypass the credit limit check…

My question is, with each migrate, whether the Patch Log decides to rerun patch updates again, or maybe a new patch is needed to fix a problem patch?

Probably the best recourse is to fix the code to set a zero value or check for null, or revise the error message and so on.

As far as I understand a patch is added to the “tabPatch Log” once it has been successfully completed. Therefore, changing the patch will only affect system that are upgraded later. We are manually correcting this issue in affected systems. Adding another patch might not be too elegant.

In general, a credit limit < 1 is probably in no case correct. We apply this as a feasibility check, but then correct to customer specific values (i.e. value from Company credit_limit).

In most cases, this will not be observed as the sales order is entered by a Sales Manager role, which overrides this behaviour…

1 Like