feat: added custom fields in email template doctype
This commit is contained in:
parent
d2d1b09c10
commit
66349ca27f
@ -76,7 +76,7 @@ after_install = "crm.install.after_install"
|
|||||||
# Uninstallation
|
# Uninstallation
|
||||||
# ------------
|
# ------------
|
||||||
|
|
||||||
# before_uninstall = "crm.uninstall.before_uninstall"
|
before_uninstall = "crm.uninstall.before_uninstall"
|
||||||
# after_uninstall = "crm.uninstall.after_uninstall"
|
# after_uninstall = "crm.uninstall.after_uninstall"
|
||||||
|
|
||||||
# Integration Setup
|
# Integration Setup
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
|
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
# MIT License. See license.txt
|
# MIT License. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
import click
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
|
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
|
||||||
|
|
||||||
def before_install():
|
def before_install():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -12,6 +14,7 @@ def after_install():
|
|||||||
add_default_deal_statuses()
|
add_default_deal_statuses()
|
||||||
add_default_communication_statuses()
|
add_default_communication_statuses()
|
||||||
add_property_setter()
|
add_property_setter()
|
||||||
|
add_email_template_custom_fields()
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
def add_default_lead_statuses():
|
def add_default_lead_statuses():
|
||||||
@ -113,4 +116,31 @@ def add_property_setter():
|
|||||||
doc.property = "search_fields"
|
doc.property = "search_fields"
|
||||||
doc.property_type = "Data"
|
doc.property_type = "Data"
|
||||||
doc.value = "email_id"
|
doc.value = "email_id"
|
||||||
doc.insert()
|
doc.insert()
|
||||||
|
|
||||||
|
def add_email_template_custom_fields():
|
||||||
|
if not frappe.get_meta("Email Template").has_field("enabled"):
|
||||||
|
click.secho("* Installing Custom Fields in Email Template")
|
||||||
|
|
||||||
|
create_custom_fields(
|
||||||
|
{
|
||||||
|
"Email Template": [
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "enabled",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Enabled",
|
||||||
|
"insert_after": "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "reference_doctype",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Doctype",
|
||||||
|
"options": "DocType",
|
||||||
|
"insert_after": "enabled",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
frappe.clear_cache(doctype="Email Template")
|
||||||
|
|||||||
22
crm/uninstall.py
Normal file
22
crm/uninstall.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
|
# MIT License. See license.txt
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import click
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def before_uninstall():
|
||||||
|
delete_email_template_custom_fields()
|
||||||
|
|
||||||
|
def delete_email_template_custom_fields():
|
||||||
|
if frappe.get_meta("Email Template").has_field("enabled"):
|
||||||
|
click.secho("* Uninstalling Custom Fields from Email Template")
|
||||||
|
|
||||||
|
fieldnames = (
|
||||||
|
"enabled",
|
||||||
|
"reference_doctype",
|
||||||
|
)
|
||||||
|
|
||||||
|
for fieldname in fieldnames:
|
||||||
|
frappe.db.delete("Custom Field", {"name": "Email Template-" + fieldname})
|
||||||
|
|
||||||
|
frappe.clear_cache(doctype="Email Template")
|
||||||
Loading…
x
Reference in New Issue
Block a user