From fbed6a12d5797a4e07db37cc38556a8b7e180114 Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Fri, 3 May 2019 17:41:19 +0530 Subject: [PATCH] fix: calculate percentage only if sales team exist --- erpnext/selling/doctype/customer/customer.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 647e8be192..fd3d260c07 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -60,12 +60,13 @@ class Customer(TransactionBase): if self.loyalty_program == customer.loyalty_program and not self.loyalty_program_tier: self.loyalty_program_tier = customer.loyalty_program_tier - allocated_percentage = 0 - for percentage in self.sales_team: - allocated_percentage += percentage.allocated_percentage + if self.sales_team: + allocated_percentage = 0 + for percentage in self.sales_team: + allocated_percentage += percentage.allocated_percentage - if not allocated_percentage == 100: - frappe.throw(_("Total contribution percentage should be equal to 100")) + if not allocated_percentage == 100: + frappe.throw(_("Total contribution percentage should be equal to 100")) def check_customer_group_change(self): frappe.flags.customer_group_changed = False