Merge pull request #699 from anandpdoshi/anand-july-16

Fixed doctype boilerplate and communication permissions
This commit is contained in:
Nabin Hait 2014-07-16 20:04:29 +05:30
commit fbbf5beef0
6 changed files with 34 additions and 5 deletions

View file

@ -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,

View file

@ -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)

View file

@ -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

View file

@ -0,0 +1,10 @@
[
{
"doctype": "Communication",
"name": "_Test Communication 1",
"subject": "Test Subject",
"sent_or_received": "Received",
"parenttype": "User",
"parent": "Administrator"
}
]

View file

@ -1,6 +1,6 @@
[
{{
"doctype": "{doctype}",
"name":"_Test {doctype} 1",
"name": "_Test {doctype} 1"
}}
]

View file

@ -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):
"""