diff --git a/frappe/core/doctype/communication/communication.json b/frappe/core/doctype/communication/communication.json index 2410353975..3a9da3435c 100644 --- a/frappe/core/doctype/communication/communication.json +++ b/frappe/core/doctype/communication/communication.json @@ -154,7 +154,7 @@ "idx": 1, "in_dialog": 0, "issingle": 0, - "modified": "2014-05-27 03:49:08.475911", + "modified": "2014-07-16 09:33:28.698964", "modified_by": "Administrator", "module": "Core", "name": "Communication", @@ -162,7 +162,7 @@ "permissions": [ { "amend": 0, - "apply_user_permissions": 1, + "apply_user_permissions": 0, "create": 1, "delete": 1, "email": 1, @@ -189,7 +189,7 @@ }, { "amend": 0, - "apply_user_permissions": 1, + "apply_user_permissions": 0, "create": 1, "delete": 1, "email": 1, diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py index 3025045a94..00cc40743e 100644 --- a/frappe/core/doctype/communication/communication.py +++ b/frappe/core/doctype/communication/communication.py @@ -16,6 +16,10 @@ from frappe import _ from frappe.model.document import Document class Communication(Document): + def validate(self): + if not self.parentfield: + self.parentfield = "communications" + def get_parent_doc(self): return frappe.get_doc(self.parenttype, self.parent) diff --git a/frappe/core/doctype/communication/test_communication.py b/frappe/core/doctype/communication/test_communication.py new file mode 100644 index 0000000000..e3c73f7eb8 --- /dev/null +++ b/frappe/core/doctype/communication/test_communication.py @@ -0,0 +1,10 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# See license.txt + +import frappe +import unittest + +test_records = frappe.get_test_records('Communication') + +class TestCommunication(unittest.TestCase): + pass diff --git a/frappe/core/doctype/communication/test_records.json b/frappe/core/doctype/communication/test_records.json new file mode 100644 index 0000000000..a69d3e9570 --- /dev/null +++ b/frappe/core/doctype/communication/test_records.json @@ -0,0 +1,10 @@ +[ + { + "doctype": "Communication", + "name": "_Test Communication 1", + "subject": "Test Subject", + "sent_or_received": "Received", + "parenttype": "User", + "parent": "Administrator" + } +] diff --git a/frappe/core/doctype/doctype/boilerplate/test_records.json b/frappe/core/doctype/doctype/boilerplate/test_records.json index 9c261424c3..6df1b54abc 100644 --- a/frappe/core/doctype/doctype/boilerplate/test_records.json +++ b/frappe/core/doctype/doctype/boilerplate/test_records.json @@ -1,6 +1,6 @@ [ {{ "doctype": "{doctype}", - "name":"_Test {doctype} 1", + "name": "_Test {doctype} 1" }} ] diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index 269bade04c..77cf99868a 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -152,7 +152,7 @@ class DocType(Document): frappe.throw(_("App not found")) app_publisher = frappe.get_hooks(hook="app_publisher", app_name=app)[0] - for template in ["controller.py", "test_controller.py", "test_records.json"]: + def _make_boilerplate(template): template_name = template.replace("controller", scrub(self.name)) target_file_path = os.path.join(target_path, template_name) if not os.path.exists(target_file_path): @@ -163,6 +163,11 @@ class DocType(Document): target.write(source.read().format(app_publisher=app_publisher, classname=self.name.replace(" ", ""), doctype=self.name)) + _make_boilerplate("controller.py") + + if not (self.istable or self.issingle): + _make_boilerplate("test_controller.py") + _make_boilerplate("test_records.json") def make_amendable(self): """