瀏覽代碼

Merge branch 'master' of github.com:webnotes/wnframework

version-14
Rushabh Mehta 14 年之前
父節點
當前提交
12e2c95531
共有 10 個檔案被更改,包括 147 行新增178 行删除
  1. +3
    -2
      js/legacy/form.compressed.js
  2. +5
    -0
      js/legacy/widgets/form/form.js
  3. +1
    -1
      js/legacy/widgets/form/grid.js
  4. +14
    -62
      py/core/doctype/doctype/doctype.txt
  5. +103
    -100
      py/core/doctype/doctype_mapper/doctype_mapper.py
  6. +4
    -0
      py/webnotes/modules/patch.py
  7. +2
    -2
      py/webnotes/profile.py
  8. +8
    -9
      py/webnotes/utils/email_lib/__init__.py
  9. +2
    -1
      py/webnotes/utils/email_lib/html2text.py
  10. +5
    -1
      py/webnotes/utils/email_lib/send.py

+ 3
- 2
js/legacy/form.compressed.js 查看文件

@@ -61,7 +61,8 @@ this.setup_footer();if(!(this.meta.istable||user=='Guest'))this.frm_head=new _f.
this.layout.wrapper.style.backgroundColor='#'+this.meta.colour.split(':')[1];this.setup_fields_std();} this.layout.wrapper.style.backgroundColor='#'+this.meta.colour.split(':')[1];this.setup_fields_std();}
_f.Frm.prototype.setup_print=function(){var fl=getchildren('DocFormat',this.meta.name,'formats','DocType');var l=[];this.default_format='Standard';if(fl.length){this.default_format=fl[0].format;for(var i=0;i<fl.length;i++) _f.Frm.prototype.setup_print=function(){var fl=getchildren('DocFormat',this.meta.name,'formats','DocType');var l=[];this.default_format='Standard';if(fl.length){this.default_format=fl[0].format;for(var i=0;i<fl.length;i++)
l.push(fl[i].format);} l.push(fl[i].format);}
l.push('Standard');this.print_sel=$a(null,'select','',{width:'160px'});add_sel_options(this.print_sel,l);this.print_sel.value=this.default_format;}
if(this.meta.default_print_format)
this.default_format=this.meta.default_print_format;l.push('Standard');this.print_sel=$a(null,'select','',{width:'160px'});add_sel_options(this.print_sel,l);this.print_sel.value=this.default_format;}
_f.Frm.prototype.print_doc=function(){if(this.doc.docstatus==2){msgprint("Cannot Print Cancelled Documents.");return;} _f.Frm.prototype.print_doc=function(){if(this.doc.docstatus==2){msgprint("Cannot Print Cancelled Documents.");return;}
_p.show_dialog();} _p.show_dialog();}
_f.Frm.prototype.email_doc=function(){if(!_e.dialog)_e.make();sel=this.print_sel;var c=$td(_e.dialog.rows['Format'].tab,0,1);if(c.cur_sel){c.removeChild(c.cur_sel);c.cur_sel=null;} _f.Frm.prototype.email_doc=function(){if(!_e.dialog)_e.make();sel=this.print_sel;var c=$td(_e.dialog.rows['Format'].tab,0,1);if(c.cur_sel){c.removeChild(c.cur_sel);c.cur_sel=null;}
@@ -263,7 +264,7 @@ _f.Grid.prototype.make_ui=function(parent){var ht=make_table($a(parent,'div'),1,
_f.Grid.prototype.show=function(){if(this.can_add_rows){$ds(this.tbar_div);}else{$dh(this.tbar_div);} _f.Grid.prototype.show=function(){if(this.can_add_rows){$ds(this.tbar_div);}else{$dh(this.tbar_div);}
$ds(this.wrapper);} $ds(this.wrapper);}
_f.Grid.prototype.hide=function(){$dh(this.wrapper);$dh(this.tbar_div);} _f.Grid.prototype.hide=function(){$dh(this.wrapper);$dh(this.tbar_div);}
_f.Grid.prototype.insert_column=function(doctype,fieldname,fieldtype,label,width,options,perm,reqd){var idx=this.head_row.cells.length;if(!width)width='140px';if((width+'').slice(-2)!='px'){width=width+'px';}
_f.Grid.prototype.insert_column=function(doctype,fieldname,fieldtype,label,width,options,perm,reqd){var idx=this.head_row.cells.length;if(!width)width='100px';if((width+'').slice(-2)!='px'){width=width+'px';}
var col=this.head_row.insertCell(idx);col.doctype=doctype;col.fieldname=fieldname;col.fieldtype=fieldtype;col.innerHTML='<div>'+label+'</div>';col.label=label;if(reqd) var col=this.head_row.insertCell(idx);col.doctype=doctype;col.fieldname=fieldname;col.fieldtype=fieldtype;col.innerHTML='<div>'+label+'</div>';col.label=label;if(reqd)
col.childNodes[0].style.color="#D22";col.style.width=width;col.options=options;col.perm=perm;this.col_idx_by_name[fieldname]=idx;} col.childNodes[0].style.color="#D22";col.style.width=width;col.options=options;col.perm=perm;this.col_idx_by_name[fieldname]=idx;}
_f.Grid.prototype.reset_table_width=function(){var w=0;for(var i=0,len=this.head_row.cells.length;i<len;i++){w+=cint(this.head_row.cells[i].style.width);} _f.Grid.prototype.reset_table_width=function(){var w=0;for(var i=0,len=this.head_row.cells.length;i<len;i++){w+=cint(this.head_row.cells[i].style.width);}


+ 5
- 0
js/legacy/widgets/form/form.js 查看文件

@@ -176,6 +176,11 @@ _f.Frm.prototype.setup_print = function() {
l.push(fl[i].format); l.push(fl[i].format);
} }

// if default print format is given, use it
if(this.meta.default_print_format)
this.default_format = this.meta.default_print_format;

l.push('Standard'); l.push('Standard');
this.print_sel = $a(null, 'select', '', {width:'160px'}); this.print_sel = $a(null, 'select', '', {width:'160px'});
add_sel_options(this.print_sel, l); add_sel_options(this.print_sel, l);


+ 1
- 1
js/legacy/widgets/form/grid.js 查看文件

@@ -62,7 +62,7 @@ _f.Grid.prototype.hide = function() {
_f.Grid.prototype.insert_column = function(doctype, fieldname, fieldtype, label, width, options, perm, reqd) { _f.Grid.prototype.insert_column = function(doctype, fieldname, fieldtype, label, width, options, perm, reqd) {
var idx = this.head_row.cells.length; var idx = this.head_row.cells.length;
if(!width)width = '140px';
if(!width)width = '100px';
if((width+'').slice(-2)!='px') { if((width+'').slice(-2)!='px') {
width= width + 'px'; width= width + 'px';
} }


+ 14
- 62
py/core/doctype/doctype/doctype.txt 查看文件

@@ -5,14 +5,14 @@
{ {
'creation': '2009-05-12 11:19:11', 'creation': '2009-05-12 11:19:11',
'docstatus': 0, 'docstatus': 0,
'modified': '2011-05-16 10:19:14',
'modified': '2011-09-07 15:28:18',
'modified_by': 'Administrator', 'modified_by': 'Administrator',
'owner': 'Administrator' 'owner': 'Administrator'
}, },


# These values are common for all DocType # These values are common for all DocType
{ {
'_last_update': '1307624201',
'_last_update': '1311674341',
'allow_copy': 0, 'allow_copy': 0,
'allow_email': 0, 'allow_email': 0,
'allow_print': 0, 'allow_print': 0,
@@ -21,7 +21,6 @@
'doctype': 'DocType', 'doctype': 'DocType',
'hide_heading': 0, 'hide_heading': 0,
'hide_toolbar': 0, 'hide_toolbar': 0,
'idx': 0,
'issingle': 0, 'issingle': 0,
'istable': 0, 'istable': 0,
'module': 'Core', 'module': 'Core',
@@ -32,7 +31,7 @@
'section_style': 'Simple', 'section_style': 'Simple',
'server_code_error': ' ', 'server_code_error': ' ',
'show_in_menu': 0, 'show_in_menu': 0,
'version': 8
'version': 11
}, },


# These values are common for all DocField # These values are common for all DocField
@@ -52,7 +51,8 @@
'parent': 'DocType', 'parent': 'DocType',
'parentfield': 'permissions', 'parentfield': 'permissions',
'parenttype': 'DocType', 'parenttype': 'DocType',
'read': 1
'read': 1,
'role': 'Administrator'
}, },


# DocType, DocType # DocType, DocType
@@ -61,22 +61,13 @@
'name': 'DocType' 'name': 'DocType'
}, },


# DocPerm
{
'doctype': 'DocPerm',
'permlevel': 0,
'role': 'System Manager'
},

# DocPerm # DocPerm
{ {
'cancel': 0, 'cancel': 0,
'create': 1, 'create': 1,
'doctype': 'DocPerm', 'doctype': 'DocPerm',
'execute': 0, 'execute': 0,
'idx': 1,
'permlevel': 0, 'permlevel': 0,
'role': 'Administrator',
'submit': 0, 'submit': 0,
'write': 1 'write': 1
}, },
@@ -84,9 +75,7 @@
# DocPerm # DocPerm
{ {
'doctype': 'DocPerm', 'doctype': 'DocPerm',
'idx': 2,
'permlevel': 1,
'role': 'Administrator'
'permlevel': 1
}, },


# DocField # DocField
@@ -94,7 +83,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldtype': 'Section Break', 'fieldtype': 'Section Break',
'hidden': 0, 'hidden': 0,
'idx': 1,
'label': 'Options', 'label': 'Options',
'oldfieldtype': 'Section Break', 'oldfieldtype': 'Section Break',
'reqd': 0, 'reqd': 0,
@@ -105,7 +93,6 @@
{ {
'doctype': 'DocField', 'doctype': 'DocField',
'fieldtype': 'Column Break', 'fieldtype': 'Column Break',
'idx': 2,
'label': 'Settings', 'label': 'Settings',
'oldfieldtype': 'Column Break', 'oldfieldtype': 'Column Break',
'width': '50%' 'width': '50%'
@@ -116,7 +103,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'module', 'fieldname': 'module',
'fieldtype': 'Link', 'fieldtype': 'Link',
'idx': 3,
'label': 'Module', 'label': 'Module',
'oldfieldname': 'module', 'oldfieldname': 'module',
'oldfieldtype': 'Link', 'oldfieldtype': 'Link',
@@ -129,7 +115,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'version', 'fieldname': 'version',
'fieldtype': 'Int', 'fieldtype': 'Int',
'idx': 4,
'label': 'Version', 'label': 'Version',
'oldfieldname': 'version', 'oldfieldname': 'version',
'oldfieldtype': 'Int' 'oldfieldtype': 'Int'
@@ -141,7 +126,6 @@
'fieldname': 'name', 'fieldname': 'name',
'fieldtype': 'Data', 'fieldtype': 'Data',
'hidden': 1, 'hidden': 1,
'idx': 5,
'label': 'Name', 'label': 'Name',
'oldfieldname': 'name', 'oldfieldname': 'name',
'oldfieldtype': 'Data', 'oldfieldtype': 'Data',
@@ -155,7 +139,6 @@
'fieldname': 'autoname', 'fieldname': 'autoname',
'fieldtype': 'Data', 'fieldtype': 'Data',
'hidden': 0, 'hidden': 0,
'idx': 6,
'label': 'Auto Name', 'label': 'Auto Name',
'oldfieldname': 'autoname', 'oldfieldname': 'autoname',
'oldfieldtype': 'Data', 'oldfieldtype': 'Data',
@@ -169,7 +152,6 @@
'fieldname': 'owner', 'fieldname': 'owner',
'fieldtype': 'Link', 'fieldtype': 'Link',
'hidden': 1, 'hidden': 1,
'idx': 7,
'label': 'Owner', 'label': 'Owner',
'oldfieldname': 'owner', 'oldfieldname': 'owner',
'oldfieldtype': 'Link', 'oldfieldtype': 'Link',
@@ -182,7 +164,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'name_case', 'fieldname': 'name_case',
'fieldtype': 'Select', 'fieldtype': 'Select',
'idx': 8,
'label': 'Name Case', 'label': 'Name Case',
'oldfieldname': 'name_case', 'oldfieldname': 'name_case',
'oldfieldtype': 'Select', 'oldfieldtype': 'Select',
@@ -195,7 +176,6 @@
'fieldname': 'search_fields', 'fieldname': 'search_fields',
'fieldtype': 'Data', 'fieldtype': 'Data',
'hidden': 0, 'hidden': 0,
'idx': 9,
'label': 'Search Fields', 'label': 'Search Fields',
'oldfieldname': 'search_fields', 'oldfieldname': 'search_fields',
'oldfieldtype': 'Data', 'oldfieldtype': 'Data',
@@ -210,7 +190,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'subject', 'fieldname': 'subject',
'fieldtype': 'Data', 'fieldtype': 'Data',
'idx': 10,
'label': 'Subject' 'label': 'Subject'
}, },


@@ -221,7 +200,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'tag_fields', 'fieldname': 'tag_fields',
'fieldtype': 'Data', 'fieldtype': 'Data',
'idx': 11,
'label': 'tag_fields' 'label': 'tag_fields'
}, },


@@ -231,7 +209,6 @@
'fieldname': 'istable', 'fieldname': 'istable',
'fieldtype': 'Check', 'fieldtype': 'Check',
'hidden': 0, 'hidden': 0,
'idx': 12,
'label': 'Is Table', 'label': 'Is Table',
'oldfieldname': 'istable', 'oldfieldname': 'istable',
'oldfieldtype': 'Check', 'oldfieldtype': 'Check',
@@ -245,7 +222,6 @@
'fieldname': 'read_only', 'fieldname': 'read_only',
'fieldtype': 'Check', 'fieldtype': 'Check',
'hidden': 0, 'hidden': 0,
'idx': 13,
'label': 'Not In Search', 'label': 'Not In Search',
'oldfieldname': 'read_only', 'oldfieldname': 'read_only',
'oldfieldtype': 'Check', 'oldfieldtype': 'Check',
@@ -258,7 +234,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'in_create', 'fieldname': 'in_create',
'fieldtype': 'Check', 'fieldtype': 'Check',
'idx': 14,
'label': 'Not In Create', 'label': 'Not In Create',
'oldfieldname': 'in_create', 'oldfieldname': 'in_create',
'oldfieldtype': 'Check' 'oldfieldtype': 'Check'
@@ -270,7 +245,6 @@
'fieldname': 'issingle', 'fieldname': 'issingle',
'fieldtype': 'Check', 'fieldtype': 'Check',
'hidden': 0, 'hidden': 0,
'idx': 15,
'label': 'Is Single', 'label': 'Is Single',
'oldfieldname': 'issingle', 'oldfieldname': 'issingle',
'oldfieldtype': 'Check', 'oldfieldtype': 'Check',
@@ -284,7 +258,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'read_only_onload', 'fieldname': 'read_only_onload',
'fieldtype': 'Check', 'fieldtype': 'Check',
'idx': 16,
'label': 'Show Print First', 'label': 'Show Print First',
'oldfieldname': 'read_only_onload', 'oldfieldname': 'read_only_onload',
'oldfieldtype': 'Check' 'oldfieldtype': 'Check'
@@ -295,7 +268,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'show_in_menu', 'fieldname': 'show_in_menu',
'fieldtype': 'Check', 'fieldtype': 'Check',
'idx': 17,
'label': 'Show In Pages', 'label': 'Show In Pages',
'oldfieldname': 'show_in_menu', 'oldfieldname': 'show_in_menu',
'oldfieldtype': 'Check' 'oldfieldtype': 'Check'
@@ -306,7 +278,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'document_type', 'fieldname': 'document_type',
'fieldtype': 'Select', 'fieldtype': 'Select',
'idx': 18,
'label': 'Document Type', 'label': 'Document Type',
'oldfieldname': 'document_type', 'oldfieldname': 'document_type',
'oldfieldtype': 'Select', 'oldfieldtype': 'Select',
@@ -318,7 +289,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldtype': 'Column Break', 'fieldtype': 'Column Break',
'hidden': 0, 'hidden': 0,
'idx': 19,
'label': 'Display', 'label': 'Display',
'oldfieldtype': 'Column Break', 'oldfieldtype': 'Column Break',
'reqd': 0, 'reqd': 0,
@@ -331,7 +301,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'is_transaction_doc', 'fieldname': 'is_transaction_doc',
'fieldtype': 'Check', 'fieldtype': 'Check',
'idx': 20,
'label': 'Is Transaction Doc', 'label': 'Is Transaction Doc',
'oldfieldname': 'is_transaction_doc', 'oldfieldname': 'is_transaction_doc',
'oldfieldtype': 'Check' 'oldfieldtype': 'Check'
@@ -342,7 +311,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'use_template', 'fieldname': 'use_template',
'fieldtype': 'Check', 'fieldtype': 'Check',
'idx': 21,
'label': 'Use Template', 'label': 'Use Template',
'oldfieldname': 'use_template', 'oldfieldname': 'use_template',
'oldfieldtype': 'Check' 'oldfieldtype': 'Check'
@@ -354,7 +322,6 @@
'fieldname': 'print_outline', 'fieldname': 'print_outline',
'fieldtype': 'Select', 'fieldtype': 'Select',
'hidden': 0, 'hidden': 0,
'idx': 22,
'label': 'Print Outline', 'label': 'Print Outline',
'oldfieldname': 'print_outline', 'oldfieldname': 'print_outline',
'oldfieldtype': 'Select', 'oldfieldtype': 'Select',
@@ -369,7 +336,6 @@
'fieldname': 'allow_print', 'fieldname': 'allow_print',
'fieldtype': 'Check', 'fieldtype': 'Check',
'hidden': 0, 'hidden': 0,
'idx': 23,
'label': 'Hide Print', 'label': 'Hide Print',
'oldfieldname': 'allow_print', 'oldfieldname': 'allow_print',
'oldfieldtype': 'Check', 'oldfieldtype': 'Check',
@@ -383,7 +349,6 @@
'fieldname': 'allow_email', 'fieldname': 'allow_email',
'fieldtype': 'Check', 'fieldtype': 'Check',
'hidden': 0, 'hidden': 0,
'idx': 24,
'label': 'Hide Email', 'label': 'Hide Email',
'oldfieldname': 'allow_email', 'oldfieldname': 'allow_email',
'oldfieldtype': 'Check', 'oldfieldtype': 'Check',
@@ -396,7 +361,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'in_dialog', 'fieldname': 'in_dialog',
'fieldtype': 'Check', 'fieldtype': 'Check',
'idx': 25,
'label': 'In Dialog', 'label': 'In Dialog',
'oldfieldname': 'in_dialog', 'oldfieldname': 'in_dialog',
'oldfieldtype': 'Check' 'oldfieldtype': 'Check'
@@ -408,7 +372,6 @@
'fieldname': 'allow_copy', 'fieldname': 'allow_copy',
'fieldtype': 'Check', 'fieldtype': 'Check',
'hidden': 0, 'hidden': 0,
'idx': 26,
'label': 'Hide Copy', 'label': 'Hide Copy',
'oldfieldname': 'allow_copy', 'oldfieldname': 'allow_copy',
'oldfieldtype': 'Check', 'oldfieldtype': 'Check',
@@ -422,7 +385,6 @@
'fieldname': 'hide_toolbar', 'fieldname': 'hide_toolbar',
'fieldtype': 'Check', 'fieldtype': 'Check',
'hidden': 0, 'hidden': 0,
'idx': 27,
'label': 'Hide Toolbar', 'label': 'Hide Toolbar',
'oldfieldname': 'hide_toolbar', 'oldfieldname': 'hide_toolbar',
'oldfieldtype': 'Check', 'oldfieldtype': 'Check',
@@ -436,7 +398,6 @@
'fieldname': 'hide_heading', 'fieldname': 'hide_heading',
'fieldtype': 'Check', 'fieldtype': 'Check',
'hidden': 0, 'hidden': 0,
'idx': 28,
'label': 'Hide Heading', 'label': 'Hide Heading',
'oldfieldname': 'hide_heading', 'oldfieldname': 'hide_heading',
'oldfieldtype': 'Check', 'oldfieldtype': 'Check',
@@ -449,7 +410,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'allow_attach', 'fieldname': 'allow_attach',
'fieldtype': 'Check', 'fieldtype': 'Check',
'idx': 29,
'label': 'Allow Attach', 'label': 'Allow Attach',
'oldfieldname': 'allow_attach', 'oldfieldname': 'allow_attach',
'oldfieldtype': 'Check', 'oldfieldtype': 'Check',
@@ -462,7 +422,6 @@
'fieldname': 'max_attachments', 'fieldname': 'max_attachments',
'fieldtype': 'Int', 'fieldtype': 'Int',
'hidden': 1, 'hidden': 1,
'idx': 30,
'label': 'Max Attachments', 'label': 'Max Attachments',
'oldfieldname': 'max_attachments', 'oldfieldname': 'max_attachments',
'oldfieldtype': 'Int' 'oldfieldtype': 'Int'
@@ -473,7 +432,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'allow_rename', 'fieldname': 'allow_rename',
'fieldtype': 'Check', 'fieldtype': 'Check',
'idx': 31,
'label': 'Allow Rename', 'label': 'Allow Rename',
'oldfieldname': 'allow_rename', 'oldfieldname': 'allow_rename',
'oldfieldtype': 'Check' 'oldfieldtype': 'Check'
@@ -484,7 +442,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'section_style', 'fieldname': 'section_style',
'fieldtype': 'Select', 'fieldtype': 'Select',
'idx': 32,
'label': 'Section Style', 'label': 'Section Style',
'oldfieldname': 'section_style', 'oldfieldname': 'section_style',
'oldfieldtype': 'Select', 'oldfieldtype': 'Select',
@@ -497,7 +454,6 @@
'fieldname': 'colour', 'fieldname': 'colour',
'fieldtype': 'Select', 'fieldtype': 'Select',
'hidden': 0, 'hidden': 0,
'idx': 33,
'label': 'Colour', 'label': 'Colour',
'oldfieldname': 'colour', 'oldfieldname': 'colour',
'oldfieldtype': 'Select', 'oldfieldtype': 'Select',
@@ -512,7 +468,6 @@
'fieldname': 'smallicon', 'fieldname': 'smallicon',
'fieldtype': 'Select', 'fieldtype': 'Select',
'hidden': 0, 'hidden': 0,
'idx': 34,
'label': 'Small Icon', 'label': 'Small Icon',
'oldfieldname': 'smallicon', 'oldfieldname': 'smallicon',
'oldfieldtype': 'Select', 'oldfieldtype': 'Select',
@@ -521,11 +476,18 @@
'search_index': 0 'search_index': 0
}, },


# DocField
{
'doctype': 'DocField',
'fieldname': 'default_print_format',
'fieldtype': 'Data',
'label': 'Default Print Format'
},

# DocField # DocField
{ {
'doctype': 'DocField', 'doctype': 'DocField',
'fieldtype': 'Section Break', 'fieldtype': 'Section Break',
'idx': 35,
'label': 'Permissions', 'label': 'Permissions',
'oldfieldtype': 'Section Break' 'oldfieldtype': 'Section Break'
}, },
@@ -534,7 +496,6 @@
{ {
'doctype': 'DocField', 'doctype': 'DocField',
'fieldtype': 'Column Break', 'fieldtype': 'Column Break',
'idx': 36,
'label': 'Roles and Permissions', 'label': 'Roles and Permissions',
'oldfieldtype': 'Column Break', 'oldfieldtype': 'Column Break',
'width': '70%' 'width': '70%'
@@ -547,7 +508,6 @@
'fieldname': 'permissions', 'fieldname': 'permissions',
'fieldtype': 'Table', 'fieldtype': 'Table',
'hidden': 0, 'hidden': 0,
'idx': 37,
'label': 'Permissions', 'label': 'Permissions',
'oldfieldname': 'permissions', 'oldfieldname': 'permissions',
'oldfieldtype': 'Table', 'oldfieldtype': 'Table',
@@ -561,7 +521,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldname': 'allow_trash', 'fieldname': 'allow_trash',
'fieldtype': 'Check', 'fieldtype': 'Check',
'idx': 38,
'label': 'Allow Trash', 'label': 'Allow Trash',
'oldfieldname': 'allow_trash', 'oldfieldname': 'allow_trash',
'oldfieldtype': 'Check' 'oldfieldtype': 'Check'
@@ -571,7 +530,6 @@
{ {
'doctype': 'DocField', 'doctype': 'DocField',
'fieldtype': 'Column Break', 'fieldtype': 'Column Break',
'idx': 39,
'label': 'Print Formats', 'label': 'Print Formats',
'oldfieldtype': 'Column Break', 'oldfieldtype': 'Column Break',
'width': '30%' 'width': '30%'
@@ -583,7 +541,6 @@
'fieldname': 'formats', 'fieldname': 'formats',
'fieldtype': 'Table', 'fieldtype': 'Table',
'hidden': 0, 'hidden': 0,
'idx': 40,
'label': 'Formats', 'label': 'Formats',
'oldfieldname': 'formats', 'oldfieldname': 'formats',
'oldfieldtype': 'Table', 'oldfieldtype': 'Table',
@@ -597,7 +554,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldtype': 'Section Break', 'fieldtype': 'Section Break',
'hidden': 0, 'hidden': 0,
'idx': 41,
'label': 'Fields', 'label': 'Fields',
'oldfieldtype': 'Section Break', 'oldfieldtype': 'Section Break',
'reqd': 0, 'reqd': 0,
@@ -609,7 +565,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldtype': 'Column Break', 'fieldtype': 'Column Break',
'hidden': 0, 'hidden': 0,
'idx': 42,
'label': 'Document Fields', 'label': 'Document Fields',
'oldfieldtype': 'Column Break', 'oldfieldtype': 'Column Break',
'reqd': 0, 'reqd': 0,
@@ -622,7 +577,6 @@
'fieldname': 'fields', 'fieldname': 'fields',
'fieldtype': 'Table', 'fieldtype': 'Table',
'hidden': 0, 'hidden': 0,
'idx': 43,
'label': 'Fields', 'label': 'Fields',
'oldfieldname': 'fields', 'oldfieldname': 'fields',
'oldfieldtype': 'Table', 'oldfieldtype': 'Table',
@@ -636,7 +590,6 @@
'doctype': 'DocField', 'doctype': 'DocField',
'fieldtype': 'Section Break', 'fieldtype': 'Section Break',
'hidden': 0, 'hidden': 0,
'idx': 44,
'label': 'Description', 'label': 'Description',
'oldfieldtype': 'Section Break', 'oldfieldtype': 'Section Break',
'reqd': 0, 'reqd': 0,
@@ -649,7 +602,6 @@
'fieldname': 'description', 'fieldname': 'description',
'fieldtype': 'Text', 'fieldtype': 'Text',
'hidden': 0, 'hidden': 0,
'idx': 45,
'label': 'Description', 'label': 'Description',
'oldfieldname': 'description', 'oldfieldname': 'description',
'oldfieldtype': 'Text', 'oldfieldtype': 'Text',


+ 103
- 100
py/core/doctype/doctype_mapper/doctype_mapper.py 查看文件

@@ -21,41 +21,17 @@ class DocType:
def __init__(self, doc, doclist=[]): def __init__(self, doc, doclist=[]):
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
self.prefix = is_testing and 'test' or 'tab'
self.ref_doc = '' self.ref_doc = ''
# Autoname # Autoname
#---------
#---------------------------------------------------------------------------
def autoname(self): def autoname(self):
self.doc.name = make_autoname(self.doc.from_doctype + '-' + self.doc.to_doctype) self.doc.name = make_autoname(self.doc.from_doctype + '-' + self.doc.to_doctype)


def map_fields_with_same_name(self, from_doctype, to_doctype, from_doc, to_doc, fld_list):
"""
Returns field list with same name in from and to doctype
"""
exception_flds = [f[0] for f in fld_list if f[2] == 'No']
exception_flds += default_fields
exception_flds += ['amended_from', 'amendment_date', 'file_list', 'naming_series', 'status']
map_fld_list = [
[d[0], d[0], 'Yes'] for d in sql("""
select t1.fieldname
from `tabDocField` t1, `tabDocField` t2
where t1.parent = %s and t2.parent = %s
and t1.fieldname = t2.fieldname
and t1.docstatus != 2 and t2.docstatus != 2
and ifnull(t1.fieldname, '') != ''
""",(from_doctype, to_doctype)) if d[0] not in exception_flds
]

self.set_value(map_fld_list, from_doc, to_doc)
# Maps the fields in 'To DocType' # Maps the fields in 'To DocType'
#--------------------------------
#---------------------------------------------------------------------------
def dt_map(self, from_doctype, to_doctype, from_docname, to_doc, doclist, from_to_list = '[]'): def dt_map(self, from_doctype, to_doctype, from_docname, to_doc, doclist, from_to_list = '[]'):

# definition of arguments
''' '''
String <from_doctype> : contains the name of DocType initiating the function String <from_doctype> : contains the name of DocType initiating the function
String <to_doctype> : contains the name of DocType created by the function String <to_doctype> : contains the name of DocType created by the function
@@ -64,6 +40,10 @@ class DocType:
String <doclist> : contains doclist of 'to_doctype' String <doclist> : contains doclist of 'to_doctype'
String <from_to_list> : contains list of tables which will be mapped String <from_to_list> : contains list of tables which will be mapped
''' '''
if not from_docname:
msgprint(from_doctype + " not selected for mapping", raise_exception=1)
# Validate reference doc docstatus # Validate reference doc docstatus
self.ref_doc = from_docname self.ref_doc = from_docname
self.check_ref_docstatus() self.check_ref_docstatus()
@@ -71,75 +51,93 @@ class DocType:
if not doclist: if not doclist:
doclist.append(to_doc) doclist.append(to_doc)


tbl_list = sql("select from_table, to_table, from_field, to_field, match_id, validation_logic from `tabTable Mapper Detail` where parent ='%s' order by match_id" % (from_doctype + "-" + to_doctype))

for t in tbl_list:
from_table_name = t[0]
to_table_name = t[1]
from_table_fname = t[2]
to_table_fname = t[3]
match_id = t[4]
validation_logic = t[5]

from_to = [from_table_name, to_table_name]
tbl_list = sql("select from_table, to_table, from_field, to_field, match_id, validation_logic from `tabTable Mapper Detail` where parent ='%s' order by match_id" % self.doc.name, as_dict=1)


if from_to in eval(from_to_list):
fld_list = sql("select from_field, to_field, map from `tabField Mapper Detail` where parent = '%s' and match_id = %s" % (from_doctype + "-" + to_doctype, match_id))
if not from_docname:
msgprint(from_doctype + " not selected for mapping")
raise Exception
# Parent to parent mapping
if from_table_name == self.doc.from_doctype and to_table_name == self.doc.to_doctype:
# Check validation
nm = sql("select name from `tab%s` where name = '%s' and %s" % (from_doctype, from_docname, validation_logic))
nm = nm and nm[0][0] or ''
# If validation failed raise exception
if not nm:
msgprint("Validation failed in doctype mapper. Please contact Administrator.")
raise Exception
from_doc = Document(from_doctype, nm)

# Map fields with same name
for t in tbl_list:
if [t['from_table'], t['to_table']] in eval(from_to_list):
self.map_fields(t, from_doctype, from_docname, to_doc, doclist)
# Doclist is required when called from server side for refreshing table
return doclist


self.map_fields_with_same_name(from_doctype, to_doctype, from_doc, to_doc, fld_list)
# Maps field in parent
if fld_list:
self.set_value(fld_list, from_doc, to_doc)


#---------------------------------------------------------------------------
def map_fields(self, t, from_dt, from_dn, to_doc, doclist):
"""
Creates from, to obj and maps flds as per mapper and with same name
"""
flds = self.get_mapper_fields(t)
flds += self.get_fields_with_same_name(t, flds)


# Parent to child OR child to child mapping
if flds:
from_docnames = self.get_docnames(t, from_dt, from_dn)
for dn in from_docnames:
# Creates object for 'From DocType', it can be parent or child
from_doc_obj = Document(t['from_table'], dn[0])
# Add a row in target table in 'To DocType' and returns obj
if t['to_table'] != self.doc.to_doctype:
to_doc_obj = addchild(to_doc, t['to_field'], t['to_table'], 1, doclist)
else: else:
dnlist = ()
if from_table_name == self.doc.from_doctype:
dnlist = ((from_docname,),)
else:
dnlist = sql("select name from `tab%s` where parent='%s' and parenttype = '%s' and %s order by idx" % (from_table_name, from_docname, self.doc.from_doctype, validation_logic))
for dn in dnlist:
# Add a row in target table in 'To DocType' and returns obj
ch = addchild(to_doc, t[3], t[1], 1, doclist)
# Creates object for 'From DocType', it can be parent or child
d = Document(t[0], dn[0])
# Map fields with same name
self.map_fields_with_same_name(from_table_name, t[1], d, ch, fld_list)
# Map values
if fld_list:
self.set_value(fld_list, d, ch)
to_doc_obj = to_doc


self.set_value(flds, from_doc_obj, to_doc_obj)
#---------------------------------------------------------------------------
def get_docnames(self, t, from_dt, from_dn):
"""
Returns docnames of source document (parent/child)
"""
docnames = ()
if t['from_table'] == self.doc.from_doctype:
docnames = sql("select name from `tab%s` where name = '%s' and %s" % (from_dt, from_dn, t['validation_logic']))
if not docnames:
msgprint("Validation failed in doctype mapper. Please contact Administrator.", raise_exception=1)
else:
docnames = sql("select name from `tab%s` where parent='%s' and parenttype = '%s' and %s order by idx" % (t['from_table'], from_dn, self.doc.from_doctype, t['validation_logic']))
return docnames
#---------------------------------------------------------------------------
def get_mapper_fields(self, t):
return [[f[0], f[1], f[2]] for f in sql("""
select from_field, to_field, map
from `tabField Mapper Detail`
where parent = '%s' and match_id = %s
""" % (self.doc.name, t['match_id']))]




# Required when called from server side for refreshing table
return doclist
#---------------------------------------------------------------------------
def get_fields_with_same_name(self, t, flds):
"""
Returns field list with same name in from and to doctype
"""
exception_flds = default_fields
exception_flds += [f[1] for f in flds]
similar_flds = [
[d[0], d[0], 'Yes'] for d in sql("""
select t1.fieldname
from `tabDocField` t1, `tabDocField` t2
where t1.parent = %s and t2.parent = %s
and t1.fieldname = t2.fieldname
and t1.docstatus != 2 and t2.docstatus != 2
and ifnull(t1.no_copy, 0) = 0
and ifnull(t1.fieldname, '') != ''
and t1.fieldtype not in ('Table', 'Section Break', 'Column Break', 'HTML')
""",(t['from_table'], t['to_table'])) if d[0] not in exception_flds
]
return similar_flds
# Assigns value to "To Doctype"
#------------------------------
#---------------------------------------------------------------------------
def set_value(self, fld_list, obj, to_doc): def set_value(self, fld_list, obj, to_doc):
"""
Assigns value to fields in "To Doctype"
"""
for f in fld_list: for f in fld_list:
if f[2] == 'Yes': if f[2] == 'Yes':
if f[0].startswith('eval:'): if f[0].startswith('eval:'):
@@ -152,9 +150,12 @@ class DocType:
else: else:
to_doc.fields[f[1]] = obj.fields.get(f[0]) to_doc.fields[f[1]] = obj.fields.get(f[0])
# Validate
#---------
#---------------------------------------------------------------------------
def validate(self): def validate(self):
"""
Validate mapper while saving
"""
for d in getlist(self.doclist, 'field_mapper_details'): for d in getlist(self.doclist, 'field_mapper_details'):
# Automatically assigns default value if not entered # Automatically assigns default value if not entered
if not d.match_id: if not d.match_id:
@@ -169,10 +170,13 @@ class DocType:
# Check wrong field name # Check wrong field name
self.check_fields_in_dt() self.check_fields_in_dt()
# Check if any wrong fieldname entered
#--------------------------------------
#---------------------------------------------------------------------------
def check_fields_in_dt(self): def check_fields_in_dt(self):
"""
Check if any wrong fieldname entered in mapper
"""
for d in getlist(self.doclist, 'field_mapper_details'): for d in getlist(self.doclist, 'field_mapper_details'):
table_name = sql("select from_table, to_table from `tabTable Mapper Detail` where parent ='%s' and match_id = '%s'" % (self.doc.name, d.match_id)) table_name = sql("select from_table, to_table from `tabTable Mapper Detail` where parent ='%s' and match_id = '%s'" % (self.doc.name, d.match_id))
@@ -186,6 +190,7 @@ class DocType:
if not exists2 and d.to_field not in default_fields: if not exists2 and d.to_field not in default_fields:
msgprint('"' + cstr(d.to_field) + '" does not exists in DocType "' + cstr(table_name[0][1]) + '"') msgprint('"' + cstr(d.to_field) + '" does not exists in DocType "' + cstr(table_name[0][1]) + '"')
# Check consistency of value with reference document # Check consistency of value with reference document
#--------------------------------------------------- #---------------------------------------------------
def validate_reference_value(self, obj, to_docname): def validate_reference_value(self, obj, to_docname):
@@ -235,7 +240,6 @@ class DocType:
if cl[2] == '=' and (ft[1] == 'Currency' or ft[1] == 'Float'): if cl[2] == '=' and (ft[1] == 'Currency' or ft[1] == 'Float'):
consistent = sql("select name, %s from `tab%s` where name = '%s' and '%s' - %s <= 0.5" % (cl[0], t.from_table, child_obj.fields[t.reference_key], flt(cur_val), cl[0])) consistent = sql("select name, %s from `tab%s` where name = '%s' and '%s' - %s <= 0.5" % (cl[0], t.from_table, child_obj.fields[t.reference_key], flt(cur_val), cl[0]))
else: else:
#consistent = sql("select name, %s from `tab%s` where name = '%s' and '%s' %s %s" % (cl[0], t.from_table, child_obj.fields[t.reference_key], cur_val, cl[2], cl[0]))
consistent = sql("select name, %s from `tab%s` where name = '%s' and '%s' %s ifnull(%s, '')" % (cl[0], t.from_table, child_obj.fields[t.reference_key], ft[1] in ('Currency', 'Float', 'Int') and flt(cur_val) or cstr(cur_val), cl[2], cl[0])) consistent = sql("select name, %s from `tab%s` where name = '%s' and '%s' %s ifnull(%s, '')" % (cl[0], t.from_table, child_obj.fields[t.reference_key], ft[1] in ('Currency', 'Float', 'Int') and flt(cur_val) or cstr(cur_val), cl[2], cl[0]))


if not self.ref_doc: if not self.ref_doc:
@@ -253,22 +257,21 @@ class DocType:
from_fld_label = sql("select label from tabDocField where parent = '%s' and fieldname = '%s'" % (from_table, from_field)) from_fld_label = sql("select label from tabDocField where parent = '%s' and fieldname = '%s'" % (from_table, from_field))
op_in_words = {'=':'equal to ', '>=':'greater than equal to ', '>':'greater than ', '<=':'less than equal to ', '<':'less than '} op_in_words = {'=':'equal to ', '>=':'greater than equal to ', '>':'greater than ', '<=':'less than equal to ', '<':'less than '}
msgprint(to_fld_label[0][0] + " should be " + op_in_words[operator] + from_fld_label[0][0] + " of " + self.doc.from_doctype + ": " + self.ref_doc)
raise Exception, "Validation Error."
msgprint(to_fld_label[0][0] + " should be " + op_in_words[operator] + from_fld_label[0][0] + " of " + self.doc.from_doctype + ": " + self.ref_doc, raise_exception=1)
def check_ref_docstatus(self): def check_ref_docstatus(self):
if self.ref_doc: if self.ref_doc:
det = sql("select name, docstatus from `tab%s` where name = '%s'" % (self.doc.from_doctype, self.ref_doc)) det = sql("select name, docstatus from `tab%s` where name = '%s'" % (self.doc.from_doctype, self.ref_doc))
if not det: if not det:
msgprint(self.doc.from_doctype + ": " + self.ref_doc + " does not exists in the system")
raise Exception, "Validation Error."
msgprint(self.doc.from_doctype + ": " + self.ref_doc + " does not exists in the system", raise_exception=1)
elif self.doc.ref_doc_submitted and det[0][1] != 1: elif self.doc.ref_doc_submitted and det[0][1] != 1:
msgprint(self.doc.from_doctype + ": " + self.ref_doc + " is not Submitted Document.")
raise Exception, "Validation Error."
msgprint(self.doc.from_doctype + ": " + self.ref_doc + " is not Submitted Document.", raise_exception=1)


def on_update(self): def on_update(self):
"""
If developer_mode = 1, mapper will be written to files
"""
import webnotes.defs import webnotes.defs
if hasattr(webnotes.defs, 'developer_mode') and webnotes.defs.developer_mode: if hasattr(webnotes.defs, 'developer_mode') and webnotes.defs.developer_mode:
from webnotes.modules.export_module import export_to_files from webnotes.modules.export_module import export_to_files
export_to_files(record_list=[[self.doc.doctype, self.doc.name]])
export_to_files(record_list=[[self.doc.doctype, self.doc.name]])

+ 4
- 0
py/webnotes/modules/patch.py 查看文件

@@ -5,6 +5,10 @@ def run(log_exception=1):
from patches import patch from patches import patch
from webnotes.utils import cint from webnotes.utils import cint
if webnotes.conn.cur_db_name=='accounts':
# no patches on accounts
return
next_patch = cint(webnotes.conn.get_global('next_patch')) next_patch = cint(webnotes.conn.get_global('next_patch'))
if next_patch <= patch.last_patch: if next_patch <= patch.last_patch:


+ 2
- 2
py/webnotes/profile.py 查看文件

@@ -162,12 +162,12 @@ class Profile:


# update tab Profile # update tab Profile
webnotes.conn.sql("UPDATE tabProfile SET password=password(%s) WHERE name=%s", (pwd, profile[0][0])) webnotes.conn.sql("UPDATE tabProfile SET password=password(%s) WHERE name=%s", (pwd, profile[0][0]))
self.send_email("Password Reset", "<p>Dear %s%s,</p><p>your password has been changed to %s</p><p>[Automatically Generated]</p>" % (profile[0][2], (profile[0][3] and (' ' + profile[0][3]) or ''), pwd), profile[0][1]) self.send_email("Password Reset", "<p>Dear %s%s,</p><p>your password has been changed to %s</p><p>[Automatically Generated]</p>" % (profile[0][2], (profile[0][3] and (' ' + profile[0][3]) or ''), pwd), profile[0][1])
def send_email(self, subj, mess, email): def send_email(self, subj, mess, email):
import webnotes.utils.email_lib import webnotes.utils.email_lib
webnotes.utils.email_lib.sendmail(email, msg=mess, subject=subj) webnotes.utils.email_lib.sendmail(email, msg=mess, subject=subj)
# update recent documents # update recent documents


+ 8
- 9
py/webnotes/utils/email_lib/__init__.py 查看文件

@@ -29,19 +29,18 @@ def sendmail(recipients, sender='', msg='', subject='[No Subject]', parts=[], cc
email = EMail(sender, recipients, subject, reply_to=reply_to) email = EMail(sender, recipients, subject, reply_to=reply_to)
email.cc = cc email.cc = cc
if msg:
if template:
msg = make_html_body(msg, template)
if msg:
if template:
msg = make_html_body(msg, template).encode('utf-8')
else: else:
# if not html, then lets put some whitespace # if not html, then lets put some whitespace
if (not '<br>' in msg) or (not '<p>' in msg): if (not '<br>' in msg) or (not '<p>' in msg):
msg = msg.replace('\n','<br>')
msg = msg.replace('\n','<br>')
footer = get_footer() footer = get_footer()
msg = msg + (footer or '')
email.set_text(html2text(msg))
email.set_html(msg)
msg = msg + (footer or '')
email.set_text(html2text(msg))
email.set_html(msg)
for p in parts: for p in parts:
email.set_message(p[1]) email.set_message(p[1])
for a in attach: for a in attach:


+ 2
- 1
py/webnotes/utils/email_lib/html2text.py 查看文件

@@ -447,7 +447,8 @@ def html2text_file(html, out=wrapwrite, baseurl=''):
return h.close() return h.close()


def html2text(html, baseurl=''): def html2text(html, baseurl=''):
return optwrap(html2text_file(html, None, baseurl))
txt = html2text_file(html.decode('utf-8'), None, baseurl)
return optwrap(txt.encode('utf-8'))


if __name__ == "__main__": if __name__ == "__main__":
baseurl = '' baseurl = ''


+ 5
- 1
py/webnotes/utils/email_lib/send.py 查看文件

@@ -16,6 +16,9 @@ class EMail:
""" """
def __init__(self, sender='', recipients=[], subject='', from_defs=0, alternative=0, reply_to=None): def __init__(self, sender='', recipients=[], subject='', from_defs=0, alternative=0, reply_to=None):
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
from email import Charset
Charset.add_charset('utf-8', Charset.QP, Charset.QP, 'utf-8')

if type(recipients)==str: if type(recipients)==str:
recipients = recipients.replace(';', ',') recipients = recipients.replace(';', ',')
recipients = recipients.split(',') recipients = recipients.split(',')
@@ -36,7 +39,8 @@ class EMail:
Attach message in the text portion of multipart/alternative Attach message in the text portion of multipart/alternative
""" """
from email.mime.text import MIMEText from email.mime.text import MIMEText
part = MIMEText(message, 'plain')
msg = unicode(message, 'utf-8')
part = MIMEText(msg.encode('utf-8'), 'plain', 'UTF-8')
self.msg_multipart.attach(part) self.msg_multipart.attach(part)
def set_html(self, message): def set_html(self, message):


Loading…
取消
儲存