From c8018bdeb13e0b5feb7dc1faed95477f30de8aaa Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 9 Feb 2019 21:10:29 +0530 Subject: [PATCH 1/2] fix: refactored comments API. Depends on https://github.com/frappe/frappe/pull/6891 --- erpnext/selling/doctype/customer/test_customer.py | 7 +++---- erpnext/setup/setup_wizard/operations/defaults_setup.py | 5 +---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index 47e80d44d71..8349e4725b5 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -117,8 +117,8 @@ class TestCustomer(unittest.TestCase): def test_rename(self): # delete communication linked to these 2 customers for name in ("_Test Customer 1", "_Test Customer 1 Renamed"): - frappe.db.sql("""delete from `tabCommunication` - where communication_type='Comment' and reference_doctype=%s and reference_name=%s""", + frappe.db.sql("""delete from `tabComment` + where reference_doctype=%s and reference_name=%s""", ("Customer", name)) # add comments @@ -132,8 +132,7 @@ class TestCustomer(unittest.TestCase): self.assertFalse(frappe.db.exists("Customer", "_Test Customer 1")) # test that comment gets linked to renamed doc - self.assertEqual(frappe.db.get_value("Communication", { - "communication_type": "Comment", + self.assertEqual(frappe.db.get_value("Comment", { "reference_doctype": "Customer", "reference_name": "_Test Customer 1 Renamed" }), comment.name) diff --git a/erpnext/setup/setup_wizard/operations/defaults_setup.py b/erpnext/setup/setup_wizard/operations/defaults_setup.py index ff8dd75eeef..6dd0fb1403f 100644 --- a/erpnext/setup/setup_wizard/operations/defaults_setup.py +++ b/erpnext/setup/setup_wizard/operations/defaults_setup.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import frappe from frappe import _ from frappe.utils import cstr, getdate -from frappe.core.doctype.communication.comment import add_info_comment def set_default_settings(args): # enable default currency @@ -114,9 +113,7 @@ def create_territories(): def create_feed_and_todo(): """update Activity feed and create todo for creation of item, customer, vendor""" - add_info_comment(**{ - "subject": _("ERPNext Setup Complete!") - }) + return def get_fy_details(fy_start_date, fy_end_date): start_year = getdate(fy_start_date).year From 39c106dd058ba440b222559a958f686847487987 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 18 Feb 2019 11:16:59 +0530 Subject: [PATCH 2/2] fix(test): rename test in test_customer --- erpnext/selling/doctype/customer/test_customer.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index 8349e4725b5..f261ef37fb9 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -116,7 +116,9 @@ class TestCustomer(unittest.TestCase): def test_rename(self): # delete communication linked to these 2 customers - for name in ("_Test Customer 1", "_Test Customer 1 Renamed"): + + new_name = "_Test Customer 1 Renamed" + for name in ("_Test Customer 1", new_name): frappe.db.sql("""delete from `tabComment` where reference_doctype=%s and reference_name=%s""", ("Customer", name)) @@ -125,20 +127,23 @@ class TestCustomer(unittest.TestCase): comment = frappe.get_doc("Customer", "_Test Customer 1").add_comment("Comment", "Test Comment for 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 - 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")) # test that comment gets linked to renamed doc self.assertEqual(frappe.db.get_value("Comment", { "reference_doctype": "Customer", - "reference_name": "_Test Customer 1 Renamed" + "reference_name": new_name, + "content": "Test Comment for Rename" }), comment.name) # 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): make_test_records("Item")