Created
September 10, 2013 17:17
-
-
Save rmehta/6512582 to your computer and use it in GitHub Desktop.
Custom Script for "Communication" model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def custom_on_update(self): | |
parent = self.get_parent_bean() | |
if not parent: | |
return | |
parent.ignore_permissions = True | |
if parent.doc.doctype=="Lead" and parent.doc.status != "Trial Approved": | |
if "via demo.erpnext.com" in self.doc.content: | |
parent.doc.source="Demo" | |
parent.doc.status="Replied" | |
parent.save() | |
if "sub_domain" in self.doc.content: | |
import json | |
try: | |
details = json.loads(self.doc.content) | |
except ValueError, e: | |
return | |
# verify subdomain | |
if webnotes.conn.exists("Serial No", details.get("sub_domain", "") + ".erpnext.com"): | |
webnotes.response.message = "Subdomain already exists, please select another sub-domain" | |
raise Exception | |
else: | |
parent.doc.status="Trial Approved" | |
parent.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment