mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
Merge pull request #31380 from frappe/mergify/bp/version-13-hotfix/pr-31372
chore: Fix a potential variable misuse bug (backport #31372)
This commit is contained in:
@@ -36,10 +36,15 @@ class PricingRule(Document):
|
|||||||
self.margin_rate_or_amount = 0.0
|
self.margin_rate_or_amount = 0.0
|
||||||
|
|
||||||
def validate_duplicate_apply_on(self):
|
def validate_duplicate_apply_on(self):
|
||||||
field = apply_on_dict.get(self.apply_on)
|
if self.apply_on != "Transaction":
|
||||||
values = [d.get(frappe.scrub(self.apply_on)) for d in self.get(field) if field]
|
apply_on_table = apply_on_dict.get(self.apply_on)
|
||||||
if len(values) != len(set(values)):
|
if not apply_on_table:
|
||||||
frappe.throw(_("Duplicate {0} found in the table").format(self.apply_on))
|
return
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
def validate_mandatory(self):
|
def validate_mandatory(self):
|
||||||
for apply_on, field in apply_on_dict.items():
|
for apply_on, field in apply_on_dict.items():
|
||||||
|
|||||||
Reference in New Issue
Block a user