File tree Expand file tree Collapse file tree
frappe/integrations/doctype/webhook Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33# For license information, please see license.txt
44
55from __future__ import unicode_literals
6+
67import frappe
78
89
@@ -54,9 +55,15 @@ def _webhook_request(webhook):
5455 event_list .append ('on_change' )
5556 event_list .append ('before_update_after_submit' )
5657
58+ from frappe .integrations .doctype .webhook .webhook import get_context
59+
5760 for webhook in webhooks_for_doc :
61+ trigger_webhook = False
5862 event = method if method in event_list else None
63+ if not webhook .condition :
64+ trigger_webhook = True
65+ elif frappe .safe_eval (webhook .condition , eval_locals = get_context (doc )):
66+ trigger_webhook = True
5967
60- if webhook .condition and frappe .safe_eval (webhook .condition , None , {"doc" : doc }):
61- if event and webhook .webhook_docevent == event :
62- _webhook_request (webhook )
68+ if trigger_webhook and event and webhook .webhook_docevent == event :
69+ _webhook_request (webhook )
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ def validate_condition(self):
3939 temp_doc = frappe .new_doc (self .webhook_doctype )
4040 if self .condition :
4141 try :
42- frappe .safe_eval (self .condition , eval_globals = None , eval_locals = get_context (temp_doc ))
42+ frappe .safe_eval (self .condition , eval_locals = get_context (temp_doc ))
4343 except Exception as e :
4444 frappe .throw (_ (e ))
4545
You can’t perform that action at this time.
0 commit comments