mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 13:09:17 +00:00
feat: unlinking dynamic links on trash
This commit is contained in:
@@ -102,7 +102,7 @@
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2020-01-28 16:16:45.447213",
|
||||
"modified": "2021-06-30 13:09:14.228756",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Appointment",
|
||||
@@ -153,6 +153,18 @@
|
||||
"role": "Sales User",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Employee",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
|
||||
@@ -38,7 +38,7 @@ class Appointment(Document):
|
||||
number_of_agents = frappe.db.get_single_value('Appointment Booking Settings', 'number_of_agents')
|
||||
if not number_of_agents == 0:
|
||||
if (number_of_appointments_in_same_slot >= number_of_agents):
|
||||
frappe.throw('Time slot is not available')
|
||||
frappe.throw(_('Time slot is not available'))
|
||||
# Link lead
|
||||
if not self.party:
|
||||
lead = self.find_lead_by_email()
|
||||
@@ -75,10 +75,10 @@ class Appointment(Document):
|
||||
subject=_('Appointment Confirmation'))
|
||||
if frappe.session.user == "Guest":
|
||||
frappe.msgprint(
|
||||
'Please check your email to confirm the appointment')
|
||||
_('Please check your email to confirm the appointment'))
|
||||
else :
|
||||
frappe.msgprint(
|
||||
'Appointment was created. But no lead was found. Please check the email to confirm')
|
||||
_('Appointment was created. But no lead was found. Please check the email to confirm'))
|
||||
|
||||
def on_change(self):
|
||||
# Sync Calendar
|
||||
@@ -91,7 +91,7 @@ class Appointment(Document):
|
||||
|
||||
def set_verified(self, email):
|
||||
if not email == self.customer_email:
|
||||
frappe.throw('Email verification failed.')
|
||||
frappe.throw(_('Email verification failed.'))
|
||||
# Create new lead
|
||||
self.create_lead_and_link()
|
||||
# Remove unverified status
|
||||
@@ -184,7 +184,7 @@ class Appointment(Document):
|
||||
appointment_event.insert(ignore_permissions=True)
|
||||
self.calendar_event = appointment_event.name
|
||||
self.save(ignore_permissions=True)
|
||||
|
||||
|
||||
def _get_verify_url(self):
|
||||
verify_route = '/book_appointment/verify'
|
||||
params = {
|
||||
|
||||
0
erpnext/crm/doctype/campaign/__init__.py
Normal file
0
erpnext/crm/doctype/campaign/__init__.py
Normal file
17
erpnext/crm/doctype/campaign/campaign.js
Normal file
17
erpnext/crm/doctype/campaign/campaign.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Campaign', {
|
||||
refresh: function(frm) {
|
||||
erpnext.toggle_naming_series();
|
||||
|
||||
if (frm.doc.__islocal) {
|
||||
frm.toggle_display("naming_series", frappe.boot.sysdefaults.campaign_naming_by=="Naming Series");
|
||||
} else {
|
||||
cur_frm.add_custom_button(__("View Leads"), function() {
|
||||
frappe.route_options = {"source": "Campaign", "campaign_name": frm.doc.name};
|
||||
frappe.set_route("List", "Lead");
|
||||
}, "fa fa-list", true);
|
||||
}
|
||||
}
|
||||
});
|
||||
111
erpnext/crm/doctype/campaign/campaign.json
Normal file
111
erpnext/crm/doctype/campaign/campaign.json
Normal file
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "naming_series:",
|
||||
"creation": "2013-01-10 16:34:18",
|
||||
"description": "Keep Track of Sales Campaigns. Keep track of Leads, Quotations, Sales Order etc from Campaigns to gauge Return on Investment. ",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Setup",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"campaign",
|
||||
"campaign_name",
|
||||
"naming_series",
|
||||
"campaign_schedules_section",
|
||||
"campaign_schedules",
|
||||
"description_section",
|
||||
"description"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "campaign",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Campaign",
|
||||
"oldfieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "campaign_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Campaign Name",
|
||||
"oldfieldname": "campaign_name",
|
||||
"oldfieldtype": "Data",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "naming_series",
|
||||
"fieldtype": "Select",
|
||||
"label": "Naming Series",
|
||||
"options": "SAL-CAM-.YYYY.-",
|
||||
"set_only_once": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "campaign_schedules_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Campaign Schedules"
|
||||
},
|
||||
{
|
||||
"fieldname": "campaign_schedules",
|
||||
"fieldtype": "Table",
|
||||
"label": "Campaign Schedules",
|
||||
"options": "Campaign Email Schedule"
|
||||
},
|
||||
{
|
||||
"fieldname": "description_section",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text",
|
||||
"in_list_view": 1,
|
||||
"label": "Description",
|
||||
"oldfieldname": "description",
|
||||
"oldfieldtype": "Text",
|
||||
"width": "300px"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-bullhorn",
|
||||
"idx": 1,
|
||||
"links": [],
|
||||
"modified": "2021-06-30 18:05:06.412712",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Campaign",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"import": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Sales Manager",
|
||||
"set_user_permissions": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"email": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Sales User"
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Sales Master Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
}
|
||||
13
erpnext/crm/doctype/campaign/campaign.py
Normal file
13
erpnext/crm/doctype/campaign/campaign.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.naming import set_name_by_naming_series
|
||||
|
||||
class Campaign(Document):
|
||||
def autoname(self):
|
||||
if frappe.defaults.get_global_default('campaign_naming_by') != 'Naming Series':
|
||||
self.name = self.campaign_name
|
||||
else:
|
||||
set_name_by_naming_series(self)
|
||||
8
erpnext/crm/doctype/campaign/test_campaign.py
Normal file
8
erpnext/crm/doctype/campaign/test_campaign.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestCampaign(unittest.TestCase):
|
||||
pass
|
||||
@@ -78,8 +78,25 @@ class Lead(SellingController):
|
||||
def on_trash(self):
|
||||
frappe.db.sql("""update `tabIssue` set lead='' where lead=%s""", self.name)
|
||||
|
||||
self.unlink_dynamic_links()
|
||||
self.delete_events()
|
||||
|
||||
def unlink_dynamic_links(self):
|
||||
links = frappe.get_all('Dynamic Link', filters={'link_doctype': self.doctype, 'link_name': self.name}, fields=['parent', 'parenttype'])
|
||||
|
||||
for link in links:
|
||||
linked_doc = frappe.get_doc(link['parenttype'], link['parent'])
|
||||
|
||||
if len(linked_doc.get('links')) == 1:
|
||||
linked_doc.delete()
|
||||
else:
|
||||
to_remove = None
|
||||
for d in linked_doc.get('links'):
|
||||
if d.link_doctype == self.doctype and d.link_name == self.name:
|
||||
to_remove = d
|
||||
if to_remove:
|
||||
link_doctype.remove(to_remove)
|
||||
|
||||
def has_customer(self):
|
||||
return frappe.db.get_value("Customer", {"lead_name": self.name})
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ frappe.query_reports["First Response Time for Opportunity"] = {
|
||||
get_chart_data: function (_columns, result) {
|
||||
return {
|
||||
data: {
|
||||
labels: result.map(d => d[0]),
|
||||
labels: result.map(d => d.creation_date),
|
||||
datasets: [{
|
||||
name: "First Response Time",
|
||||
values: result.map(d => d[1])
|
||||
values: result.map(d => d.first_response_time)
|
||||
}]
|
||||
},
|
||||
type: "line",
|
||||
@@ -35,8 +35,7 @@ frappe.query_reports["First Response Time for Opportunity"] = {
|
||||
hide_days: 0,
|
||||
hide_seconds: 0
|
||||
};
|
||||
value = frappe.utils.get_formatted_duration(d, duration_options);
|
||||
return value;
|
||||
return frappe.utils.get_formatted_duration(d, duration_options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user