From 4f129239030db439a7eb04b23d6339ad9c25701d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Mar 2013 18:49:50 +0530 Subject: [PATCH] fixes in sales team percentage validation --- selling/doctype/sales_common/sales_common.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py index 47d139f955..12ae4a8c90 100644 --- a/selling/doctype/sales_common/sales_common.py +++ b/selling/doctype/sales_common/sales_common.py @@ -341,12 +341,10 @@ class DocType(TransactionBase): # ======================================================================== # it indicates % contribution of sales person in sales def get_allocated_sum(self,obj): - sum = 0 - for d in getlist(obj.doclist,'sales_team'): - sum += flt(d.allocated_percentage) - if (flt(sum) != 100) and getlist(obj.doclist,'sales_team'): - msgprint("Total Allocated % of Sales Persons should be 100%") - raise Exception + sales_team_list = obj.doclist.get({"parentfield": "sales_team"}) + total_allocation = sum([flt(d.allocated_percentage) for d in sales_team_list]) + if sales_team_list and total_allocation != 100.0: + msgprint("Total Allocated %% of Sales Persons should be 100%", raise_exception=True) # Check Conversion Rate (i.e. it will not allow conversion rate to be 1 for Currency other than default currency set in Global Defaults) # ===========================================================================