fix: cyclical imports
This commit is contained in:
parent
2109c7a984
commit
edba86ceba
2 changed files with 13 additions and 6 deletions
|
|
@ -3,6 +3,7 @@
|
|||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
|
|
@ -54,9 +55,15 @@ def run_webhooks(doc, method):
|
|||
event_list.append('on_change')
|
||||
event_list.append('before_update_after_submit')
|
||||
|
||||
for webhook in webhooks_for_doc:
|
||||
event = method if method in event_list else None
|
||||
from frappe.integrations.doctype.webhook.webhook import get_context
|
||||
|
||||
if webhook.condition and frappe.safe_eval(webhook.condition, None, {"doc": doc}):
|
||||
if event and webhook.webhook_docevent == event:
|
||||
_webhook_request(webhook)
|
||||
for webhook in webhooks_for_doc:
|
||||
trigger_webhook = False
|
||||
event = method if method in event_list else None
|
||||
if not webhook.condition:
|
||||
trigger_webhook = True
|
||||
elif frappe.safe_eval(webhook.condition, eval_locals=get_context(doc)):
|
||||
trigger_webhook = True
|
||||
|
||||
if trigger_webhook and event and webhook.webhook_docevent == event:
|
||||
_webhook_request(webhook)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class Webhook(Document):
|
|||
temp_doc = frappe.new_doc(self.webhook_doctype)
|
||||
if self.condition:
|
||||
try:
|
||||
frappe.safe_eval(self.condition, eval_globals=None, eval_locals=get_context(temp_doc))
|
||||
frappe.safe_eval(self.condition, eval_locals=get_context(temp_doc))
|
||||
except Exception as e:
|
||||
frappe.throw(_(e))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue