refactor: Remove implicit auto assignment feature (#18124)
This behaviour now can be replicated with Assignment Rule configurations.
This commit is contained in:
parent
fc3731f15e
commit
8d70073cf8
@ -9,7 +9,6 @@ from frappe.model.mapper import get_mapped_doc
|
||||
from erpnext.setup.utils import get_exchange_rate
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
from erpnext.accounts.party import get_party_account_currency
|
||||
from frappe.desk.form import assign_to
|
||||
from frappe.email.inbox import link_communication_to_document
|
||||
|
||||
subject_field = "title"
|
||||
@ -155,9 +154,6 @@ class Opportunity(TransactionBase):
|
||||
def on_update(self):
|
||||
self.add_calendar_event()
|
||||
|
||||
# assign to customer account manager or lead owner
|
||||
assign_to_user(self, subject_field)
|
||||
|
||||
def add_calendar_event(self, opts=None, force=False):
|
||||
if not opts:
|
||||
opts = frappe._dict()
|
||||
@ -335,21 +331,6 @@ def auto_close_opportunity():
|
||||
doc.flags.ignore_mandatory = True
|
||||
doc.save()
|
||||
|
||||
def assign_to_user(doc, subject_field):
|
||||
assign_user = None
|
||||
if doc.customer:
|
||||
assign_user = frappe.db.get_value('Customer', doc.customer, 'account_manager')
|
||||
elif doc.lead:
|
||||
assign_user = frappe.db.get_value('Lead', doc.lead, 'lead_owner')
|
||||
|
||||
if assign_user and assign_user not in ['Administrator', 'Guest']:
|
||||
if not assign_to.get(dict(doctype = doc.doctype, name = doc.name)):
|
||||
assign_to.add({
|
||||
"assign_to": assign_user,
|
||||
"doctype": doc.doctype,
|
||||
"name": doc.name,
|
||||
"description": doc.get(subject_field)
|
||||
})
|
||||
@frappe.whitelist()
|
||||
def make_opportunity_from_communication(communication, ignore_communication_links=False):
|
||||
from erpnext.crm.doctype.lead.lead import make_lead_from_communication
|
||||
|
@ -7,7 +7,6 @@ from frappe.utils import today, random_string
|
||||
from erpnext.crm.doctype.lead.lead import make_customer
|
||||
from erpnext.crm.doctype.opportunity.opportunity import make_quotation
|
||||
import unittest
|
||||
from frappe.desk.form import assign_to
|
||||
|
||||
test_records = frappe.get_test_records('Opportunity')
|
||||
|
||||
@ -61,20 +60,6 @@ class TestOpportunity(unittest.TestCase):
|
||||
self.assertEqual(opp_doc.enquiry_from, "Customer")
|
||||
self.assertEqual(opp_doc.customer, customer.name)
|
||||
|
||||
def test_assignment(self):
|
||||
# assign cutomer account manager
|
||||
frappe.db.set_value('Customer', '_Test Customer', 'account_manager', 'test1@example.com')
|
||||
doc = make_opportunity(with_items=0)
|
||||
|
||||
self.assertEqual(assign_to.get(dict(doctype = doc.doctype, name = doc.name))[0].get('owner'), 'test1@example.com')
|
||||
|
||||
# assign lead owner
|
||||
frappe.db.set_value('Customer', '_Test Customer', 'account_manager', '')
|
||||
frappe.db.set_value('Lead', '_T-Lead-00001', 'lead_owner', 'test2@example.com')
|
||||
doc = make_opportunity(with_items=0, enquiry_from='Lead')
|
||||
|
||||
self.assertEqual(assign_to.get(dict(doctype = doc.doctype, name = doc.name))[0].get('owner'), 'test2@example.com')
|
||||
|
||||
|
||||
def make_opportunity(**args):
|
||||
args = frappe._dict(args)
|
||||
|
@ -12,7 +12,6 @@ from datetime import datetime, timedelta
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from frappe.utils.user import is_website_user
|
||||
from erpnext.support.doctype.service_level_agreement.service_level_agreement import get_active_service_level_agreement_for
|
||||
from erpnext.crm.doctype.opportunity.opportunity import assign_to_user
|
||||
from frappe.email.inbox import link_communication_to_document
|
||||
|
||||
sender_field = "raised_by"
|
||||
@ -39,9 +38,6 @@ class Issue(Document):
|
||||
self.create_communication()
|
||||
self.flags.communication_created = None
|
||||
|
||||
# assign to customer account manager or lead owner
|
||||
assign_to_user(self, 'subject')
|
||||
|
||||
def set_lead_contact(self, email_id):
|
||||
import email.utils
|
||||
|
||||
|
@ -8,15 +8,8 @@ from erpnext.support.doctype.service_level_agreement.test_service_level_agreemen
|
||||
from frappe.utils import now_datetime, get_datetime
|
||||
import datetime
|
||||
from datetime import timedelta
|
||||
from frappe.desk.form import assign_to
|
||||
|
||||
class TestIssue(unittest.TestCase):
|
||||
def test_assignment(self):
|
||||
frappe.db.set_value('Customer', '_Test Customer', 'account_manager', 'test1@example.com')
|
||||
doc = make_issue(customer='_Test Customer')
|
||||
self.assertEqual(assign_to.get(dict(doctype = doc.doctype, name = doc.name))[0].get('owner'), 'test1@example.com')
|
||||
|
||||
|
||||
def test_response_time_and_resolution_time_based_on_different_sla(self):
|
||||
create_service_level_agreements_for_issues()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user