Try ERPNext Buy Support Partners Foundation Foundation Members

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.

Error:

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?

Sure:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/woocommerceconnector/woocommerceconnector/sync_orders.py", line 28, in sync_woocommerce_orders
	create_order(woocommerce_order, woocommerce_settings)
  File "/home/frappe/frappe-bench/apps/woocommerceconnector/woocommerceconnector/sync_orders.py", line 193, in create_order
	so = create_sales_order(woocommerce_order, woocommerce_settings, company)
  File "/home/frappe/frappe-bench/apps/woocommerceconnector/woocommerceconnector/sync_orders.py", line 247, in create_sales_order
	so.submit()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 857, in submit
	self._submit()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 846, in _submit
	self.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 271, in save
	return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 324, in _save
	self.run_post_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 920, in run_post_save_methods
	self.run_method("on_submit")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 786, in run_method
	out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1056, in composer
	return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1039, in runner
	add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", 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/sales_order.py", line 170, in on_submit
	self.check_credit_limit()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/selling/doctype/sales_order/sales_order.py", line 214, in check_credit_limit
	check_credit_limit(self.customer, self.company)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/selling/doctype/customer/customer.py", line 266, in check_credit_limit
	.format(" / " + credit_controller if credit_controller else ""))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 360, in throw
	msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 346, in msgprint
	_raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", 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