fix for get_obj for custom doctypes
This commit is contained in:
parent
33d4621d0b
commit
2aea93e8f2
2 changed files with 106 additions and 79 deletions
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:34',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-11 16:15:21',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
u'creation': '2012-07-12 22:19:54',
|
||||
u'docstatus': 0,
|
||||
u'modified': '2012-10-15 17:42:42',
|
||||
u'modified_by': u'Administrator',
|
||||
u'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
|
|
@ -19,13 +19,13 @@
|
|||
'autoname': u'Prompt',
|
||||
'colour': u'White:FFF',
|
||||
'description': u'The basic building block of wnframework is a **DocType**. A DocType represents both a table in the database and a form from which a user can enter data. Actions are also embedded in the DocType. Hence it is the Model, View and Controller.\n\nDocTypes can be single tables or groups. For example, Quotation has a \u201cQuotation\u201d DocType and a \u201cQuotation Item\u201d doctype for the Items table, among others. DocTypes contain a collection of fields called DocFields that form the basis of the columns in the database and the layout of the form.',
|
||||
'doctype': 'DocType',
|
||||
u'doctype': u'DocType',
|
||||
'hide_heading': 0,
|
||||
'hide_toolbar': 0,
|
||||
'issingle': 0,
|
||||
'istable': 0,
|
||||
'module': u'Core',
|
||||
'name': '__common__',
|
||||
u'name': u'__common__',
|
||||
'print_outline': u'Yes',
|
||||
'read_only': 0,
|
||||
'search_fields': u'autoname',
|
||||
|
|
@ -37,8 +37,8 @@
|
|||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
u'doctype': u'DocField',
|
||||
u'name': u'__common__',
|
||||
'parent': u'DocType',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
|
|
@ -47,8 +47,8 @@
|
|||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
u'doctype': u'DocPerm',
|
||||
u'name': u'__common__',
|
||||
'parent': u'DocType',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
|
|
@ -57,39 +57,13 @@
|
|||
|
||||
# DocType, DocType
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'DocType'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'execute': 0,
|
||||
'permlevel': 0,
|
||||
'role': u'Administrator',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Administrator'
|
||||
u'doctype': u'DocType',
|
||||
u'name': u'DocType'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'sb0',
|
||||
'fieldtype': u'Section Break',
|
||||
'hidden': 0,
|
||||
|
|
@ -101,7 +75,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'module',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Module',
|
||||
|
|
@ -113,14 +87,14 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'cb01',
|
||||
'fieldtype': u'Column Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'document_type',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Document Type',
|
||||
|
|
@ -131,14 +105,25 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Is it a Custom DocType created by you?',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'custom',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Custom?',
|
||||
'no_copy': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'sb0_5',
|
||||
'fieldtype': u'Section Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 0,
|
||||
|
|
@ -152,7 +137,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'fields_section_break',
|
||||
'fieldtype': u'Section Break',
|
||||
'hidden': 0,
|
||||
|
|
@ -164,7 +149,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'fields',
|
||||
'fieldtype': u'Table',
|
||||
'hidden': 0,
|
||||
|
|
@ -178,14 +163,14 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'sb1',
|
||||
'fieldtype': u'Section Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'cb10',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Database'
|
||||
|
|
@ -193,7 +178,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'issingle',
|
||||
'fieldtype': u'Check',
|
||||
'hidden': 0,
|
||||
|
|
@ -207,7 +192,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'istable',
|
||||
'fieldtype': u'Check',
|
||||
'hidden': 0,
|
||||
|
|
@ -220,7 +205,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'cb11',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Naming',
|
||||
|
|
@ -230,7 +215,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'autoname',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 0,
|
||||
|
|
@ -243,7 +228,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'name_case',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Name Case',
|
||||
|
|
@ -254,7 +239,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'search_fields',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 0,
|
||||
|
|
@ -267,7 +252,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'sb2',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Permission Rules'
|
||||
|
|
@ -276,7 +261,7 @@
|
|||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'permissions',
|
||||
'fieldtype': u'Table',
|
||||
'hidden': 0,
|
||||
|
|
@ -290,14 +275,14 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'sb3',
|
||||
'fieldtype': u'Section Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'cb30',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Permissions Settings'
|
||||
|
|
@ -305,7 +290,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'in_create',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'User Cannot Create',
|
||||
|
|
@ -315,7 +300,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'read_only',
|
||||
'fieldtype': u'Check',
|
||||
'hidden': 0,
|
||||
|
|
@ -328,7 +313,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'is_submittable',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Is Submittable'
|
||||
|
|
@ -336,7 +321,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'allow_rename',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Allow Rename',
|
||||
|
|
@ -346,7 +331,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'cb31',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Hide Actions'
|
||||
|
|
@ -354,7 +339,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'hide_heading',
|
||||
'fieldtype': u'Check',
|
||||
'hidden': 0,
|
||||
|
|
@ -367,7 +352,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'hide_toolbar',
|
||||
'fieldtype': u'Check',
|
||||
'hidden': 0,
|
||||
|
|
@ -380,7 +365,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'allow_print',
|
||||
'fieldtype': u'Check',
|
||||
'hidden': 0,
|
||||
|
|
@ -393,7 +378,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'allow_email',
|
||||
'fieldtype': u'Check',
|
||||
'hidden': 0,
|
||||
|
|
@ -406,7 +391,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'allow_copy',
|
||||
'fieldtype': u'Check',
|
||||
'hidden': 0,
|
||||
|
|
@ -419,7 +404,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'sb4',
|
||||
'fieldtype': u'Section Break',
|
||||
'hidden': 0,
|
||||
|
|
@ -431,7 +416,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'cb41',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Display'
|
||||
|
|
@ -439,7 +424,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'default_print_format',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Default Print Format'
|
||||
|
|
@ -447,7 +432,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'read_only_onload',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Show Print First',
|
||||
|
|
@ -457,7 +442,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'in_dialog',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'In Dialog',
|
||||
|
|
@ -467,7 +452,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'cb42',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Attachments'
|
||||
|
|
@ -475,7 +460,7 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'allow_attach',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Allow Attach',
|
||||
|
|
@ -486,12 +471,44 @@
|
|||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'max_attachments',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'label': u'Max Attachments',
|
||||
'oldfieldname': u'max_attachments',
|
||||
'oldfieldtype': u'Int'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
u'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
u'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 1,
|
||||
u'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Administrator',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
u'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Administrator'
|
||||
}
|
||||
]
|
||||
|
|
@ -130,8 +130,18 @@ def get_server_obj(doc, doclist = [], basedoctype = ''):
|
|||
module = scrub(module)
|
||||
dt = scrub(doc.doctype)
|
||||
|
||||
module = __import__('%s.doctype.%s.%s' % (module, dt, dt), fromlist=[''])
|
||||
DocType = getattr(module, 'DocType')
|
||||
try:
|
||||
module = __import__('%s.doctype.%s.%s' % (module, dt, dt), fromlist=[''])
|
||||
DocType = getattr(module, 'DocType')
|
||||
except ImportError, e:
|
||||
from webnotes.utils import cint
|
||||
if not cint(webnotes.conn.get_value("DocType", doc.doctype, "custom")):
|
||||
raise e
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
|
||||
# custom?
|
||||
custom_script = get_custom_script(doc.doctype, 'Server')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue