fix: added null check for conditions

This commit is contained in:
Shivam Mishra 2019-09-16 13:24:16 +05:30
parent 4668cc64e0
commit 124a218bbf

View file

@ -109,12 +109,15 @@ class AssignmentRule(Document):
def safe_eval(self, fieldname, doc):
try:
return frappe.safe_eval(self.get(fieldname), None, doc)
if self.get(fieldname):
return frappe.safe_eval(self.get(fieldname), None, doc)
except Exception as e:
# when assignment fails, don't block the document as it may be
# a part of the email pulling
frappe.msgprint(frappe._('Auto assignment failed: {0}').format(str(e)), indicator = 'orange')
return False
def get_assignments(doc):
return frappe.get_all('ToDo', fields = ['name', 'assignment_rule'], filters = dict(
reference_type = doc.get('doctype'),