From 5ca977a41c1b935555b75b86e5bc6f4c0683ee8e Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Wed, 1 May 2019 11:16:43 +0530 Subject: [PATCH] fix: python side validation --- erpnext/selling/doctype/customer/customer.js | 5 ----- erpnext/selling/doctype/customer/customer.py | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index 356dcda8e1..178a21d474 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -124,10 +124,5 @@ frappe.ui.form.on("Customer", { validate: function(frm) { if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name); - var total = 0; - for (var idx in frm.doc.sales_team) { - total += frm.doc.sales_team[idx].allocated_percentage; - if (total > 100) frappe.throw(__("Total contribution percentage can't exceed 100")); - } }, }); \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index ba20cbc73e..7328d1d6ae 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -60,6 +60,12 @@ 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 allocated_percentage > 100: + frappe.throw(_("Total contribution percentage can't exceed 100")) + def check_customer_group_change(self): frappe.flags.customer_group_changed = False