fix: python side validation

This commit is contained in:
Himanshu Warekar 2019-05-01 11:16:43 +05:30 committed by Nabin Hait
parent 76eddcc29f
commit 5ca977a41c
2 changed files with 6 additions and 5 deletions

View File

@ -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"));
}
},
});

View File

@ -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