Skip to content

Commit

Permalink
chore: Code readability & check for field in row (now row itself)
Browse files Browse the repository at this point in the history
  • Loading branch information
marination committed Jun 16, 2022
1 parent e817191 commit ea1095f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions erpnext/accounts/doctype/pricing_rule/pricing_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ def validate(self):

def validate_duplicate_apply_on(self):
if self.apply_on != "Transaction":
field = apply_on_dict.get(self.apply_on)
if not field:
apply_on_table = apply_on_dict.get(self.apply_on)
if not apply_on_table:
return

values = [d.get(frappe.scrub(self.apply_on)) for d in self.get(field) if d]
apply_on_field = frappe.scrub(self.apply_on)
values = [d.get(apply_on_field) for d in self.get(apply_on_table) if d.get(apply_on_field)]
if len(values) != len(set(values)):
frappe.throw(_("Duplicate {0} found in the table").format(self.apply_on))

Expand Down

0 comments on commit ea1095f

Please sign in to comment.