feat: Optionally trigger doc events while updating doc from notification
This commit is contained in:
parent
9830225bea
commit
a9133ebcf6
2 changed files with 18 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"autoname": "Prompt",
|
||||
"creation": "2014-07-11 17:18:09.923399",
|
||||
|
|
@ -30,6 +31,7 @@
|
|||
"property_section",
|
||||
"set_property_after_alert",
|
||||
"property_value",
|
||||
"trigger_document_events",
|
||||
"column_break_5",
|
||||
"recipients",
|
||||
"message_sb",
|
||||
|
|
@ -260,10 +262,17 @@
|
|||
"fieldtype": "Link",
|
||||
"label": "Print Format",
|
||||
"options": "Print Format"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "trigger_document_events",
|
||||
"fieldtype": "Check",
|
||||
"label": "Trigger Document Events"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-envelope",
|
||||
"modified": "2019-07-15 13:17:02.585013",
|
||||
"links": [],
|
||||
"modified": "2020-01-24 11:26:48.454013",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Email",
|
||||
"name": "Notification",
|
||||
|
|
|
|||
|
|
@ -129,11 +129,14 @@ def get_context(context):
|
|||
allow_update = True
|
||||
if doc.docstatus == 1 and not doc.meta.get_field(self.set_property_after_alert).allow_on_submit:
|
||||
allow_update = False
|
||||
|
||||
if allow_update:
|
||||
frappe.db.set_value(doc.doctype, doc.name, self.set_property_after_alert,
|
||||
self.property_value, update_modified = False)
|
||||
doc.set(self.set_property_after_alert, self.property_value)
|
||||
try:
|
||||
if allow_update:
|
||||
frappe.db.set_value(doc.doctype, doc.name, self.set_property_after_alert,
|
||||
self.property_value, update_modified = False)
|
||||
doc.set(self.set_property_after_alert, self.property_value)
|
||||
doc.save()
|
||||
except Exception as e:
|
||||
frappe.log_error(title=_('Document update failed'), message=frappe.get_traceback())
|
||||
|
||||
def send_an_email(self, doc, context):
|
||||
from email.utils import formataddr
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue