fix: Replace newlines with spaces before evaluation of condition and formula (#21165)

This commit is contained in:
Nabin Hait 2020-04-08 09:34:46 +05:30 committed by GitHub
parent da6806e6bc
commit 04870ae23a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -356,13 +356,13 @@ class SalarySlip(TransactionBase):
def eval_condition_and_formula(self, d, data):
try:
condition = d.condition.strip() if d.condition else None
condition = d.condition.strip().replace("\n", " ") if d.condition else None
if condition:
if not frappe.safe_eval(condition, self.whitelisted_globals, data):
return None
amount = d.amount
if d.amount_based_on_formula:
formula = d.formula.strip() if d.formula else None
formula = d.formula.strip().replace("\n", " ") if d.formula else None
if formula:
amount = flt(frappe.safe_eval(formula, self.whitelisted_globals, data), d.precision("amount"))
if amount: