fix: calculate percentage only if sales team exist

This commit is contained in:
Himanshu Warekar 2019-05-03 17:41:19 +05:30 committed by Nabin Hait
parent 40b99e3347
commit fbed6a12d5

View File

@ -60,12 +60,13 @@ class Customer(TransactionBase):
if self.loyalty_program == customer.loyalty_program and not self.loyalty_program_tier: if self.loyalty_program == customer.loyalty_program and not self.loyalty_program_tier:
self.loyalty_program_tier = customer.loyalty_program_tier self.loyalty_program_tier = customer.loyalty_program_tier
allocated_percentage = 0 if self.sales_team:
for percentage in self.sales_team: allocated_percentage = 0
allocated_percentage += percentage.allocated_percentage for percentage in self.sales_team:
allocated_percentage += percentage.allocated_percentage
if not allocated_percentage == 100: if not allocated_percentage == 100:
frappe.throw(_("Total contribution percentage should be equal to 100")) frappe.throw(_("Total contribution percentage should be equal to 100"))
def check_customer_group_change(self): def check_customer_group_change(self):
frappe.flags.customer_group_changed = False frappe.flags.customer_group_changed = False