@@ -2,26 +2,17 @@ | |||
{ | |||
"owner": "Administrator", | |||
"docstatus": 0, | |||
"creation": "2012-05-25 14:30:53", | |||
"creation": "2012-09-10 14:50:29", | |||
"modified_by": "Administrator", | |||
"modified": "2012-09-10 12:14:04" | |||
"modified": "2012-12-28 11:54:12" | |||
}, | |||
{ | |||
"section_style": "Simple", | |||
"autoname": "eval:doc.dt+\"-\"+doc.fieldname", | |||
"description": "Adds a custom field to a DocType", | |||
"tag_fields": "dt,fieldtype", | |||
"search_fields": "dt,label,fieldtype,options", | |||
"module": "Core", | |||
"doctype": "DocType", | |||
"allow_trash": 1, | |||
"server_code_error": " ", | |||
"subject": "%(label)s (%(fieldtype)s) on %(dt)s", | |||
"autoname": "eval:doc.dt+\"-\"+doc.fieldname", | |||
"name": "__common__", | |||
"colour": "White:FFF", | |||
"_last_update": "1305789385", | |||
"show_in_menu": 0, | |||
"version": 1 | |||
"name": "__common__" | |||
}, | |||
{ | |||
"name": "__common__", | |||
@@ -43,37 +34,7 @@ | |||
"doctype": "DocType" | |||
}, | |||
{ | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"write": 1, | |||
"role": "Administrator", | |||
"cancel": 1, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"role": "Administrator", | |||
"permlevel": 1, | |||
"doctype": "DocPerm" | |||
}, | |||
{ | |||
"role": "Administrator", | |||
"permlevel": 2, | |||
"doctype": "DocPerm" | |||
}, | |||
{ | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"write": 1, | |||
"role": "System Manager", | |||
"cancel": 1, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"role": "System Manager", | |||
"permlevel": 1, | |||
"doctype": "DocPerm" | |||
}, | |||
{ | |||
"print_width": "50%", | |||
"oldfieldtype": "Column Break", | |||
"doctype": "DocField", | |||
"label": "Details", | |||
@@ -84,13 +45,13 @@ | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Small Text", | |||
"doctype": "DocField", | |||
"label": "Trash Reason", | |||
"oldfieldname": "trash_reason", | |||
"fieldname": "trash_reason", | |||
"fieldtype": "Small Text", | |||
"oldfieldtype": "Small Text", | |||
"search_index": 0, | |||
"permlevel": 1 | |||
}, | |||
{ | |||
@@ -100,7 +61,6 @@ | |||
"label": "Document", | |||
"oldfieldname": "dt", | |||
"permlevel": 0, | |||
"trigger": "Client", | |||
"fieldname": "dt", | |||
"fieldtype": "Link", | |||
"search_index": 1, | |||
@@ -110,13 +70,13 @@ | |||
}, | |||
{ | |||
"no_copy": 1, | |||
"search_index": 0, | |||
"oldfieldtype": "Data", | |||
"doctype": "DocField", | |||
"label": "Label", | |||
"oldfieldname": "label", | |||
"fieldname": "label", | |||
"fieldtype": "Data", | |||
"oldfieldtype": "Data", | |||
"search_index": 0, | |||
"reqd": 1, | |||
"permlevel": 0, | |||
"in_filter": 1 | |||
@@ -132,12 +92,10 @@ | |||
{ | |||
"no_copy": 0, | |||
"oldfieldtype": "Select", | |||
"colour": "White:FFF", | |||
"doctype": "DocField", | |||
"label": "Field Type", | |||
"oldfieldname": "fieldtype", | |||
"permlevel": 0, | |||
"trigger": "Client", | |||
"fieldname": "fieldtype", | |||
"fieldtype": "Select", | |||
"search_index": 0, | |||
@@ -155,28 +113,30 @@ | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Text", | |||
"doctype": "DocField", | |||
"label": "Options", | |||
"oldfieldname": "options", | |||
"fieldname": "options", | |||
"fieldtype": "Text", | |||
"oldfieldtype": "Text", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"print_width": "300px", | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Text", | |||
"doctype": "DocField", | |||
"label": "Field Description", | |||
"oldfieldname": "description", | |||
"width": "300px", | |||
"fieldname": "description", | |||
"fieldtype": "Text", | |||
"oldfieldtype": "Text", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"print_width": "50%", | |||
"oldfieldtype": "Column Break", | |||
"doctype": "DocField", | |||
"label": "Properties", | |||
@@ -188,126 +148,169 @@ | |||
{ | |||
"description": "Select the label after which you want to insert new field.", | |||
"no_copy": 1, | |||
"search_index": 0, | |||
"colour": "White:FFF", | |||
"oldfieldtype": "Select", | |||
"doctype": "DocField", | |||
"label": "Insert After", | |||
"oldfieldname": "insert_after", | |||
"trigger": "Client", | |||
"fieldname": "insert_after", | |||
"fieldtype": "Select", | |||
"oldfieldtype": "Select", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Text", | |||
"doctype": "DocField", | |||
"label": "Default Value", | |||
"oldfieldname": "default", | |||
"fieldname": "default", | |||
"fieldtype": "Text", | |||
"oldfieldtype": "Text", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"no_copy": 1, | |||
"search_index": 0, | |||
"oldfieldtype": "Data", | |||
"doctype": "DocField", | |||
"label": "Fieldname", | |||
"oldfieldname": "fieldname", | |||
"fieldname": "fieldname", | |||
"fieldtype": "Data", | |||
"oldfieldtype": "Data", | |||
"search_index": 0, | |||
"permlevel": 2 | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Data", | |||
"doctype": "DocField", | |||
"label": "Width", | |||
"oldfieldname": "width", | |||
"fieldname": "width", | |||
"fieldtype": "Data", | |||
"oldfieldtype": "Data", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Is Mandatory Field", | |||
"oldfieldname": "reqd", | |||
"fieldname": "reqd", | |||
"fieldtype": "Check", | |||
"oldfieldtype": "Check", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "In Report Filter", | |||
"oldfieldname": "in_filter", | |||
"fieldname": "in_filter", | |||
"fieldtype": "Check", | |||
"oldfieldtype": "Check", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "No Copy", | |||
"oldfieldname": "no_copy", | |||
"fieldname": "no_copy", | |||
"fieldtype": "Check", | |||
"oldfieldtype": "Check", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "Read Only", | |||
"fieldname": "read_only", | |||
"fieldtype": "Check", | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "Hidden", | |||
"fieldname": "hidden", | |||
"fieldtype": "Check", | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Print Hide", | |||
"oldfieldname": "print_hide", | |||
"fieldname": "print_hide", | |||
"fieldtype": "Check", | |||
"oldfieldtype": "Check", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Report Hide", | |||
"oldfieldname": "report_hide", | |||
"fieldname": "report_hide", | |||
"fieldtype": "Check", | |||
"oldfieldtype": "Check", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Allow on Submit", | |||
"oldfieldname": "allow_on_submit", | |||
"fieldname": "allow_on_submit", | |||
"fieldtype": "Check", | |||
"oldfieldtype": "Check", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"no_copy": 0, | |||
"search_index": 0, | |||
"default": "0", | |||
"oldfieldtype": "Int", | |||
"doctype": "DocField", | |||
"label": "Permission Level", | |||
"oldfieldname": "permlevel", | |||
"default": "0", | |||
"no_copy": 0, | |||
"fieldname": "permlevel", | |||
"fieldtype": "Int", | |||
"oldfieldtype": "Int", | |||
"search_index": 0, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"write": 1, | |||
"role": "Administrator", | |||
"cancel": 1, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"doctype": "DocPerm", | |||
"role": "Administrator", | |||
"permlevel": 1 | |||
}, | |||
{ | |||
"doctype": "DocPerm", | |||
"role": "Administrator", | |||
"permlevel": 2 | |||
}, | |||
{ | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"write": 1, | |||
"role": "System Manager", | |||
"cancel": 1, | |||
"permlevel": 0 | |||
}, | |||
{ | |||
"doctype": "DocPerm", | |||
"role": "System Manager", | |||
"permlevel": 1 | |||
} | |||
] |
@@ -2,9 +2,9 @@ | |||
{ | |||
"owner": "Administrator", | |||
"docstatus": 0, | |||
"creation": "2012-12-20 17:16:52", | |||
"creation": "2012-12-28 10:34:30", | |||
"modified_by": "Administrator", | |||
"modified": "2012-12-28 10:32:57" | |||
"modified": "2012-12-28 11:21:09" | |||
}, | |||
{ | |||
"istable": 1, | |||
@@ -49,6 +49,7 @@ | |||
"doctype": "DocType" | |||
}, | |||
{ | |||
"print_width": "163", | |||
"oldfieldtype": "Data", | |||
"doctype": "DocField", | |||
"label": "Label", | |||
@@ -96,6 +97,20 @@ | |||
"hidden": 0 | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Mandatory", | |||
"oldfieldname": "reqd", | |||
"width": "50px", | |||
"fieldname": "reqd", | |||
"fieldtype": "Check", | |||
"search_index": 0, | |||
"reqd": 0, | |||
"hidden": 0 | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"default": "0", | |||
"oldfieldtype": "Int", | |||
"doctype": "DocField", | |||
@@ -109,6 +124,7 @@ | |||
"hidden": 0 | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"doctype": "DocField", | |||
"label": "Read Only", | |||
"width": "50px", | |||
@@ -116,6 +132,7 @@ | |||
"fieldtype": "Check" | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"oldfieldtype": "Data", | |||
"doctype": "DocField", | |||
"label": "Width", | |||
@@ -127,18 +144,6 @@ | |||
"reqd": 0, | |||
"hidden": 0 | |||
}, | |||
{ | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Reqd", | |||
"oldfieldname": "reqd", | |||
"width": "50px", | |||
"fieldname": "reqd", | |||
"fieldtype": "Check", | |||
"search_index": 0, | |||
"reqd": 0, | |||
"hidden": 0 | |||
}, | |||
{ | |||
"oldfieldtype": "Text", | |||
"doctype": "DocField", | |||
@@ -151,6 +156,7 @@ | |||
"hidden": 0 | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Hidden", | |||
@@ -171,6 +177,7 @@ | |||
"fieldtype": "Data" | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Print Hide", | |||
@@ -189,6 +196,7 @@ | |||
"fieldtype": "Data" | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "No Copy", | |||
@@ -198,6 +206,7 @@ | |||
"fieldtype": "Check" | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Allow on Submit", | |||
@@ -207,6 +216,7 @@ | |||
"fieldtype": "Check" | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "In Filter", | |||
@@ -216,6 +226,7 @@ | |||
"fieldtype": "Check" | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Report Hide", | |||
@@ -225,6 +236,7 @@ | |||
"fieldtype": "Check" | |||
}, | |||
{ | |||
"print_width": "50px", | |||
"oldfieldtype": "Check", | |||
"doctype": "DocField", | |||
"label": "Index", | |||
@@ -237,6 +249,7 @@ | |||
"hidden": 0 | |||
}, | |||
{ | |||
"print_width": "300px", | |||
"oldfieldtype": "Text", | |||
"doctype": "DocField", | |||
"label": "Description", | |||
@@ -0,0 +1,20 @@ | |||
wn.provide("wn.core") | |||
wn.core.Workflow = wn.ui.form.Controller.extend({ | |||
refresh: function(doc) { | |||
this.frm.set_intro(""); | |||
if(doc.is_custom=="No" && !in_list(user_roles, 'Administrator')) { | |||
// make the document read-only | |||
this.frm.perm[0][WRITE] = 0; | |||
this.frm.set_intro('Standard Workflow editable by Administrator only. \ | |||
To edit workflow, copy this and create a new Custom workflow for this Document Type') | |||
} else { | |||
if(doc.is_active) { | |||
this.frm.set_intro("This Workflow is active."); | |||
} | |||
} | |||
} | |||
}); | |||
cur_frm.cscript = new wn.core.Workflow({frm:cur_frm}); |
@@ -0,0 +1,59 @@ | |||
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) | |||
# | |||
# MIT License (MIT) | |||
# | |||
# Permission is hereby granted, free of charge, to any person obtaining a | |||
# copy of this software and associated documentation files (the "Software"), | |||
# to deal in the Software without restriction, including without limitation | |||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
# and/or sell copies of the Software, and to permit persons to whom the | |||
# Software is furnished to do so, subject to the following conditions: | |||
# | |||
# The above copyright notice and this permission notice shall be included in | |||
# all copies or substantial portions of the Software. | |||
# | |||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
from __future__ import unicode_literals | |||
import webnotes | |||
class DocType: | |||
def __init__(self, d, dl): | |||
self.doc, self.doclist = d, dl | |||
def validate(self): | |||
self.set_active() | |||
self.create_custom_field_for_workflow_state() | |||
def create_custom_field_for_workflow_state(self): | |||
doctypeobj = webnotes.get_doctype(self.doc.document_type) | |||
if not doctypeobj.get({"doctype":"DocField", | |||
"fieldname":self.doc.workflow_state_field}): | |||
# create custom field | |||
webnotes.model_wrapper([{ | |||
"doctype":"Custom Field", | |||
"dt": self.doc.document_type, | |||
"__islocal": 1, | |||
"fieldname": self.doc.workflow_state_field, | |||
"label": self.doc.workflow_state_field.replace("_", " ").title(), | |||
"hidden": 1, | |||
"fieldtype": "Link", | |||
"options": "Workflow State", | |||
"insert_after": doctypeobj.get({"doctype":"DocField"})[-1].label | |||
}]).save() | |||
webnotes.msgprint("Created Custom Field '%s' in '%s'" % (self.doc.workflow_state_field, | |||
self.doc.document_type)) | |||
def set_active(self): | |||
if int(self.doc.is_active or 0): | |||
# clear all other | |||
webnotes.conn.sql("""update tabWorkflow set is_active=0 | |||
where document_type=%s""", | |||
self.doc.document_type) |
@@ -0,0 +1,109 @@ | |||
[ | |||
{ | |||
"owner": "Administrator", | |||
"docstatus": 0, | |||
"creation": "2012-12-28 10:49:55", | |||
"modified_by": "Administrator", | |||
"modified": "2012-12-28 11:26:45" | |||
}, | |||
{ | |||
"autoname": "field:workflow_name", | |||
"description": "Defines workflow states and rules for a document.", | |||
"doctype": "DocType", | |||
"module": "Core", | |||
"document_type": "Transaction", | |||
"name": "__common__" | |||
}, | |||
{ | |||
"name": "__common__", | |||
"parent": "Workflow", | |||
"doctype": "DocField", | |||
"parenttype": "DocType", | |||
"permlevel": 0, | |||
"parentfield": "fields" | |||
}, | |||
{ | |||
"parent": "Workflow", | |||
"read": 1, | |||
"cancel": 1, | |||
"name": "__common__", | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"write": 1, | |||
"parenttype": "DocType", | |||
"role": "System Manager", | |||
"permlevel": 0, | |||
"parentfield": "permissions" | |||
}, | |||
{ | |||
"name": "Workflow", | |||
"doctype": "DocType" | |||
}, | |||
{ | |||
"read_only": 0, | |||
"doctype": "DocField", | |||
"label": "Workflow Name", | |||
"fieldname": "workflow_name", | |||
"fieldtype": "Data", | |||
"reqd": 1 | |||
}, | |||
{ | |||
"description": "DocType on which this Workflow is applicable.", | |||
"doctype": "DocField", | |||
"label": "Document Type", | |||
"fieldname": "document_type", | |||
"fieldtype": "Link", | |||
"reqd": 1, | |||
"options": "DocType" | |||
}, | |||
{ | |||
"description": "If checked, all other workflows become inactive.", | |||
"doctype": "DocField", | |||
"label": "Is Active", | |||
"fieldname": "is_active", | |||
"fieldtype": "Check" | |||
}, | |||
{ | |||
"description": "Different \"States\" this document can exist in. Like \"Open\", \"Pending Approval\" etc.", | |||
"doctype": "DocField", | |||
"label": "States", | |||
"fieldname": "states", | |||
"fieldtype": "Section Break" | |||
}, | |||
{ | |||
"description": "All possible Workflow States and roles of the workflow. <br>Docstatus Options: 0 is\"Saved\", 1 is \"Submitted\" and 2 is \"Cancelled\"", | |||
"doctype": "DocField", | |||
"label": "Workflow Document States", | |||
"fieldname": "workflow_document_states", | |||
"fieldtype": "Table", | |||
"reqd": 1, | |||
"options": "Workflow Document State" | |||
}, | |||
{ | |||
"description": "Rules for how states are transitions, like next state and which role is allowed to change state etc.", | |||
"doctype": "DocField", | |||
"label": "Transition Rules", | |||
"fieldname": "transition_rules", | |||
"fieldtype": "Section Break" | |||
}, | |||
{ | |||
"description": "Rules defining transition of state in the workflow.", | |||
"doctype": "DocField", | |||
"label": "Workflow Transitions", | |||
"fieldname": "workflow_transitions", | |||
"fieldtype": "Table", | |||
"reqd": 1, | |||
"options": "Workflow Transition" | |||
}, | |||
{ | |||
"description": "Field that represents the Workflow State of the transaction (if field is not present, a new hidden Custom Field will be created)", | |||
"default": "workflow_state", | |||
"doctype": "DocField", | |||
"label": "Workflow State Field", | |||
"fieldname": "workflow_state_field", | |||
"fieldtype": "Data" | |||
}, | |||
{ | |||
"doctype": "DocPerm" | |||
} | |||
] |
@@ -0,0 +1,27 @@ | |||
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) | |||
# | |||
# MIT License (MIT) | |||
# | |||
# Permission is hereby granted, free of charge, to any person obtaining a | |||
# copy of this software and associated documentation files (the "Software"), | |||
# to deal in the Software without restriction, including without limitation | |||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
# and/or sell copies of the Software, and to permit persons to whom the | |||
# Software is furnished to do so, subject to the following conditions: | |||
# | |||
# The above copyright notice and this permission notice shall be included in | |||
# all copies or substantial portions of the Software. | |||
# | |||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
from __future__ import unicode_literals | |||
import webnotes | |||
class DocType: | |||
def __init__(self, d, dl): | |||
self.doc, self.doclist = d, dl |
@@ -0,0 +1,51 @@ | |||
[ | |||
{ | |||
"owner": "Administrator", | |||
"docstatus": 0, | |||
"creation": "2012-12-28 10:49:56", | |||
"modified_by": "Administrator", | |||
"modified": "2012-12-28 11:34:48" | |||
}, | |||
{ | |||
"autoname": "field:workflow_action_name", | |||
"description": "Workflow Action Master", | |||
"doctype": "DocType", | |||
"module": "Core", | |||
"name": "__common__" | |||
}, | |||
{ | |||
"parent": "Workflow Action", | |||
"doctype": "DocField", | |||
"reqd": 1, | |||
"name": "__common__", | |||
"label": "Workflow Action Name", | |||
"parenttype": "DocType", | |||
"fieldname": "workflow_action_name", | |||
"fieldtype": "Data", | |||
"permlevel": 0, | |||
"parentfield": "fields" | |||
}, | |||
{ | |||
"parent": "Workflow Action", | |||
"read": 1, | |||
"cancel": 1, | |||
"name": "__common__", | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"write": 1, | |||
"parenttype": "DocType", | |||
"role": "System Manager", | |||
"permlevel": 0, | |||
"parentfield": "permissions" | |||
}, | |||
{ | |||
"name": "Workflow Action", | |||
"doctype": "DocType" | |||
}, | |||
{ | |||
"doctype": "DocField" | |||
}, | |||
{ | |||
"doctype": "DocPerm" | |||
} | |||
] |
@@ -0,0 +1,27 @@ | |||
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) | |||
# | |||
# MIT License (MIT) | |||
# | |||
# Permission is hereby granted, free of charge, to any person obtaining a | |||
# copy of this software and associated documentation files (the "Software"), | |||
# to deal in the Software without restriction, including without limitation | |||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
# and/or sell copies of the Software, and to permit persons to whom the | |||
# Software is furnished to do so, subject to the following conditions: | |||
# | |||
# The above copyright notice and this permission notice shall be included in | |||
# all copies or substantial portions of the Software. | |||
# | |||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
from __future__ import unicode_literals | |||
import webnotes | |||
class DocType: | |||
def __init__(self, d, dl): | |||
self.doc, self.doclist = d, dl |
@@ -0,0 +1,60 @@ | |||
[ | |||
{ | |||
"owner": "Administrator", | |||
"docstatus": 0, | |||
"creation": "2012-12-28 10:49:56", | |||
"modified_by": "Administrator", | |||
"modified": "2012-12-28 11:37:31" | |||
}, | |||
{ | |||
"istable": 1, | |||
"description": "Represents the states allowed in one document and role assigned to change the state.", | |||
"doctype": "DocType", | |||
"module": "Core", | |||
"document_type": "Master", | |||
"name": "__common__" | |||
}, | |||
{ | |||
"name": "__common__", | |||
"parent": "Workflow Document State", | |||
"doctype": "DocField", | |||
"width": "200px", | |||
"parenttype": "DocType", | |||
"permlevel": 0, | |||
"parentfield": "fields" | |||
}, | |||
{ | |||
"name": "Workflow Document State", | |||
"doctype": "DocType" | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "State", | |||
"fieldname": "state", | |||
"fieldtype": "Link", | |||
"reqd": 1, | |||
"options": "Workflow State" | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "Allow Edit", | |||
"fieldname": "allow_edit", | |||
"fieldtype": "Link", | |||
"reqd": 0, | |||
"options": "Role" | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "Doc Status", | |||
"fieldname": "doc_status", | |||
"fieldtype": "Select", | |||
"options": "0\n1\n2" | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "Message", | |||
"fieldname": "message", | |||
"fieldtype": "Text", | |||
"reqd": 0 | |||
} | |||
] |
@@ -0,0 +1,27 @@ | |||
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) | |||
# | |||
# MIT License (MIT) | |||
# | |||
# Permission is hereby granted, free of charge, to any person obtaining a | |||
# copy of this software and associated documentation files (the "Software"), | |||
# to deal in the Software without restriction, including without limitation | |||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
# and/or sell copies of the Software, and to permit persons to whom the | |||
# Software is furnished to do so, subject to the following conditions: | |||
# | |||
# The above copyright notice and this permission notice shall be included in | |||
# all copies or substantial portions of the Software. | |||
# | |||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
from __future__ import unicode_literals | |||
import webnotes | |||
class DocType: | |||
def __init__(self, d, dl): | |||
self.doc, self.doclist = d, dl |
@@ -0,0 +1,70 @@ | |||
[ | |||
{ | |||
"owner": "Administrator", | |||
"docstatus": 0, | |||
"creation": "2012-12-28 10:49:56", | |||
"modified_by": "Administrator", | |||
"modified": "2012-12-28 11:30:26" | |||
}, | |||
{ | |||
"autoname": "field:workflow_state_name", | |||
"description": "Workflow state represents the current state of a document.", | |||
"doctype": "DocType", | |||
"module": "Core", | |||
"document_type": "Master", | |||
"name": "__common__" | |||
}, | |||
{ | |||
"name": "__common__", | |||
"parent": "Workflow State", | |||
"doctype": "DocField", | |||
"parenttype": "DocType", | |||
"permlevel": 0, | |||
"parentfield": "fields" | |||
}, | |||
{ | |||
"parent": "Workflow State", | |||
"read": 1, | |||
"cancel": 1, | |||
"name": "__common__", | |||
"create": 1, | |||
"doctype": "DocPerm", | |||
"write": 1, | |||
"parenttype": "DocType", | |||
"role": "System Manager", | |||
"permlevel": 0, | |||
"parentfield": "permissions" | |||
}, | |||
{ | |||
"name": "Workflow State", | |||
"doctype": "DocType" | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "Workflow State Name", | |||
"fieldname": "workflow_state_name", | |||
"fieldtype": "Data", | |||
"reqd": 1 | |||
}, | |||
{ | |||
"description": "Icon will appear on the button", | |||
"doctype": "DocField", | |||
"label": "Icon", | |||
"fieldname": "icon", | |||
"fieldtype": "Select", | |||
"reqd": 0, | |||
"options": "\nglass\nmusic\nsearch\nenvelope\nheart\nstar\nstar-empty\nuser\nfilm\nth-large\nth\nth-list\nok\nremove\nzoom-in\nzoom-out\noff\nsignal\ncog\ntrash\nhome\nfile\ntime\nroad\ndownload-alt\ndownload\nupload\ninbox\nplay-circle\nrepeat\nrefresh\nlist-alt\nlock\nflag\nheadphones\nvolume-off\nvolume-down\nvolume-up\nqrcode\nbarcode\ntag\ntags\nbook\nbookmark\nprint\ncamera\nfont\nbold\nitalic\ntext-height\ntext-width\nalign-left\nalign-center\nalign-right\nalign-justify\nlist\nindent-left\nindent-right\nfacetime-video\npicture\npencil\nmap-marker\nadjust\ntint\nedit\nshare\ncheck\nmove\nstep-backward\nfast-backward\nbackward\nplay\npause\nstop\nforward\nfast-forward\nstep-forward\neject\nchevron-left\nchevron-right\nplus-sign\nminus-sign\nremove-sign\nok-sign\nquestion-sign\ninfo-sign\nscreenshot\nremove-circle\nok-circle\nban-circle\narrow-left\narrow-right\narrow-up\narrow-down\nshare-alt\nresize-full\nresize-small\nplus\nminus\nasterisk\nexclamation-sign\ngift\nleaf\nfire\neye-open\neye-close\nwarning-sign\nplane\ncalendar\nrandom\ncomment\nmagnet\nchevron-up\nchevron-down\nretweet\nshopping-cart\nfolder-close\nfolder-open\nresize-vertical\nresize-horizontal\nhdd\nbullhorn\nbell\ncertificate\nthumbs-up\nthumbs-down\nhand-right\nhand-left\nhand-up\nhand-down\ncircle-arrow-right\ncircle-arrow-left\ncircle-arrow-up\ncircle-arrow-down\nglobe\nwrench\ntasks\nfilter\nbriefcase\nfullscreen" | |||
}, | |||
{ | |||
"description": "Style represents the button color: Success - Green, Danger - Red, Inverse - Black, Primary - Dark Blue, Info - Light Blue, Warning - Orange", | |||
"doctype": "DocField", | |||
"label": "Style", | |||
"fieldname": "style", | |||
"fieldtype": "Select", | |||
"reqd": 0, | |||
"options": "\nPrimary\nInfo\nSuccess\nWarning\nDanger\nInverse" | |||
}, | |||
{ | |||
"doctype": "DocPerm" | |||
} | |||
] |
@@ -0,0 +1,27 @@ | |||
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) | |||
# | |||
# MIT License (MIT) | |||
# | |||
# Permission is hereby granted, free of charge, to any person obtaining a | |||
# copy of this software and associated documentation files (the "Software"), | |||
# to deal in the Software without restriction, including without limitation | |||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
# and/or sell copies of the Software, and to permit persons to whom the | |||
# Software is furnished to do so, subject to the following conditions: | |||
# | |||
# The above copyright notice and this permission notice shall be included in | |||
# all copies or substantial portions of the Software. | |||
# | |||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
from __future__ import unicode_literals | |||
import webnotes | |||
class DocType: | |||
def __init__(self, d, dl): | |||
self.doc, self.doclist = d, dl |
@@ -0,0 +1,55 @@ | |||
[ | |||
{ | |||
"owner": "Administrator", | |||
"docstatus": 0, | |||
"creation": "2012-12-28 10:49:56", | |||
"modified_by": "Administrator", | |||
"modified": "2012-12-28 11:25:03" | |||
}, | |||
{ | |||
"istable": 1, | |||
"description": "Defines actions on states and the next step and allowed roles.", | |||
"doctype": "DocType", | |||
"module": "Core", | |||
"name": "__common__" | |||
}, | |||
{ | |||
"name": "__common__", | |||
"parent": "Workflow Transition", | |||
"doctype": "DocField", | |||
"width": "200px", | |||
"parenttype": "DocType", | |||
"fieldtype": "Link", | |||
"reqd": 1, | |||
"permlevel": 0, | |||
"parentfield": "fields" | |||
}, | |||
{ | |||
"name": "Workflow Transition", | |||
"doctype": "DocType" | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "State", | |||
"fieldname": "state", | |||
"options": "Workflow State" | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "Action", | |||
"fieldname": "action", | |||
"options": "Workflow Action" | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "Next State", | |||
"fieldname": "next_state", | |||
"options": "Workflow State" | |||
}, | |||
{ | |||
"doctype": "DocField", | |||
"label": "Allowed", | |||
"fieldname": "allowed", | |||
"options": "Role" | |||
} | |||
] |
@@ -109,7 +109,7 @@ div.grid_tbarlinks { | |||
border: 3px solid #abf; | |||
height:200px; | |||
width: 300px; | |||
z-index: 10; | |||
z-index: 1; | |||
position:absolute; | |||
} | |||
@@ -37,13 +37,11 @@ def save(doclist): | |||
"""insert or update from form query""" | |||
if isinstance(doclist, basestring): | |||
doclist = json.loads(doclist) | |||
from webnotes.model.wrapper import ModelWrapper | |||
if not webnotes.has_permission(doclist[0]["doctype"], "write"): | |||
webnotes.msgprint("No Write Permission", raise_exception=True) | |||
doclistobj = ModelWrapper(doclist) | |||
doclistobj = webnotes.model_wrapper(doclist) | |||
doclistobj.save() | |||
return [d.fields for d in doclist] | |||
@@ -66,7 +66,7 @@ def get(doctype, processed=False, cached=True): | |||
add_print_formats(doclist) | |||
add_search_fields(doclist) | |||
add_linked_with(doclist) | |||
#add_workflows(doclist) | |||
add_workflows(doclist) | |||
#update_language(doclist) | |||
# add validators | |||
@@ -0,0 +1,49 @@ | |||
# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) | |||
# | |||
# MIT License (MIT) | |||
# | |||
# Permission is hereby granted, free of charge, to any person obtaining a | |||
# copy of this software and associated documentation files (the "Software"), | |||
# to deal in the Software without restriction, including without limitation | |||
# the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
# and/or sell copies of the Software, and to permit persons to whom the | |||
# Software is furnished to do so, subject to the following conditions: | |||
# | |||
# The above copyright notice and this permission notice shall be included in | |||
# all copies or substantial portions of the Software. | |||
# | |||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | |||
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | |||
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | |||
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
# | |||
from __future__ import unicode_literals | |||
import webnotes | |||
workflow_names = {} | |||
def get_workflow_name(doctype): | |||
global workflow_names | |||
if not doctype in workflow_names: | |||
workflow_name = webnotes.conn.get_value("Workflow", {"document_type": doctype, | |||
"is_active": "1"}, "name") | |||
# no active? get default workflow | |||
if not workflow_name: | |||
workflow_name = webnotes.conn.get_value("Workflow", {"document_type": doctype, | |||
"is_custom": "No"}, "name") | |||
workflow_names[doctype] = workflow_name | |||
return workflow_names[doctype] | |||
def get_default_state(doctype): | |||
workflow_name = get_workflow_name(doctype) | |||
return webnotes.conn.get_value("Workflow Document State", {"parent":doctype, | |||
"idx":1}, "state") | |||
def get_state_fieldname(doctype): | |||
workflow_name = get_workflow_name(doctype) | |||
return webnotes.conn.get_value("Workflow", workflow_name, "workflow_state_field") |
@@ -87,6 +87,9 @@ def load_single_doc(dt, dn, user): | |||
if not dn: dn = dt | |||
if not webnotes.conn.exists(dt, dn): | |||
return None | |||
try: | |||
dl = webnotes.model_wrapper(dt, dn).doclist | |||
except Exception, e: | |||