Merge pull request #2770 from neilLasrado/time-log

Validate renaming of activity type - manufacturing
This commit is contained in:
Nabin Hait 2015-02-18 13:11:19 +05:30
commit 9f89df341d
2 changed files with 11 additions and 4 deletions

View File

@ -19,7 +19,7 @@
"icon": "icon-flag", "icon": "icon-flag",
"idx": 1, "idx": 1,
"in_dialog": 0, "in_dialog": 0,
"modified": "2015-02-05 05:11:34.201187", "modified": "2015-02-18 13:05:23.608066",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Projects", "module": "Projects",
"name": "Activity Type", "name": "Activity Type",
@ -27,7 +27,10 @@
"permissions": [ "permissions": [
{ {
"create": 1, "create": 1,
"delete": 1,
"email": 1, "email": 1,
"export": 1,
"import": 1,
"permlevel": 0, "permlevel": 0,
"print": 1, "print": 1,
"read": 1, "read": 1,
@ -39,6 +42,7 @@
{ {
"apply_user_permissions": 1, "apply_user_permissions": 1,
"create": 1, "create": 1,
"delete": 0,
"email": 1, "email": 1,
"permlevel": 0, "permlevel": 0,
"print": 1, "print": 1,

View File

@ -3,14 +3,17 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
class ActivityType(Document): class ActivityType(Document):
def on_trash(self): def on_trash(self):
self.validate_manufacturing_type() self.validate_manufacturing_type()
def before_rename(self, olddn, newdn, merge=False):
self.validate_manufacturing_type()
def validate_manufacturing_type(self): def validate_manufacturing_type(self):
if self.activity_type == 'Manufacturing': if self.activity_type == 'Manufacturing':
frappe.throw(_("Activity Type 'Manufacturing' cannot be deleted.")) frappe.throw(_("Activity Type 'Manufacturing' cannot be deleted/renamed."))