Merge pull request #16694 from rmehta/refactor-comments
fix: refactored comments API. Depends on https://github.com/frappe/frappe/pull/6891
This commit is contained in:
commit
20db65ef77
@ -116,30 +116,34 @@ class TestCustomer(unittest.TestCase):
|
|||||||
|
|
||||||
def test_rename(self):
|
def test_rename(self):
|
||||||
# delete communication linked to these 2 customers
|
# delete communication linked to these 2 customers
|
||||||
for name in ("_Test Customer 1", "_Test Customer 1 Renamed"):
|
|
||||||
frappe.db.sql("""delete from `tabCommunication`
|
new_name = "_Test Customer 1 Renamed"
|
||||||
where communication_type='Comment' and reference_doctype=%s and reference_name=%s""",
|
for name in ("_Test Customer 1", new_name):
|
||||||
|
frappe.db.sql("""delete from `tabComment`
|
||||||
|
where reference_doctype=%s and reference_name=%s""",
|
||||||
("Customer", name))
|
("Customer", name))
|
||||||
|
|
||||||
# add comments
|
# add comments
|
||||||
comment = frappe.get_doc("Customer", "_Test Customer 1").add_comment("Comment", "Test Comment for Rename")
|
comment = frappe.get_doc("Customer", "_Test Customer 1").add_comment("Comment", "Test Comment for Rename")
|
||||||
|
|
||||||
# rename
|
# rename
|
||||||
frappe.rename_doc("Customer", "_Test Customer 1", "_Test Customer 1 Renamed")
|
frappe.rename_doc("Customer", "_Test Customer 1", new_name)
|
||||||
|
|
||||||
# check if customer renamed
|
# check if customer renamed
|
||||||
self.assertTrue(frappe.db.exists("Customer", "_Test Customer 1 Renamed"))
|
self.assertTrue(frappe.db.exists("Customer", new_name))
|
||||||
self.assertFalse(frappe.db.exists("Customer", "_Test Customer 1"))
|
self.assertFalse(frappe.db.exists("Customer", "_Test Customer 1"))
|
||||||
|
|
||||||
# test that comment gets linked to renamed doc
|
# test that comment gets linked to renamed doc
|
||||||
self.assertEqual(frappe.db.get_value("Communication", {
|
self.assertEqual(frappe.db.get_value("Comment", {
|
||||||
"communication_type": "Comment",
|
|
||||||
"reference_doctype": "Customer",
|
"reference_doctype": "Customer",
|
||||||
"reference_name": "_Test Customer 1 Renamed"
|
"reference_name": new_name,
|
||||||
|
"content": "Test Comment for Rename"
|
||||||
}), comment.name)
|
}), comment.name)
|
||||||
|
|
||||||
# rename back to original
|
# rename back to original
|
||||||
frappe.rename_doc("Customer", "_Test Customer 1 Renamed", "_Test Customer 1")
|
frappe.rename_doc("Customer", new_name, "_Test Customer 1")
|
||||||
|
|
||||||
|
frappe.db.rollback()
|
||||||
|
|
||||||
def test_freezed_customer(self):
|
def test_freezed_customer(self):
|
||||||
make_test_records("Item")
|
make_test_records("Item")
|
||||||
|
|||||||
@ -5,7 +5,6 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import cstr, getdate
|
from frappe.utils import cstr, getdate
|
||||||
from frappe.core.doctype.communication.comment import add_info_comment
|
|
||||||
|
|
||||||
def set_default_settings(args):
|
def set_default_settings(args):
|
||||||
# enable default currency
|
# enable default currency
|
||||||
@ -114,9 +113,7 @@ def create_territories():
|
|||||||
|
|
||||||
def create_feed_and_todo():
|
def create_feed_and_todo():
|
||||||
"""update Activity feed and create todo for creation of item, customer, vendor"""
|
"""update Activity feed and create todo for creation of item, customer, vendor"""
|
||||||
add_info_comment(**{
|
return
|
||||||
"subject": _("ERPNext Setup Complete!")
|
|
||||||
})
|
|
||||||
|
|
||||||
def get_fy_details(fy_start_date, fy_end_date):
|
def get_fy_details(fy_start_date, fy_end_date):
|
||||||
start_year = getdate(fy_start_date).year
|
start_year = getdate(fy_start_date).year
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user