mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 12:19:12 +00:00
[enhance] Add Issue Type and Opportunity Type masters (#11598)
* [enhance] added & linked Issue Type & Opportunity Type with opportunity * [patch] create issue and opportunity type from the custom field if available * [minor] issue_type and opportunity type should be mandatory * [patches] removed try catch from the patch * [fix] patch * [refactor] cleanup issue/opportunity type
This commit is contained in:
0
erpnext/patches/v9_1/__init__.py
Normal file
0
erpnext/patches/v9_1/__init__.py
Normal file
34
erpnext/patches/v9_1/create_issue_opportunity_type.py
Normal file
34
erpnext/patches/v9_1/create_issue_opportunity_type.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Copyright (c) 2017, Frappe and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
def execute():
|
||||
# delete custom field if exists
|
||||
for fieldname in ('issue_type', 'opportunity_type'):
|
||||
custom_field = frappe.db.get_value("Custom Field", {"fieldname": fieldname})
|
||||
if custom_field:
|
||||
frappe.delete_doc("Custom Field", custom_field, ignore_permissions=True)
|
||||
|
||||
frappe.reload_doc('support', 'doctype', 'issue_type')
|
||||
frappe.reload_doc('support', 'doctype', 'issue')
|
||||
frappe.reload_doc('crm', 'doctype', 'opportunity_type')
|
||||
frappe.reload_doc('crm', 'doctype', 'opportunity')
|
||||
|
||||
# rename enquiry_type -> opportunity_type
|
||||
from frappe.model.utils.rename_field import rename_field
|
||||
rename_field('Opportunity', 'enquiry_type', 'opportunity_type')
|
||||
|
||||
# create values if already set
|
||||
for opts in (('Issue', 'issue_type', 'Issue Type'),
|
||||
('Opportunity', 'opportunity_type', 'Opportunity Type')):
|
||||
for d in frappe.db.sql('select distinct {0} from `tab{1}`'.format(opts[1], opts[0])):
|
||||
if not frappe.db.exists(opts[2], d[0]):
|
||||
frappe.get_doc(dict(doctype = opts[2], name=d[0])).insert()
|
||||
|
||||
# fixtures
|
||||
for name in ('Hub', _('Sales'), _('Support'), _('Maintenance')):
|
||||
if not frappe.db.exists('Opportunity', name):
|
||||
frappe.get_doc(dict(doctype = 'Opportunity Type', name=name)).insert()
|
||||
Reference in New Issue
Block a user