mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 06:29:20 +00:00
Sourced wnframework-modules from Google Code as erpnext
This commit is contained in:
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'Administrator', 'name': 'Payable Voucher', 'parent': None, 'dt_label': 'Purchase Invoice', 'creation': '2010-06-10 10:44:55', 'modified': '2010-06-10 10:44:55', 'module': 'Application Internal', 'doctype': 'DocType Label', 'idx': None, 'parenttype': None, 'owner': 'Administrator', 'docstatus': 0, 'dt': 'Payable Voucher', 'parentfield': None}]
|
||||
@@ -0,0 +1 @@
|
||||
[{'modified_by': 'Administrator', 'name': 'Receivable Voucher', 'parent': None, 'dt_label': 'Sales Invoice', 'creation': '2010-06-10 10:44:40', 'modified': '2010-06-10 10:44:40', 'module': 'Application Internal', 'doctype': 'DocType Label', 'idx': None, 'parenttype': None, 'owner': 'Administrator', 'docstatus': 0, 'dt': 'Receivable Voucher', 'parentfield': None}]
|
||||
@@ -0,0 +1,218 @@
|
||||
[
|
||||
{
|
||||
'_last_update': None,
|
||||
'creation': '2010-11-30 17:30:06',
|
||||
'disabled': 'No',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def',
|
||||
'doctype_list': 'DocType Label, Payable Voucher\nDocType Label, Receivable Voucher',
|
||||
'file_list': None,
|
||||
'idx': None,
|
||||
'is_hidden': None,
|
||||
'last_updated_date': '2010-11-29 12:02:02',
|
||||
'modified': '2010-09-25 00:00:00',
|
||||
'modified_by': 'Administrator',
|
||||
'module_desc': None,
|
||||
'module_icon': None,
|
||||
'module_label': 'Application Internal',
|
||||
'module_name': 'Application Internal',
|
||||
'module_page': None,
|
||||
'module_seq': None,
|
||||
'name': 'Application Internal',
|
||||
'owner': 'Administrator',
|
||||
'parent': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'trash_reason': None,
|
||||
'widget_code': None
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 17:30:06',
|
||||
'description': None,
|
||||
'display_name': 'Code History',
|
||||
'doc_name': 'Code History',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': None,
|
||||
'modified': '2011-03-24 15:04:46',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00016',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Application Internal',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 17:30:06',
|
||||
'description': None,
|
||||
'display_name': 'DocType Label',
|
||||
'doc_name': 'DocType Label',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': None,
|
||||
'modified': '2011-03-24 15:04:46',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00017',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Application Internal',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 17:30:06',
|
||||
'description': None,
|
||||
'display_name': 'DocType Mapper',
|
||||
'doc_name': 'DocType Mapper',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': None,
|
||||
'modified': '2011-03-24 15:04:46',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00018',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Application Internal',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 17:30:06',
|
||||
'description': None,
|
||||
'display_name': 'Form Settings',
|
||||
'doc_name': 'Form Settings',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': None,
|
||||
'modified': '2011-03-24 15:04:46',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00019',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Application Internal',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 17:30:06',
|
||||
'description': None,
|
||||
'display_name': 'GL Mapper',
|
||||
'doc_name': 'GL Mapper',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': None,
|
||||
'modified': '2011-03-24 15:04:46',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00020',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Application Internal',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 17:30:06',
|
||||
'description': None,
|
||||
'display_name': 'Impact Analysis',
|
||||
'doc_name': 'Impact Analysis',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': None,
|
||||
'modified': '2011-03-24 15:04:46',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00021',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Application Internal',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 17:30:06',
|
||||
'description': None,
|
||||
'display_name': 'Rating Template',
|
||||
'doc_name': 'Rating Template',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': None,
|
||||
'modified': '2011-03-24 15:04:46',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00022',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Application Internal',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 17:30:06',
|
||||
'description': None,
|
||||
'display_name': 'Search Criteria',
|
||||
'doc_name': 'Search Criteria',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': None,
|
||||
'modified': '2011-03-24 15:04:46',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00023',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Application Internal',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2011-03-24 15:04:46',
|
||||
'description': None,
|
||||
'display_name': None,
|
||||
'doc_name': 'Forms',
|
||||
'doc_type': 'Separator',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': None,
|
||||
'modified': '2011-03-24 15:04:46',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000003078',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Application Internal',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
}
|
||||
]
|
||||
0
application_internal/__init__.py
Normal file
0
application_internal/__init__.py
Normal file
0
application_internal/doctype/__init__.py
Normal file
0
application_internal/doctype/__init__.py
Normal file
204
application_internal/doctype/code_editor/code_editor.js
Normal file
204
application_internal/doctype/code_editor/code_editor.js
Normal file
@@ -0,0 +1,204 @@
|
||||
|
||||
// get the script
|
||||
loadscript("js/edit_area/edit_area_full.js", function() { });
|
||||
|
||||
// property div
|
||||
cur_frm.fields_dict['Property HTML'].prop_div = $a(cur_frm.fields_dict['Property HTML'].wrapper,'div','',{margin:'8px 0px'});
|
||||
|
||||
// comment div
|
||||
cur_frm.cscript.comment_div = $a(cur_frm.fields_dict['Code Toolbar'].wrapper,'div','',{display: 'none', marginBottom:'8px', width: '90%', backgroundColor: '#FFD', fontSize: '14px', padding:'4px'})
|
||||
|
||||
// field master
|
||||
cur_frm.cscript.type_fields = {
|
||||
'DocType': 'doc_type'
|
||||
,'Page': 'page_name'
|
||||
,'Search Criteria': 'criteria_id'
|
||||
,'Print Format': 'print_format'
|
||||
}
|
||||
|
||||
// syntax master
|
||||
// -------------
|
||||
cur_frm.cscript.code_syntax = {
|
||||
// --- DocType
|
||||
client_script:'js'
|
||||
,client_script_core:'js'
|
||||
,server_code:'python'
|
||||
,server_code_core:'python'
|
||||
|
||||
// --- Page
|
||||
,content:'html'
|
||||
,script:'js'
|
||||
,style:'css'
|
||||
|
||||
// --- Search Criteria
|
||||
,report_script:'js'
|
||||
,server_script:'python'
|
||||
|
||||
// --- Print Format
|
||||
,code:'html'
|
||||
}
|
||||
|
||||
// get field name of code
|
||||
// ----------------------
|
||||
|
||||
cur_frm.cscript.get_field_name = function(doc) {
|
||||
// field names
|
||||
if(doc.script_from =='DocType') {
|
||||
var code_field = doc.code_type.toLowerCase().replace(/ /g,'_');
|
||||
} else if(doc.script_from =='Page') {
|
||||
var code_field = doc.code_type_page.toLowerCase().replace(/ /g,'_');
|
||||
} else if(doc.script_from =='Search Criteria') {
|
||||
var code_field = doc.code_type_criteria.toLowerCase().replace(/ /g,'_');
|
||||
} else if(doc.script_from =='Print Format') {
|
||||
var code_field = 'html';
|
||||
}
|
||||
return code_field;
|
||||
}
|
||||
|
||||
// update comment
|
||||
// --------------
|
||||
cur_frm.cscript.update_comment = function() {
|
||||
var ce = cur_frm.cscript.cur_editor;
|
||||
if(!ce) return;
|
||||
var c = cur_frm.cscript.comment_div;
|
||||
c.innerHTML = "Currently Editing '<b>" + ce.fn + "</b>' from " + ce.dt + " <b>" + ce.dn + "</b><span style='color: #888'> (Last Modified: " + ce.code_modified + ")</span>";
|
||||
if(ce.saved)
|
||||
c.innerHTML += "<br><b style='color: GREEN'>Saved</b>"
|
||||
else
|
||||
c.innerHTML += "<br><b style='color: ORANGE'>Changes are not saved</b>"
|
||||
|
||||
$ds(c);
|
||||
}
|
||||
|
||||
// get code button
|
||||
// ---------------
|
||||
cur_frm.cscript.get_code = function() {
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
|
||||
if(!editAreaLoader) {
|
||||
msgprint('Waiting for the editor to load. Please try again');
|
||||
return;
|
||||
}
|
||||
|
||||
if(cur_frm.cscript.cur_editor && (!cur_frm.cscript.cur_editor.saved)) {
|
||||
if(!confirm("Current script not saved. Do you want to continue?")) return;
|
||||
}
|
||||
|
||||
// field names
|
||||
var code_field = cur_frm.cscript.get_field_name(doc);
|
||||
|
||||
var callback = function(r, rt) {
|
||||
|
||||
cur_frm.cscript.make_editor(cur_frm.cscript.code_syntax[code_field]);
|
||||
editAreaLoader.setValue(cur_frm.cscript.cur_editor.editor_id, r.message[0]);
|
||||
|
||||
var ce = cur_frm.cscript.cur_editor;
|
||||
|
||||
ce.code_modified = r.message[1];
|
||||
ce.dt = doc.script_from;
|
||||
ce.dn = doc[cur_frm.cscript.type_fields[doc.script_from]];
|
||||
ce.fn = code_field;
|
||||
ce.saved = 1;
|
||||
cur_frm.cscript.update_comment();
|
||||
}
|
||||
$c_obj([doc], 'get_code', [doc.script_from, doc[cur_frm.cscript.type_fields[doc.script_from]], code_field].join('~~~'), callback);
|
||||
}
|
||||
|
||||
// make a new editor
|
||||
// -----------------
|
||||
|
||||
cur_frm.cscript.make_editor = function(syntax) {
|
||||
|
||||
// hide editor if exists
|
||||
if(cur_frm.cscript.cur_editor) {
|
||||
}
|
||||
|
||||
// set id
|
||||
var myid = 'code_edit_1' //+ cur_frm.cscript.mycnt;
|
||||
|
||||
editAreaLoader.init({id: myid, start_highlight: true, word_wrap: false, syntax: syntax
|
||||
,change_callback : "cur_frm.cscript.editor_change_callback"
|
||||
,EA_load_callback: "cur_frm.cscript.editor_load_callback"
|
||||
});
|
||||
editAreaLoader.window_loaded(); // make the editor
|
||||
|
||||
if(!cur_frm.cscript.cur_editor) {
|
||||
|
||||
// parent
|
||||
var div = $a(cur_frm.fields_dict['Code HTML'].wrapper,'div');
|
||||
div.editor_id = myid;
|
||||
|
||||
// make the form
|
||||
div.innerHTML = '<form method="POST"></form>';
|
||||
|
||||
div.form = div.childNodes[0];
|
||||
|
||||
// make the text area
|
||||
div.ta = $a(div.form,'textarea','',{height: '400px'}); div.ta.setAttribute('id',myid);
|
||||
|
||||
cur_frm.cscript.cur_editor = div;
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.editor_change_callback = function(id) {
|
||||
cur_frm.cscript.cur_editor.saved = 0; cur_frm.cscript.update_comment();
|
||||
}
|
||||
|
||||
cur_frm.cscript.editor_load_callback = function(id) {
|
||||
cur_frm.cscript.cur_editor.saved = 1; cur_frm.cscript.update_comment();
|
||||
}
|
||||
|
||||
// get properties
|
||||
// --------------
|
||||
cur_frm.cscript.get_properties = function() {
|
||||
var callback = function(r,rt) {
|
||||
var div = cur_frm.fields_dict['Property HTML'].prop_div;
|
||||
div.innerHTML = '';
|
||||
|
||||
var t = make_table(div, r.message.length, 4, '90%', ['25%','25%','25%','25%'], {padding: '3px'})
|
||||
var cl = r.message;
|
||||
for(var i=0; i<cl.length; i++) {
|
||||
$td(t,i,0).innerHTML = cl[i][0];
|
||||
$td(t,i,1).innerHTML = cl[i][1];
|
||||
$td(t,i,2).innerHTML = cl[i][2];
|
||||
$td(t,i,3).innerHTML = cl[i][3];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$c_obj([locals[cur_frm.doctype][cur_frm.docname]], 'get_properties', '', callback);
|
||||
}
|
||||
|
||||
// set code button
|
||||
// ---------------
|
||||
|
||||
cur_frm.cscript.set_code = function() {
|
||||
ce = cur_frm.cscript.cur_editor;
|
||||
|
||||
var doc = locals[cur_frm.doctype][cur_frm.docname];
|
||||
|
||||
if(doc.add_to_history) {
|
||||
var comment = prompt("Please enter comment before saving");
|
||||
if(!comment) { msgprint("Comment is necessary. Not saved"); return; }
|
||||
}
|
||||
|
||||
doc.code = editAreaLoader.getValue(ce.editor_id);
|
||||
$c_obj([doc], 'set_code', [ce.dt, ce.dn, ce.fn, comment, ce.code_modified].join('~~~'),
|
||||
function(r,rt) {
|
||||
if(r.exc)return;
|
||||
cur_frm.cscript.cur_editor.code_modified = r.message;
|
||||
cur_frm.cscript.cur_editor.saved = 1;
|
||||
cur_frm.cscript.update_comment();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
cur_frm.cscript.is_doctype = function(doc,dt,dn) { return doc.script_from == 'DocType' }
|
||||
cur_frm.cscript.is_page = function(doc,dt,dn) { return doc.script_from == 'Page' }
|
||||
cur_frm.cscript.is_criteria = function(doc,dt,dn) { return doc.script_from == 'Search Criteria' }
|
||||
cur_frm.cscript.is_print_format = function(doc,dt,dn) { return doc.script_from == 'Print Format' }
|
||||
cur_frm.cscript.test = function(doc,dt,dn) { return false }
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
cur_frm.cscript.update_comment();
|
||||
}
|
||||
73
application_internal/doctype/code_editor/code_editor.py
Normal file
73
application_internal/doctype/code_editor/code_editor.py
Normal file
@@ -0,0 +1,73 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
# get the code
|
||||
# ------------
|
||||
def get_code(self, arg):
|
||||
dt, dn, field = arg.split('~~~')
|
||||
return [str(r or '') for r in sql("select `%s`, modified from `tab%s` where name='%s'" % (field, dt, dn))[0]]
|
||||
|
||||
# set code
|
||||
# check modified, add to history, update code
|
||||
# -------------------------------------------
|
||||
def set_code(self, arg):
|
||||
dt, dn, field, comment, modified = arg.split('~~~')
|
||||
|
||||
# validate modified
|
||||
old_modified = sql("select modified from `tab%s` where name='%s'" % (dt, dn))[0][0]
|
||||
if str(old_modified) != modified:
|
||||
msgprint('error:Someone has updated the code after you checked it out. Please update to the latest copy of the code before saving.')
|
||||
raise Exception
|
||||
|
||||
# add to history
|
||||
if self.doc.add_to_history:
|
||||
self.add_to_history(dt, dn, field, self.doc.code, comment)
|
||||
|
||||
# update
|
||||
new_modified = now()
|
||||
sql("update `tab%s` set `%s` = %s, modified = %s where name=%s" % (dt, field, '%s', '%s', '%s'), (self.doc.code, new_modified, dn))
|
||||
|
||||
# compile
|
||||
if dt=='DocType':
|
||||
get_obj('DocType',dn).compile_code()
|
||||
sql("delete from __DocTypeCache where name=%s", dn)
|
||||
|
||||
msgprint('ok:Saved')
|
||||
return new_modified
|
||||
|
||||
# get properties
|
||||
# --------------
|
||||
def get_properties(self, arg=''):
|
||||
#return convert_to_lists(sql("select fieldname, label, fieldtype, options from tabDocField where parent=%s and ifnull(fieldname,'') != '' order by idx asc", self.doc.select_doctype))
|
||||
return convert_to_lists(sql("select fieldname, label, fieldtype, options from tabDocField where parent=%s and ifnull(label,'') != '' order by idx asc", self.doc.select_doctype))
|
||||
# add to history
|
||||
# --------------
|
||||
def add_to_history(self, dt, dn, fn, code, comment):
|
||||
ch = Document('Code History')
|
||||
ch.script_from = dt
|
||||
ch.record_id = dn
|
||||
ch.field_name = fn
|
||||
ch.comment = comment
|
||||
ch.code = code
|
||||
ch.save(1)
|
||||
|
||||
1
application_internal/doctype/code_editor/code_editor.txt
Normal file
1
application_internal/doctype/code_editor/code_editor.txt
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-06-10 10:41:58', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 2, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'field:dt', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'DocType Label', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM01036', 'parent': 'DocType Label', 'read': 1, 'create': 1, 'creation': '2010-06-10 10:41:58', 'modified': '2010-06-10 10:44:09', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2010-06-10 10:41:58', 'doctype': 'DocField', 'oldfieldname': 'dt', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Select DocType', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'DocType Label', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05322', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-06-10 10:44:09', 'parenttype': 'DocType', 'fieldname': 'dt', 'fieldtype': 'Select', 'options': 'link:DocType', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-06-10 10:41:58', 'doctype': 'DocField', 'oldfieldname': 'dt_label', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'DocType Label', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'DocType Label', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05323', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-06-10 10:44:09', 'parenttype': 'DocType', 'fieldname': 'dt_label', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
|
||||
@@ -0,0 +1,15 @@
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def update_dt(self):
|
||||
sql("update tabDocType set module=%s, autoname=%s, read_only_onload=%s, section_style=%s, description=%s where name=%s limit 1", (self.doc.module, self.doc.autoname, self.doc.show_print_format_first, self.doc.page_style, self.doc.description, self.doc.select_doctype))
|
||||
|
||||
def get_details(self):
|
||||
ret = sql("select module, autoname, read_only_onload, section_style, description from tabDocType where name=%s", (self.doc.select_doctype))
|
||||
self.doc.module = ret[0][0] or ''
|
||||
self.doc.autoname = ret[0][1] or ''
|
||||
self.doc.show_print_format_first = ret[0][2] or 0
|
||||
self.doc.page_style = ret[0][3] or 'Simple'
|
||||
self.doc.description = ret[0][4] or ''
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
25
application_internal/doctype/form_settings/form_settings.js
Normal file
25
application_internal/doctype/form_settings/form_settings.js
Normal file
@@ -0,0 +1,25 @@
|
||||
cur_frm.fields_dict['doctype_name'].get_query = function(doc){
|
||||
return 'SELECT tabDocType.name FROM tabDocType WHERE (tabDocType.istable != 1 OR tabDocType.istable is null) AND (tabDocType.issingle !=1 OR tabDocType.issingle is null) AND tabDocType.name LIKE "%s"';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['report_filter_details'].grid.get_field("field_label_fr").get_query = function(doc){
|
||||
return 'SELECT tabDocField.label FROM tabDocField WHERE tabDocField.parent = "' + doc.doctype_name+ '" AND tabDocField.fieldname is not null AND tabDocField.fieldname != "'+''+'" AND tabDocField.fieldtype != "Table" AND tabDocField.label LIKE "%s"';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['report_field_details'].grid.get_field("field_label_fd").get_query = function(doc){
|
||||
return 'SELECT tabDocField.label FROM tabDocField WHERE tabDocField.parent = "' + doc.doctype_name+ '" AND tabDocField.fieldname is not null AND tabDocField.fieldname != "'+''+'" AND tabDocField.fieldtype != "Table" AND tabDocField.label LIKE "%s"';
|
||||
}
|
||||
|
||||
cur_frm.cscript.field_label_fr = function(doc,cdt,cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.field_label_fr){
|
||||
get_server_fields('get_filter_details',d.field_label_fr,'report_filter_details',doc,cdt,cdn,1);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.field_label_fd = function(doc,cdt,cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if(d.field_label_fd){
|
||||
get_server_fields('get_field_details',d.field_label_fd,'report_field_details',doc,cdt,cdn,1);
|
||||
}
|
||||
}
|
||||
54
application_internal/doctype/form_settings/form_settings.py
Normal file
54
application_internal/doctype/form_settings/form_settings.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def autoname(self):
|
||||
rep_nm = self.doc.doctype_name + '-' + 'Settings'
|
||||
if sql("select name from `tabForm Settings` where name=%s",rep_nm):
|
||||
msgprint("Settings for this form already created, please open existing form to do any changes.")
|
||||
raise Exception
|
||||
else:
|
||||
self.doc.name = rep_nm
|
||||
|
||||
def get_filter_details(self,arg=''):
|
||||
dt_det = sql("select label, fieldtype, options, fieldname from tabDocField where parent=%s and label=%s",(self.doc.doctype_name,arg),as_dict=1)
|
||||
|
||||
ret = {
|
||||
'field_label_fr' : dt_det and dt_det[0]['label'] or '',
|
||||
'field_type_fr' : dt_det and dt_det[0]['fieldtype'] or '',
|
||||
'options_fr' : dt_det and dt_det[0]['options'] or '',
|
||||
'field_name_fr' : dt_det and dt_det[0]['fieldname'] or '',
|
||||
'table_name_fr' : self.doc.doctype_name
|
||||
}
|
||||
return cstr(ret)
|
||||
|
||||
def get_field_details(self,arg=''):
|
||||
dt_det = sql("select label, fieldtype, options, fieldname from tabDocField where parent=%s and label=%s",(self.doc.doctype_name,arg),as_dict=1)
|
||||
ret = {
|
||||
'field_label_fd' : dt_det and dt_det[0]['label'] or '',
|
||||
'field_type_fd' : dt_det and dt_det[0]['fieldtype'] or '',
|
||||
'options_fd' : dt_det and dt_det[0]['options'] or '',
|
||||
'field_name_fd' : dt_det and dt_det[0]['fieldname'] or '',
|
||||
'table_name_fd' : self.doc.doctype_name
|
||||
}
|
||||
return cstr(ret)
|
||||
File diff suppressed because one or more lines are too long
0
application_internal/doctype/gl_mapper/__init__.py
Normal file
0
application_internal/doctype/gl_mapper/__init__.py
Normal file
1
application_internal/doctype/gl_mapper/gl_mapper.txt
Normal file
1
application_internal/doctype/gl_mapper/gl_mapper.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-12 12:09:20', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 2, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': None, 'allow_print': None, 'autoname': 'field:doc_type', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'GL Mapper', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': 0, 'amend': 0, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00034', 'parent': 'GL Mapper', 'read': 1, 'create': 0, 'creation': '2009-03-12 12:09:20', 'modified': '2010-04-08 12:29:12', 'submit': 0, 'doctype': 'DocPerm', 'write': 0, 'idx': 1, 'parenttype': 'DocType', 'role': 'Accounts User', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': '', 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00660', 'parent': 'GL Mapper', 'read': 1, 'create': None, 'creation': '2010-02-10 13:50:27', 'modified': '2010-03-31 10:38:44', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 2, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'wasim@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-03-12 12:09:20', 'doctype': 'DocField', 'oldfieldname': 'doc_type', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Doc Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'GL Mapper', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00361', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-03-31 10:38:44', 'parenttype': 'DocType', 'fieldname': 'doc_type', 'fieldtype': 'Link', 'options': 'DocType', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Table', 'creation': '2009-03-12 12:09:20', 'doctype': 'DocField', 'oldfieldname': 'fields', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Fields', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'GL Mapper', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL00362', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-03-31 10:38:44', 'parenttype': 'DocType', 'fieldname': 'fields', 'fieldtype': 'Table', 'options': 'GL Mapper Detail', 'report_hide': None, 'parentfield': 'fields'}]
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
0
application_internal/doctype/mail/__init__.py
Normal file
0
application_internal/doctype/mail/__init__.py
Normal file
1
application_internal/doctype/mail/mail.txt
Normal file
1
application_internal/doctype/mail/mail.txt
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-06-04 10:40:44', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 3, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'saumil@webnotestech.com', 'document_type': None, 'name': 'Mail Participant Details', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-06-04 10:40:44', 'doctype': 'DocField', 'oldfieldname': 'participant_name', 'owner': 'Administrator', 'reqd': 0, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Participant Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Mail Participant Details', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05240', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-08 15:04:17', 'parenttype': 'DocType', 'fieldname': 'participant_name', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2010-06-04 10:40:44', 'doctype': 'DocField', 'oldfieldname': 'read_status', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Read Status', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Mail Participant Details', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05241', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-08-08 15:04:17', 'parenttype': 'DocType', 'fieldname': 'read_status', 'fieldtype': 'Select', 'options': '\nRead\nUnread', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2010-06-04 10:40:44', 'doctype': 'DocField', 'oldfieldname': 'delete_status', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Delete Status', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Mail Participant Details', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05242', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-08-08 15:04:17', 'parenttype': 'DocType', 'fieldname': 'delete_status', 'fieldtype': 'Select', 'options': '\nYes\nNo', 'report_hide': None, 'parentfield': 'fields'}]
|
||||
82
application_internal/doctype/menu_control/menu_control.js
Normal file
82
application_internal/doctype/menu_control/menu_control.js
Normal file
@@ -0,0 +1,82 @@
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
def get_children(self, arg='', only_type='', in_roles=[]):
|
||||
|
||||
type_cond = only_type and (" and menu_item_type='%s'" % only_type) or ''
|
||||
|
||||
if globals().has_key('version') and version=='v170':
|
||||
import webnotes
|
||||
roles = webnotes.user.get_roles()
|
||||
all_read = webnotes.user.can_read
|
||||
else:
|
||||
roles = in_roles or session['data']['roles']
|
||||
all_read = session['data']['all_readtypes']
|
||||
|
||||
cl = sql("select name, menu_item_label, menu_item_type, link_id, link_content, has_children, icon, `order`, criteria_name, doctype_fields, onload from `tabMenu Item` where ifnull(disabled,'No')!='Yes' and ifnull(parent_menu_item,'')='%s' %s order by `order` asc" % (arg, type_cond), as_dict=1)
|
||||
ol = []
|
||||
for c in cl:
|
||||
c['has_children'] = cint(c['has_children'])
|
||||
c['order'] = cint(c['order'])
|
||||
for k in c.keys():
|
||||
if c[k]==None: c[k] = ''
|
||||
|
||||
# check permission
|
||||
if c['menu_item_type'] in ('DocType','Single','Report'):
|
||||
if c['link_id'] in all_read:
|
||||
ol.append(c)
|
||||
elif c['menu_item_type']=='Page':
|
||||
# page
|
||||
if c['link_id'].startswith('_'):
|
||||
ol.append(c)
|
||||
elif has_common([r[0] for r in sql("select role from `tabPage Role` where parent=%s", c['link_id'])], roles):
|
||||
ol.append(c)
|
||||
elif cstr(c['menu_item_type'])=='':
|
||||
# sections
|
||||
if has_common([r[0] for r in sql("select role from `tabMenu Item Role` where parent=%s", c['name'])], roles):
|
||||
ol.append(c)
|
||||
else:
|
||||
ol.append(c)
|
||||
|
||||
return ol
|
||||
|
||||
def get_dt_details(self, arg):
|
||||
dt, fl = arg.split('~~~')
|
||||
|
||||
out = {}
|
||||
|
||||
# filters
|
||||
# -------
|
||||
|
||||
sf = sql("select search_fields from tabDocType where name=%s", dt)[0][0] or ''
|
||||
sf = [s.strip() for s in sf.split(',')]
|
||||
if sf and sf[0]:
|
||||
res = sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname in (%s)" % (dt, '"'+'","'.join(sf)+'"'))
|
||||
else:
|
||||
res = []
|
||||
|
||||
res = [[c or '' for c in r] for r in res]
|
||||
for r in res:
|
||||
if r[2]=='Select' and r[3] and r[3].startswith('link:'):
|
||||
tdt = r[3][5:]
|
||||
ol = sql("select name from `tab%s` where docstatus!=2 order by name asc" % tdt)
|
||||
r[3] = NEWLINE.join([''] + [o[0] for o in ol])
|
||||
|
||||
if not res:
|
||||
out['filters'] = [['name', 'ID', 'Data', '']]
|
||||
else:
|
||||
out['filters'] = res
|
||||
|
||||
# columns
|
||||
# -------
|
||||
fl = fl.split(NEWLINE)
|
||||
fl = [f.split(',')[0] for f in fl]
|
||||
res = []
|
||||
for f in fl:
|
||||
res += [[c or '' for c in r] for r in sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname='%s'" % (dt, f))]
|
||||
|
||||
out['columns'] = [['name', 'ID', 'Link', dt]] + res
|
||||
|
||||
return out
|
||||
|
||||
265
application_internal/doctype/menu_control/menu_control.py
Normal file
265
application_internal/doctype/menu_control/menu_control.py
Normal file
@@ -0,0 +1,265 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cint, cstr
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, form, msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
# --------------------------------------------------------------
|
||||
def get_children(self, arg='', only_type='', in_roles=[]):
|
||||
|
||||
type_cond = only_type and (" and menu_item_type='%s'" % only_type) or ''
|
||||
|
||||
import webnotes
|
||||
roles = webnotes.user.get_roles()
|
||||
all_read = webnotes.user.can_get_report
|
||||
|
||||
cl = sql("select name, menu_item_label, menu_item_type, link_id, link_content, has_children, icon, `order`, criteria_name, doctype_fields, onload from `tabMenu Item` where ifnull(disabled,'No')!='Yes' and ifnull(parent_menu_item,'')='%s' %s order by `order` asc" % (arg, type_cond), as_dict=1)
|
||||
ol = []
|
||||
for c in cl:
|
||||
c['has_children'] = cint(c['has_children'])
|
||||
c['order'] = cint(c['order'])
|
||||
for k in c.keys():
|
||||
if c[k]==None: c[k] = ''
|
||||
|
||||
# check permission
|
||||
if c['menu_item_type'] in ('DocType','Single','Report'):
|
||||
if c['link_id'] in all_read:
|
||||
ol.append(c)
|
||||
elif c['menu_item_type']=='Page':
|
||||
# page
|
||||
if c['link_id'].startswith('_'):
|
||||
ol.append(c)
|
||||
elif has_common([r[0] for r in sql("select role from `tabPage Role` where parent=%s", c['link_id'])], roles):
|
||||
ol.append(c)
|
||||
elif cstr(c['menu_item_type'])=='':
|
||||
# sections
|
||||
if has_common([r[0] for r in sql("select role from `tabMenu Item Role` where parent=%s", c['name'])], roles):
|
||||
ol.append(c)
|
||||
else:
|
||||
ol.append(c)
|
||||
|
||||
return ol
|
||||
|
||||
# --------------------------------------------------------------
|
||||
def has_result(self, dt):
|
||||
return sql("select name from `tab%s` limit 1" % dt) and 'Yes' or 'No'
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def is_submittable(self, dt):
|
||||
return sql("select name from tabDocPerm where parent=%s and ifnull(submit,0)=1 and docstatus<1 limit 1", dt)
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def can_cancel(self, dt):
|
||||
return sql('select name from tabDocPerm where parent="%s" and ifnull(cancel,0)=1 and docstatus<1 and role in ("%s") limit 1' % (dt, '", "'.join(webnotes.user.get_roles())))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
def get_dt_trend(self, dt):
|
||||
ret = {}
|
||||
for r in sql("select datediff(now(),modified), count(*) from `tab%s` where datediff(now(),modified) between 0 and 30 group by date(modified)" % dt):
|
||||
ret[cint(r[0])] = cint(r[1])
|
||||
return ret
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_columns(self, out, sf, fl, dt):
|
||||
if not fl:
|
||||
fl = sf
|
||||
|
||||
res = []
|
||||
for f in fl:
|
||||
if f:
|
||||
res += [[c or '' for c in r] for r in sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname='%s'" % (dt, f))]
|
||||
|
||||
return res
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def check_user_tags(self, dt):
|
||||
try:
|
||||
sql("select `_user_tags` from `tab%s` limit 1" % dt)
|
||||
except Exception, e:
|
||||
if e.args[0] == 1054:
|
||||
webnotes.conn.commit()
|
||||
sql("alter table `tab%s` add column `_user_tags` varchar(180)" % dt)
|
||||
webnotes.conn.begin()
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# NOTE: THIS SHOULD BE CACHED IN DOCTYPE CACHE
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_dt_details(self, arg):
|
||||
dt, fl, color_map = eval(arg)
|
||||
submittable = self.is_submittable(dt) and 1 or 0
|
||||
|
||||
out = {
|
||||
'submittable':(self.is_submittable(dt) and 1 or 0),
|
||||
'can_cancel':(self.can_cancel(dt) and 1 or 0)
|
||||
}
|
||||
|
||||
# filters
|
||||
# -------
|
||||
|
||||
sf = sql("select search_fields from tabDocType where name=%s", dt)[0][0] or ''
|
||||
|
||||
# get fields from in_filter (if not in search_fields)
|
||||
if not sf.strip():
|
||||
res = sql("select fieldname, label, fieldtype, options from tabDocField where parent=%s and `in_filter` = 1 and ifnull(fieldname,'') != ''", dt)
|
||||
sf = [s[0] for s in res]
|
||||
else:
|
||||
sf = [s.strip() for s in sf.split(',')]
|
||||
res = sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname in (%s)" % (dt, '"'+'","'.join(sf)+'"'))
|
||||
|
||||
# select "link" options
|
||||
res = [[c or '' for c in r] for r in res]
|
||||
for r in res:
|
||||
if r[2]=='Select' and r[3] and r[3].startswith('link:'):
|
||||
tdt = r[3][5:]
|
||||
ol = sql("select name from `tab%s` where docstatus!=2 order by name asc" % tdt)
|
||||
r[3] = "\n".join([''] + [o[0] for o in ol])
|
||||
|
||||
if not res:
|
||||
out['filters'] = [['name', 'ID', 'Data', '']]
|
||||
else:
|
||||
out['filters'] = [['name', 'ID', 'Data', '']] + res
|
||||
|
||||
# columns
|
||||
# -------
|
||||
res = self.get_columns(out, sf, fl, dt)
|
||||
|
||||
self.check_user_tags(dt)
|
||||
|
||||
out['columns'] = [['name', 'ID', 'Link', dt], ['modified', 'Modified', 'Data', ''], ['_user_tags', 'Tags', 'Data', '']] + res
|
||||
|
||||
if cint(color_map):
|
||||
out['color_map'] = self.get_color_map()
|
||||
|
||||
return out
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_color_map(self):
|
||||
d={}
|
||||
try:
|
||||
for tag in sql("select name, tag_color from tabTag"):
|
||||
d[tag[0]] = tag[1]
|
||||
except Exception, e:
|
||||
if e.args[0] in (1146, 1054):
|
||||
return {}
|
||||
else:
|
||||
raise e
|
||||
return d
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_trend(self, dt):
|
||||
return {'trend': self.get_dt_trend(dt)}
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_tags(self, dt, dn):
|
||||
tl = sql("select ifnull(_user_tags,'') from tab%s where name=%s" % (dt,'%s'), dn)[0][0]
|
||||
return tl and tl.split(',') or []
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def update_tags(self, dt, dn, tl):
|
||||
if len(','.join(tl)) > 179:
|
||||
msgprint("Too many tags")
|
||||
raise Exception
|
||||
|
||||
tl = filter(lambda x: x, tl)
|
||||
|
||||
# update in table
|
||||
sql("update tab%s set _user_tags=%s where name=%s" % (dt,'%s','%s'), (',' + ','.join(tl), dn))
|
||||
|
||||
# update in feed (if present)
|
||||
sql("update tabFeed set _user_tags=%s where doc_label=%s and doc_name=%s", (',' + ','.join(tl), dt, dn))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def _add_tag_to_master(self, tag, color):
|
||||
if color:
|
||||
t, cond = color, ("on duplicate key update tag_color='%s'" % color)
|
||||
else:
|
||||
t, cond = 'Default', ''
|
||||
|
||||
sql("insert ignore into tabTag(name, tag_color) values ('%s', '%s') %s" % (tag, t, cond))
|
||||
|
||||
def create_tag(self, tag, color):
|
||||
try:
|
||||
self._add_tag_to_master(tag, color)
|
||||
except Exception, e:
|
||||
# add the table
|
||||
if e.args[0]==1146:
|
||||
webnotes.conn.commit()
|
||||
sql("create table `tabTag`(`name` varchar(180), tag_color varchar(180), primary key (`name`))")
|
||||
webnotes.conn.begin()
|
||||
self._add_tag_to_master(tag, color)
|
||||
|
||||
# udpate the color column
|
||||
if e.args[0]==1054:
|
||||
webnotes.conn.commit()
|
||||
sql("alter table tabTag add column tag_color varchar(180)")
|
||||
webnotes.conn.begin()
|
||||
self._add_tag_to_master(tag, color)
|
||||
|
||||
else:
|
||||
raise e
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def add_tag(self,arg):
|
||||
dt, dn, tag, color = eval(arg)
|
||||
|
||||
# create tag in tag table
|
||||
self.create_tag(tag, color)
|
||||
|
||||
# add in _user_tags
|
||||
tl = self.get_tags(dt, dn)
|
||||
|
||||
if not tag in tl:
|
||||
tl.append(tag)
|
||||
self.update_tags(dt, dn, tl)
|
||||
|
||||
return tag
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def remove_tag(self,arg):
|
||||
dt, dn, tag = eval(arg)
|
||||
tl = self.get_tags(dt, dn)
|
||||
self.update_tags(dt, dn, filter(lambda x:x!=tag, tl))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def delete_items(self,arg):
|
||||
il = eval(arg)
|
||||
from webnotes.model import delete_doc
|
||||
for d in il:
|
||||
dt_obj = get_obj(d[0], d[1])
|
||||
if hasattr(dt_obj, 'on_trash'):
|
||||
dt_obj.on_trash()
|
||||
delete_doc(d[0], d[1])
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def archive_items(self,arg):
|
||||
arg = eval(arg)
|
||||
|
||||
from webnotes.utils.archive import archive_doc
|
||||
for d in arg['items']:
|
||||
archive_doc(d[0], d[1], arg['action']=='Restore' and 1 or 0)
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-06-12 12:08:31', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 55, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': '', 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Menu Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
0
application_internal/doctype/message/__init__.py
Normal file
0
application_internal/doctype/message/__init__.py
Normal file
1
application_internal/doctype/message/message.txt
Normal file
1
application_internal/doctype/message/message.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-13 13:47:58', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': 1, 'read_only': 1, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 2, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'MSG.#####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'saumil@webnotestech.com', 'document_type': None, 'name': 'Message', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'saumil@webnotestech.com', 'name': 'PERM00770', 'parent': 'Message', 'read': 1, 'create': 1, 'creation': '2010-04-13 13:47:58', 'modified': '2010-08-08 15:03:43', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Customer', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'saumil@webnotestech.com', 'name': 'PERM00771', 'parent': 'Message', 'read': 1, 'create': 1, 'creation': '2010-04-13 13:47:58', 'modified': '2010-08-08 15:03:43', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 2, 'parenttype': 'DocType', 'role': 'Supplier', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'saumil@webnotestech.com', 'name': 'PERM00772', 'parent': 'Message', 'read': 1, 'create': 1, 'creation': '2010-04-13 13:47:58', 'modified': '2010-08-08 15:03:43', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 3, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-04-13 13:47:58', 'doctype': 'DocField', 'oldfieldname': 'subject', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Subject', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Message', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04639', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-08 15:03:43', 'parenttype': 'DocType', 'fieldname': 'subject', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2010-04-13 13:47:58', 'doctype': 'DocField', 'oldfieldname': 'message_type', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Message Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Message', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04641', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-08-08 15:03:43', 'parenttype': 'DocType', 'fieldname': 'message_type', 'fieldtype': 'Select', 'options': 'Enquiry\nFeedback\nComplaint\nSuggestion', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2010-04-13 13:47:58', 'doctype': 'DocField', 'oldfieldname': 'details', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'saumil@webnotestech.com', 'label': 'Details', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Message', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04640', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-08-08 15:03:43', 'parenttype': 'DocType', 'fieldname': 'details', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
|
||||
307
application_internal/doctype/message_control/message_control.py
Normal file
307
application_internal/doctype/message_control/message_control.py
Normal file
@@ -0,0 +1,307 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,doc,doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
#get list of unread messages
|
||||
#------------------------------------
|
||||
def get_unread_msg_lst(self,arg):
|
||||
ret = {}
|
||||
ret['ur_lst'] = convert_to_lists(sql("select t1.name from `tabMail` t1, `tabMail Participant Details` t2 where t2.participant_name = '%s' and t2.parent = t1.name and (t2.read_status = 'No' or t2.read_status is NULL) and (t2.delete_status = 'No' or t2.delete_status is NULL) and t1.last_updated_by != t2.participant_name" % arg))
|
||||
return ret
|
||||
|
||||
# get list of email participants at the time of reply msg. This will give name of iwebnotes user and email id of non iwebnotes user if envolved in that email
|
||||
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
def get_thread_details(self,arg):
|
||||
arg = eval(arg)
|
||||
ret = {}
|
||||
to_list3 = []
|
||||
|
||||
ret['tl'] = convert_to_lists(sql("select t1.subject,t1.message, t1.owner, t1.message_date, t1.main_thread_id, t2.first_name, t2.file_list from `tabMail` t1, `tabProfile` t2 where t1.main_thread_id='%s' and t2.name=t1.owner" % arg['cur_msg_id']))
|
||||
|
||||
to_user_list = sql("select participant_name from `tabMail Participant Details` where participant_name != '%s' and parent = '%s'" % (arg['user_name'], arg['cur_msg_id']))
|
||||
to_list1 = [x[0] for x in to_user_list]
|
||||
|
||||
non_member_dict = self.get_non_member_list(to_list1)
|
||||
non_member_list = non_member_dict['non_erp_user']
|
||||
|
||||
for m in to_list1:
|
||||
if m not in non_member_list:
|
||||
to_list2 = sql("select first_name from `tabProfile` where name = '%s'" % (m))
|
||||
to_list3.append(to_list2[0][0])
|
||||
|
||||
for y in non_member_list:
|
||||
to_list3.append(y)
|
||||
|
||||
ret['to_list'] = to_list3
|
||||
return ret
|
||||
|
||||
#validate message
|
||||
#---------------------
|
||||
def validate_message(self, msg, to_list = []):
|
||||
ml = ['subject','message']
|
||||
for m in ml:
|
||||
if not msg.fields.get(m):
|
||||
msgprint("error:To, Subject and Message are required. Please try again.")
|
||||
raise Exception
|
||||
|
||||
#get list of emails which are not registered on that iwebnotes account
|
||||
#----------------------------------------------------------------------------------
|
||||
def get_non_member_list(self, arg):
|
||||
to_list, ret, new_list, non_valid_lst, non_valid_lst_msg= arg, {}, [], [], ''
|
||||
|
||||
for m in to_list:
|
||||
check_user = sql("select name from `tabProfile` where name = '%s'" % m)
|
||||
check_user = check_user and check_user[0][0] or 'not_user'
|
||||
|
||||
if check_user == 'not_user':
|
||||
if not validate_email_add(m):
|
||||
non_valid_lst.append(m)
|
||||
else:
|
||||
new_list.append(m)
|
||||
|
||||
if non_valid_lst:
|
||||
for x in non_valid_lst:
|
||||
if non_valid_lst_msg == '' :
|
||||
non_valid_lst_msg = x
|
||||
else :
|
||||
non_valid_lst_msg = non_valid_lst_msg + ', ' + x
|
||||
msgprint("error:Incorrect email id format. Message can not be sent to following mentioned email-id(s)." + "\n" + "\n" + non_valid_lst_msg)
|
||||
|
||||
ret['non_erp_user'] = new_list
|
||||
ret['non_valid_lst'] = non_valid_lst
|
||||
return ret
|
||||
|
||||
#create message thread
|
||||
#----------------------------------
|
||||
def create_msg_thread(self, arg, to_list, new_msg):
|
||||
arg = eval(arg)
|
||||
msg_fld = {'message_date':nowdate(), 'owner':arg['user_name'], 'subject':arg['subject'], 'message':arg['message'], 'last_updated_on':nowdate(), 'last_updated_by':arg['user_name'], 'is_main_thread':new_msg and 'Yes' or 'No', 'to_user':new_msg and cstr(to_list) or '', 'from_user': new_msg and arg['user_name'] or '', 'previous_updated_by': new_msg and arg['user_name'] or ''}
|
||||
|
||||
msg = Document('Mail')
|
||||
for f in msg_fld:
|
||||
msg.fields[f]=msg_fld[f]
|
||||
if new_msg:
|
||||
self.validate_message(msg, to_list)
|
||||
if not new_msg:
|
||||
msg.main_thread_id = arg['message_id']
|
||||
msg.save(new=1)
|
||||
return msg.name
|
||||
|
||||
#add mail participants
|
||||
#---------------------------
|
||||
def add_mail_participants(self, participant, msg_id):
|
||||
fields = {'participant_name': participant, 'parent':msg_id, 'parenttype':'Mail', 'parentfield':'mail_participant'}
|
||||
child = Document('Mail Participant Details')
|
||||
for f in fields:
|
||||
child.fields[f]=fields[f]
|
||||
child.save(new=1)
|
||||
|
||||
#send email notification to personal id
|
||||
#-----------------------------------------------
|
||||
def email_to_personal_id(self, email_arg, non_member_list):
|
||||
message_subject =''
|
||||
if email_arg['participant'] not in non_member_list:
|
||||
r_full_nm = sql("select first_name from`tabProfile` where name = '%s'" % email_arg['participant'])
|
||||
r_full_nm = r_full_nm and r_full_nm[0][0] or ''
|
||||
|
||||
if not(email_arg['participant'] == email_arg['sender']):
|
||||
if email_arg['participant'] not in non_member_list:
|
||||
self.notification_email_to_members(email_arg['participant'],r_full_nm,email_arg['sender'],email_arg['sender_nm'])
|
||||
else :
|
||||
message_subject = 'Message from ' + cstr(email_arg['sender_nm']) + '- '
|
||||
if email_arg['new_msg']:
|
||||
message_subject=message_subject+ cstr(email_arg['mail_sub'])
|
||||
else:
|
||||
message_subject=message_subject+ 'Re: '+cstr(email_arg['mail_sub'])
|
||||
self.notification_email_to_non_members(email_arg['participant'], email_arg['sender'], email_arg['sender_nm'], message_subject, email_arg['mail_msg'])
|
||||
|
||||
#send new message
|
||||
#----------------------------
|
||||
def send_message(self,arg1):
|
||||
arg = eval(arg1)
|
||||
val, to_list1 = 'false', arg['to_list'].split(',')
|
||||
new_list = [l.strip() for l in to_list1 if l.strip()]
|
||||
|
||||
non_member_dict = self.get_non_member_list(new_list)
|
||||
non_member_list = non_member_dict['non_erp_user']
|
||||
non_valid_lst = non_member_dict['non_valid_lst']
|
||||
|
||||
if len(new_list) > len(non_valid_lst) :
|
||||
to_list = [m for m in new_list if m not in non_valid_lst]
|
||||
to_list.append(arg['user_name'])
|
||||
msg_id = self.create_msg_thread(arg1, to_list, 1)
|
||||
sql("update `tabMail` set main_thread_id = '%s' where name = '%s'" % (msg_id, msg_id))
|
||||
|
||||
s_full_nm = sql("select first_name from`tabProfile` where name = '%s'" % arg['user_name'])
|
||||
s_full_nm = s_full_nm and s_full_nm[0][0] or ''
|
||||
|
||||
for t in to_list:
|
||||
self.add_mail_participants(t,msg_id)
|
||||
val = 'true'
|
||||
|
||||
# email notification to personal email id
|
||||
email_arg = {'participant':t, 'sender':arg['user_name'], 'sender_nm':s_full_nm, 'mail_sub':arg['subject'], 'mail_msg':arg['message'], 'new_msg':1}
|
||||
self.email_to_personal_id(email_arg, non_member_list)
|
||||
return cstr(val)
|
||||
else :
|
||||
msgprint("error:Please mention preper email-ids. Message can not be sent.");
|
||||
|
||||
#update main msg thread
|
||||
#---------------------------------
|
||||
def update_main_thread_msg(self, arg):
|
||||
thread_msg = Document('Mail',arg['message_id'])
|
||||
thread_msg.last_updated_on = nowdate()
|
||||
if thread_msg.last_updated_by != session['user']:
|
||||
thread_msg.previous_updated_by = thread_msg.last_updated_by
|
||||
thread_msg.last_updated_by = arg['user_name']
|
||||
thread_msg.save()
|
||||
|
||||
#send reply msg
|
||||
#---------------------
|
||||
def send_reply(self,arg1):
|
||||
arg = eval(arg1)
|
||||
val = 'false'
|
||||
|
||||
if not arg['message']:
|
||||
msgprint("Please type some message")
|
||||
raise Exception
|
||||
|
||||
msg_id = self.create_msg_thread(arg1, '', 0)
|
||||
self.update_main_thread_msg(arg)
|
||||
|
||||
nm = sql("select name from `tabMail` where main_thread_id = '%s' and is_main_thread = 'Yes'" % arg['message_id'])
|
||||
msg_nm = nm and nm[0][0] or ''
|
||||
sql("update `tabMail Participant Details` set delete_status = 'No' where parent='%s'" % (msg_nm))
|
||||
sql("update `tabMail Participant Details` set read_status = 'No' where parent='%s' and participant_name != '%s'" % (msg_nm, session['user']))
|
||||
val = 'true'
|
||||
|
||||
p_nm = sql("select participant_name from `tabMail Participant Details` where parent='%s' and participant_name!='%s'"%(msg_nm, session['user']))
|
||||
if p_nm:
|
||||
p_nm_lst = [x[0] for x in p_nm]
|
||||
|
||||
non_member_dict = self.get_non_member_list(p_nm_lst)
|
||||
non_member_list = non_member_dict['non_erp_user']
|
||||
|
||||
s_full_nm = sql("select first_name from`tabProfile` where name = '%s'" % arg['user_name'])
|
||||
s_full_nm = s_full_nm and s_full_nm[0][0] or ''
|
||||
|
||||
for m in p_nm_lst:
|
||||
# email notification to personal email id
|
||||
email_arg = {'participant':m, 'sender':arg['user_name'], 'sender_nm':s_full_nm, 'mail_sub':arg['subject'], 'mail_msg':arg['message'], 'new_msg':0}
|
||||
self.email_to_personal_id(email_arg, non_member_list)
|
||||
return cstr(val)
|
||||
|
||||
#delete message
|
||||
#----------------------
|
||||
def delete_message(self, arg):
|
||||
m_arg = arg.split('~~')
|
||||
user_nm = m_arg[0]
|
||||
msg_lst = m_arg[1].split(',')
|
||||
msg_del = 'false'
|
||||
for i in msg_lst:
|
||||
sql("update `tabMail Participant Details` set delete_status = 'Yes' where parent='%s' and participant_name = '%s'" % (i, user_nm))
|
||||
msg_del = 'true'
|
||||
return cstr(msg_del)
|
||||
|
||||
# set read or unread status of message
|
||||
#---------------------------------------------
|
||||
def read_unread_message(self,arg):
|
||||
arg = eval(arg);
|
||||
sql("update `tabMail Participant Details` set read_status = '%s' where parent='%s' and participant_name = '%s'" % (arg['read'],arg['msg'], arg['user']))
|
||||
|
||||
# function for checking message is already read or not
|
||||
#--------------------------------------------------------------
|
||||
def check_read(self,arg):
|
||||
arg = eval(arg);
|
||||
chk_val=sql("select read_status from `tabMail Participant Details` where parent='%s' and participant_name = '%s'" % (arg['msg'], arg['user']))[0][0] or ''
|
||||
if chk_val == '':
|
||||
chk_val = 'blank'
|
||||
|
||||
return cstr(chk_val)
|
||||
|
||||
#list of autosuggested users for 'to list'
|
||||
#-----------------------------------------------
|
||||
def get_to_list(self, arg):
|
||||
li = sql("select name, first_name from `tabProfile` where first_name like '%s%%' and name!='%s' and name!='Guest' limit 10" % (arg.strip(), session['user']))
|
||||
li = [{'id':l[0], 'value':l[0], 'info':l[1]} for l in li]
|
||||
return {'results':li}
|
||||
|
||||
# unread message count
|
||||
#--------------------------
|
||||
def get_unread_msg_count(self, arg):
|
||||
ret = convert_to_lists(sql("select count(t1.name) from `tabMail` t1, `tabMail Participant Details` t2 where t2.participant_name = '%s' and t2.parent = t1.name and (t2.read_status = 'No' or t2.read_status is NULL) and (t2.delete_status = 'No' or t2.delete_status is NULL) and t1.last_updated_by != t2.participant_name" % arg))
|
||||
|
||||
if ret:
|
||||
return cstr(ret[0][0])
|
||||
else:
|
||||
return cstr(0)
|
||||
|
||||
# email notification to personal email id of registered users
|
||||
#--------------------------------------------------------------------
|
||||
def notification_email_to_members(self, receiver_id, r_full_nm, sender_id, s_full_nm):
|
||||
msg = """
|
||||
<html>
|
||||
<body>
|
||||
|
||||
Dear %s,<br><br>
|
||||
You have received a new message from %s.<br>
|
||||
|
||||
To check the message, visit Inbox of erpnext.<br><br>
|
||||
Stay connected using the link:<br><br>
|
||||
<div><a href ='https://www.erpnext.com' target ='_blank'> https://www.erpnext.com</a></div><br><br>
|
||||
|
||||
Thank You,<br><br>
|
||||
Administrator<br>
|
||||
erpnext
|
||||
</body>
|
||||
</html>
|
||||
""" % (r_full_nm, s_full_nm)
|
||||
|
||||
# send email
|
||||
sendmail([receiver_id], sender = sender_id, msg=msg, subject='ERP - You have received a new message')
|
||||
|
||||
# email to non ERP member's personal id
|
||||
#-------------------------------------------------------
|
||||
def notification_email_to_non_members(self, receiver_id, sender_id, s_full_nm, message_subject, message):
|
||||
msg = """
|
||||
<html>
|
||||
<body>
|
||||
|
||||
Hi,<br><br>
|
||||
You have received a new message from %s via erpnext.<br><br>
|
||||
Message:<br>
|
||||
%s<br><br>
|
||||
|
||||
Not on erpnext? Sign up now! <br>
|
||||
Stay connected using the link:<br><br>
|
||||
<div><a href ='https://www.erpnext.com' target ='_blank'> https://www.erpnext.com</a></div><br><br>
|
||||
|
||||
Thank You,<br><br>
|
||||
Administrator<br>
|
||||
erpnext
|
||||
</body>
|
||||
</html>
|
||||
""" % (s_full_nm, message)
|
||||
|
||||
# send email
|
||||
sendmail([receiver_id], sender = sender_id, msg=msg, subject=message_subject)
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-06-07 11:26:34', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 17, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'saumil@webnotestech.com', 'document_type': '', 'name': 'Message Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-10-04 14:20:37', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
25
application_internal/doctype/module_setter/module_setter.py
Normal file
25
application_internal/doctype/module_setter/module_setter.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d,dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
def set_module(self):
|
||||
sql("update tabDocType set module=%s where name=%s", (self.doc.module, self.doc.doc_type))
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-03-12 12:36:55', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 4, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Module Setter', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': '', 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM00143', 'parent': 'Module Setter', 'read': 1, 'create': 1, 'creation': '2009-03-12 12:36:55', 'modified': '2010-03-31 10:42:15', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:36:55', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Doc Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Module Setter', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01328', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-03-31 10:42:15', 'parenttype': 'DocType', 'fieldname': 'doc_type', 'fieldtype': 'Select', 'options': 'link:DocType', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:36:55', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Module', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Module Setter', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01329', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-03-31 10:42:15', 'parenttype': 'DocType', 'fieldname': 'module', 'fieldtype': 'Select', 'options': 'link:Module Def', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': None, 'creation': '2009-03-12 12:36:55', 'doctype': 'DocField', 'oldfieldname': None, 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Set', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Module Setter', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01330', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-03-31 10:42:15', 'parenttype': 'DocType', 'fieldname': None, 'fieldtype': 'Button', 'options': 'set_module', 'report_hide': None, 'parentfield': 'fields'}]
|
||||
@@ -0,0 +1,34 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
# get update on recent activities of module
|
||||
# -----------------------------------------
|
||||
def get_module_activity(self, args):
|
||||
args = eval(args)
|
||||
ret = {}
|
||||
for tr in args['tr_list']:
|
||||
cnt = sql("select ifnull(count(name),0) from `tab%s` where datediff(now(),creation) between 0 and 7"%(tr))
|
||||
if cnt[0][0]:
|
||||
ret[tr] = cnt
|
||||
if ret:
|
||||
return ret
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-05-10 12:54:12', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 30, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': '', 'name': 'Module Tip Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-11-08 11:50:50', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
@@ -0,0 +1,158 @@
|
||||
cur_frm.cscript.is_list = function(d) { return d.modules_or_list=='List' ? 1 : 0 }
|
||||
cur_frm.cscript.is_modules = function(d) { return d.modules_or_list=='Modules' ? 1 : 0 }
|
||||
|
||||
cur_frm.cscript['Do Transfer'] = function(doc) {
|
||||
al = getchildren('Transfer Account', doc.name, 'transfer_accounts');
|
||||
ml = getchildren('Transfer Module', doc.name, 'transfer_modules');
|
||||
sl = doc.selected_list.split(NEWLINE)
|
||||
|
||||
cur_frm.cscript.cancel_transfer = 0;
|
||||
|
||||
cur_frm.cscript.do_list = [];
|
||||
|
||||
// for each account
|
||||
for(var ai = 0; ai < al.length; ai++) {
|
||||
|
||||
|
||||
// if transfer
|
||||
if(cint(al[ai].transfer)) {
|
||||
|
||||
// module
|
||||
// ------
|
||||
if(doc.modules_or_list == 'Modules') {
|
||||
|
||||
for(var mi = 0; mi < ml.length; mi++) {
|
||||
|
||||
if(ml[mi].transfer) {
|
||||
var args = {server:al[ai].server, path:al[ai].path, pwd:al[ai].admin_password, act: al[ai].account, module:ml[mi].module, transfer_what:doc.transfer_what}
|
||||
cur_frm.cscript.do_list.push(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// list
|
||||
// ------
|
||||
if(doc.modules_or_list == 'List') {
|
||||
|
||||
for(var si = 0; si < sl.length; si++) {
|
||||
if(sl[si]){
|
||||
var s = sl[si].split(',');
|
||||
var args = {server:al[ai].server, path:al[ai].path, pwd:al[ai].admin_password, act: al[ai].account, dt: strip(s[0]), dn:strip(s[1]), transfer_what:doc.transfer_what}
|
||||
cur_frm.cscript.do_list.push(args);}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
locals[doc.doctype][doc.name].transfer_log = 'Transferring...'.bold();
|
||||
refresh_field('transfer_log');
|
||||
|
||||
if(cur_frm.cscript.do_list.length)
|
||||
cur_frm.cscript.do_next();
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.do_next = function() {
|
||||
|
||||
if(cur_frm.cscript.do_list.length){
|
||||
var t = cur_frm.cscript.do_list[0];
|
||||
|
||||
// do transfer
|
||||
|
||||
locals[doc.doctype][doc.name].transfer_log += '<br>Transferring... Account:' + t.act + ':' + t.module + ', Record:'+t.dt + ',' + t.dn;
|
||||
refresh_field('transfer_log');
|
||||
|
||||
$c_obj(make_doclist(doc.doctype, doc.name), 'do_transfer', docstring(t), cur_frm.cscript.ret_fn);
|
||||
|
||||
|
||||
// remove from list
|
||||
var tmp = [];
|
||||
for(var i=1;i<cur_frm.cscript.do_list.length;i++)tmp.push(cur_frm.cscript.do_list[i]);
|
||||
cur_frm.cscript.do_list = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.ret_fn = function(r,rt) {
|
||||
locals[doc.doctype][doc.name].transfer_log += '<br>' + r.message;
|
||||
refresh_field('transfer_log');
|
||||
|
||||
|
||||
if(cur_frm.cscript.do_list.length <= 0) {
|
||||
locals[doc.doctype][doc.name].transfer_log += '<br><b>Completed!</b>';
|
||||
refresh_field('transfer_log');
|
||||
return;
|
||||
}
|
||||
if(!cur_frm.cscript.cancel_transfer)
|
||||
cur_frm.cscript.do_next();
|
||||
else {
|
||||
locals[doc.doctype][doc.name].transfer_log += '<br><b>Cancelled!</b>';
|
||||
refresh_field('transfer_log');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Cancel Transfer'] = function(doc,dt,dn) {
|
||||
cur_frm.cscript.cancel_transfer = 1;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------- running remote script in account selected-----------------------*/
|
||||
|
||||
cur_frm.cscript['Update Accounts'] = function(doc) {
|
||||
var al = getchildren('Transfer Account', doc.name, 'transfer_accounts');
|
||||
|
||||
cur_frm.cscript.update_list = [];
|
||||
cur_frm.cscript.cancel_updates = 0;
|
||||
|
||||
for(var ai = 0; ai < al.length; ai++) {
|
||||
if(cint(al[ai].transfer)){
|
||||
var args = {server:al[ai].server, path:al[ai].path, pwd:al[ai].admin_password, act: al[ai].account};
|
||||
cur_frm.cscript.update_list.push(args);
|
||||
}
|
||||
}
|
||||
|
||||
locals[doc.doctype][doc.name].transfer_log = 'Updating...'.bold();
|
||||
refresh_field('transfer_log');
|
||||
|
||||
if(cur_frm.cscript.update_list.length)
|
||||
cur_frm.cscript.update_accounts();
|
||||
}
|
||||
|
||||
cur_frm.cscript.update_accounts = function(){
|
||||
if(cur_frm.cscript.update_list.length){
|
||||
var t = cur_frm.cscript.update_list[0];
|
||||
|
||||
// update account
|
||||
locals[doc.doctype][doc.name].transfer_log += '<br>Updating... Account:' + t.act;
|
||||
refresh_field('transfer_log');
|
||||
|
||||
$c_obj(make_doclist(doc.doctype, doc.name), 'execute_remote_code', docstring(t), cur_frm.cscript.accounts_updated);
|
||||
|
||||
// remove from list
|
||||
var tmp = [];
|
||||
for(var i=1;i<cur_frm.cscript.update_list.length;i++)tmp.push(cur_frm.cscript.update_list[i]);
|
||||
cur_frm.cscript.update_list = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.accounts_updated = function(r,rt){
|
||||
locals[doc.doctype][doc.name].transfer_log += '<br>' + r.message;
|
||||
refresh_field('transfer_log');
|
||||
|
||||
if(cur_frm.cscript.update_list.length <= 0) {
|
||||
locals[doc.doctype][doc.name].transfer_log += '<br><b>Completed!</b>';
|
||||
refresh_field('transfer_log');
|
||||
return;
|
||||
}
|
||||
if(!cur_frm.cscript.cancel_updates)
|
||||
cur_frm.cscript.update_accounts();
|
||||
else {
|
||||
locals[doc.doctype][doc.name].transfer_log += '<br><b>Cancelled!</b>';
|
||||
refresh_field('transfer_log');
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Cancel Updates'] = function(doc,dt,dn) {
|
||||
cur_frm.cscript.cancel_updates = 1;
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
# Modules
|
||||
# -----------
|
||||
|
||||
def get_module_items(self, mod, only_dt=0):
|
||||
dl = []
|
||||
if only_dt:
|
||||
transfer_types = ['DocType']
|
||||
else:
|
||||
transfer_types = ['Role', 'Print Format','DocType', 'Page', 'DocType Mapper', 'Search Criteria','Menu Item']
|
||||
dl = ['Module Def,'+mod]
|
||||
|
||||
for dt in transfer_types:
|
||||
try:
|
||||
dl2 = sql('select name from `tab%s` where module="%s"' % (dt,mod))
|
||||
dl += [(dt+','+e[0]) for e in dl2]
|
||||
except:
|
||||
pass
|
||||
|
||||
if not only_dt:
|
||||
dl1 = sql('select doctype_list from `tabModule Def` where name=%s', mod)
|
||||
dl += dl1[0][0].split("\n")
|
||||
|
||||
# build finally
|
||||
dl = [e.split(',') for e in dl]
|
||||
dl = [[e[0].strip(), e[1].strip()] for e in dl] # remove blanks
|
||||
return dl
|
||||
|
||||
def do_transfer(self, arg):
|
||||
import datetime
|
||||
arg = eval(arg)
|
||||
# server, path, act, pwd, dt, dn, module
|
||||
|
||||
standard_menu_items = "" # to store all standard menu items in remote account
|
||||
super_doclist = [] # to make the list of all doctypes to transfer and then send together
|
||||
modified_time = ''
|
||||
# get dt list
|
||||
# -----------
|
||||
|
||||
dt_only = 1
|
||||
if arg['transfer_what']=='Everything':
|
||||
dt_only = 0
|
||||
|
||||
if arg.get('module'):
|
||||
dtl = self.get_module_items(arg['module'], dt_only)
|
||||
else:
|
||||
dtl = [[arg['dt'], arg['dn']]]
|
||||
|
||||
# login to target
|
||||
# ---------------
|
||||
|
||||
rem_serv = FrameworkServer(arg.get('server'),arg.get('path'),"Administrator",arg.get('pwd'),arg.get('act', ''))
|
||||
|
||||
msg = []
|
||||
for dt in dtl:
|
||||
|
||||
transfer = 1
|
||||
# check version
|
||||
# -------------
|
||||
if dt[0]=='DocType':
|
||||
get_modified_time = '''msgprint(sql("SELECT modified FROM `tab%s` WHERE name = '%s'"))''' %(dt[0],dt[1])
|
||||
ret = rem_serv.runserverobj('Control Panel','Control Panel','execute_test',get_modified_time)
|
||||
if ret.get('exc'):
|
||||
msg.append(ret['exc'])
|
||||
elif eval(ret.get('server_messages')): # get modified time
|
||||
modified_time = eval(ret.get('server_messages'))
|
||||
for t in modified_time:
|
||||
original_date = sql("select modified from `tab%s` where name = '%s'"%(dt[0],dt[1]))
|
||||
if cstr(t[0])==cstr(original_date[0][0]):
|
||||
transfer = 0
|
||||
msg.append("DocType '%s' is already transferred"%(dt[1]))
|
||||
else:
|
||||
transfer = 1
|
||||
|
||||
# transfer menu items
|
||||
# -------------------------
|
||||
if dt[0]=='Menu Item' or dt[0]=='Print Format' or dt[0]=='Search Criteria' or dt[0]=='Page':
|
||||
# get name and standard field of all menu items
|
||||
get_standard_menu_items = '''msgprint(sql("SELECT name, standard, modified FROM `tab%s` WHERE name = '%s'"))''' %(dt[0],dt[1])
|
||||
ret = rem_serv.runserverobj('Control Panel','Control Panel','execute_test',get_standard_menu_items)
|
||||
if ret.get('exc'):
|
||||
msg.append(ret['exc'])
|
||||
elif eval(ret.get('server_messages')): # checks for standard menu items
|
||||
standard_menu_items = eval(ret.get('server_messages'))
|
||||
for sml in standard_menu_items:
|
||||
original_date = sql("select modified from `tab%s` where name = '%s'"%(dt[0],sml[0]))
|
||||
if sml[1] == 'Yes' and cmp(sml[2],original_date[0][0]) != 0:
|
||||
super_doclist.append(self.transfer(dt[0], sml[0]))
|
||||
else:
|
||||
msg.append(dt[0]+" : "+dt[1]+" is customized or already transferred.")
|
||||
transfer = 0
|
||||
|
||||
elif not eval(ret.get('server_messages')): # for first time entry
|
||||
transfer = 1
|
||||
|
||||
if transfer != 0:
|
||||
super_doclist.append(self.transfer(dt[0], dt[1]))
|
||||
|
||||
if super_doclist:
|
||||
myargs = { 'ovr': 1, 'ignore': 1, 'onupdate': 1, 'super_doclist': {'super_doclist':super_doclist} }
|
||||
res = rem_serv.http_get_response(method = 'acctr_remote_setdoclist', args = myargs)
|
||||
data = eval(res.read())
|
||||
msg.append(data['message'])
|
||||
|
||||
if data.has_key('exc'):
|
||||
msg.append(data['exc'])
|
||||
|
||||
return '<br>'.join(msg)
|
||||
|
||||
def transfer(self, dt, dn):
|
||||
tl = getdoc(dt, dn)
|
||||
# clean up
|
||||
no_export_fields = ('creation','modified_by','owner','server_code_compiled','recent_documents','oldfieldtype','oldfieldname','superclass','ss_colourkey','has_monitors','onupdate','permtype','no_copy', 'print_hide','transaction_safe','setup_test')
|
||||
|
||||
for d in tl:
|
||||
for f in no_export_fields:
|
||||
if d.fields.has_key(f): del d.fields[f]
|
||||
|
||||
return [d.fields for d in tl]
|
||||
|
||||
|
||||
# run remote script
|
||||
# ----------------------------------------
|
||||
|
||||
def execute_remote_code(self, arg):
|
||||
msg = []
|
||||
arg = eval(arg)
|
||||
remote_server = FrameworkServer(arg.get('server'),arg.get('path'),"Administrator",arg.get('pwd'),arg.get('act', ''))
|
||||
ret = remote_server.runserverobj('Control Panel','Control Panel','execute_test',self.doc.remote_code)
|
||||
if ret.get('exc'):
|
||||
msg.append(ret['exc'])
|
||||
else:
|
||||
if ret.get('server_messages'): # this returns msg in msgprints from remote account
|
||||
msgprint(arg.get('act')+':')
|
||||
msgprint(ret['server_messages'])
|
||||
msg.append(arg.get('act')+" updated")
|
||||
return '<br>'.join(msg)
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,40 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def get_date_diff(self):
|
||||
if session['user'] != 'Administrator' and session['user'] != 'Demo':
|
||||
last_pwd_date = sql("select password_last_updated from tabProfile where name=%s",session['user'])[0][0] or ''
|
||||
if cstr(last_pwd_date) == '':
|
||||
sql("update tabProfile set password_last_updated = '%s' where name='%s'"% (nowdate(),session['user']))
|
||||
else:
|
||||
date_diff = (getdate(nowdate()) -last_pwd_date).days
|
||||
return date_diff
|
||||
|
||||
def get_cur_pwd(self):
|
||||
if session['user'] != 'Administrator' and session['user'] != 'Demo':
|
||||
cur_pwd = sql("select password from tabProfile where name=%s",session['user'])[0][0] or ''
|
||||
return cur_pwd
|
||||
|
||||
def reset_password(self,pwd):
|
||||
sql("update tabProfile set password= '%s',password_last_updated='%s' where name = '%s'" % (pwd,nowdate(),session['user']))
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-05-25 17:17:29', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 7, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Password Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
0
application_internal/doctype/patch_util/__init__.py
Normal file
0
application_internal/doctype/patch_util/__init__.py
Normal file
101
application_internal/doctype/patch_util/patch_util.py
Normal file
101
application_internal/doctype/patch_util/patch_util.py
Normal file
@@ -0,0 +1,101 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def get_field_id(self, doctype, fieldname):
|
||||
f = sql("select name, idx from tabDocField where parent=%s and fieldname=%s", (doctype, fieldname))
|
||||
if not f:
|
||||
f=sql("select name, idx from tabDocField where parent=%s and label=%s", (doctype, fieldname))
|
||||
if not f:
|
||||
return '__notfound__', 0
|
||||
#msgprint("No field found for %s" % fieldname)
|
||||
#raise Exception
|
||||
return f[0]
|
||||
|
||||
def set_field_property(self, doctype, fieldname, property, value):
|
||||
f = self.get_field_id(doctype, fieldname)
|
||||
sql("update tabDocField set `%s`=%s where name=%s" % (property,'%s','%s'), (value, f[0]))
|
||||
|
||||
def move_field(self, doctype, fieldname, before_field='', after_field=''):
|
||||
f1 = self.get_field_id(doctype, fieldname)
|
||||
|
||||
# get new id
|
||||
new_idx = self.get_field_id(doctype, before_field or after_field)[1]
|
||||
if after_field:
|
||||
new_idx = new_idx + 1
|
||||
|
||||
# push fields down at new idx
|
||||
sql("update tabDocField set idx=idx+1 where idx>=%s and parent=%s", (new_idx, doctype))
|
||||
|
||||
# push fields up at old idx
|
||||
sql("update tabDocField set idx=idx-1 where idx>%s and parent=%s", (f1[1], doctype))
|
||||
|
||||
# set field idx
|
||||
sql("update tabDocField set idx=%s where name=%s", (new_idx, f1[0]))
|
||||
|
||||
def delete_field(self, doctype, fieldname):
|
||||
sql("delete from tabDocField where name=%s limit 1", self.get_field_id(doctype, fieldname)[0])
|
||||
|
||||
def delete_unnamed_field(self, doctype, after_field=''):
|
||||
f1 = self.get_field_id(doctype, after_field)
|
||||
|
||||
if f1[0]=='__notfound__':
|
||||
return
|
||||
|
||||
# check if truly un-named
|
||||
f2 = sql("select name, fieldname, label from tabDocField where idx=%s and parent=%s limit 1", (f1[1]+1, doctype))
|
||||
|
||||
if not f2:
|
||||
return
|
||||
f2 = f2[0]
|
||||
|
||||
if f2[1] or f2[2]:
|
||||
return
|
||||
else:
|
||||
sql("delete from tabDocField where name=%s limit 1", (f2[0]))
|
||||
|
||||
# move fields up
|
||||
sql("update tabDocField set idx=idx-1 where idx>%s and parent=%s", (f1[1], doctype))
|
||||
|
||||
def add_permission(self, doctype, role, level=0, read=0, write=0, create=0, submit=0, cancel=0, amend=0, match=''):
|
||||
# check if exists
|
||||
pid = sql("select name from tabDocPerm where parent=%s and role=%s and permlevel=%s", (doctype, role, level))
|
||||
if pid:
|
||||
d = Document('DocPerm', pid[0][0])
|
||||
else:
|
||||
d = Document('DocPerm')
|
||||
d.parent = doctype
|
||||
d.parenttype = 'DocType'
|
||||
d.parentfield = 'permissions'
|
||||
|
||||
d.role = role
|
||||
d.read = read
|
||||
d.write = write
|
||||
d.create = create
|
||||
d.submit = submit
|
||||
d.cancel = cancel
|
||||
d.amend = amend
|
||||
d.match = match
|
||||
|
||||
d.save(new = (not d.name and 1 or 0))
|
||||
|
||||
def delete_permission(self, doctype, role, level):
|
||||
sql("delete from `tabDocPerm` where role = '%s' and parent = '%s' and permlevel = '%s'" % (role, doctype, level))
|
||||
1
application_internal/doctype/patch_util/patch_util.txt
Normal file
1
application_internal/doctype/patch_util/patch_util.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-12-15 09:56:48', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 6, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': '', 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': '', 'name': 'Patch Util', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-12-24 13:28:08', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
@@ -0,0 +1,78 @@
|
||||
// Global dictionary of next steps for doctypes
|
||||
// ============================================
|
||||
pscript.payroll_tip_dict = {'Employee':['Payroll Rule', 'Salary Structure'], 'Salary Structure':['IT Checklist', 'Salary Slip']};
|
||||
|
||||
// Set tips depending on conditions
|
||||
// ================================
|
||||
cur_frm.cscript.get_tips = function(doc, cdt, cdn)
|
||||
{
|
||||
|
||||
var next_step_list = pscript.payroll_tip_dict[cur_frm.doctype];
|
||||
|
||||
// from is shown in print format
|
||||
if(!cur_frm.editable){
|
||||
cur_frm.set_tip("Click on the <div style='font-weight:bold; display:inline'>Edit</div> button above to edit this " + cur_frm.doctype + ".");
|
||||
}
|
||||
|
||||
// form is not in print format
|
||||
if(cur_frm.editable){
|
||||
// new doc
|
||||
if(doc.__islocal){
|
||||
if(doc.status=='Cancelled' || doc.amended_from)
|
||||
cur_frm.set_tip("You can now make changes in this " + cur_frm.doctype + " and save it by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
|
||||
// doc is completely new
|
||||
else{
|
||||
// For Salary Slip
|
||||
if(cur_frm.doctype=='Salary Slip'){
|
||||
cur_frm.set_tip("To create " + cur_frm.doctype + " please enter all the details and save it by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
cur_frm.append_tip("To calculate earnings and deductions click on <div style='font-weight:bold; display:inline'>Process Payroll</div> button after saving the form");
|
||||
}
|
||||
// For IT Checklist
|
||||
else if(cur_frm.doctype=='IT Checklist'){
|
||||
cur_frm.set_tip("To create " + cur_frm.doctype + " please enter all the details and click on <div style='font-weight:bold; display:inline'>Done</div> button below to fetch all the details in the remaining tabs.");
|
||||
cur_frm.append_tip("To calculate taxes, please enter the actual amount in all the tables in the remaining tabs and click on <div style='font-weight:bold; display:inline'>Calculate</div> button in the <div style='font-weight:bold; display:inline'>Total Taxable Income</div> tab.");
|
||||
}
|
||||
// For Others
|
||||
else
|
||||
cur_frm.set_tip("To create " + cur_frm.doctype + " please start by entering all the mandatory fields(marked <div style='color:Red; display:inline'> Red</div>).<br><br> You can then save this form by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
}
|
||||
}
|
||||
|
||||
// doc exists
|
||||
else if(!doc.__islocal){
|
||||
// execute when doc is saved
|
||||
if(doc.docstatus==0 && cur_frm.doctype=='Salary Slip'){
|
||||
cur_frm.set_tip("You have saved your " + cur_frm.doctype + ". To calculate earnings and deductions click on <div style='font-weight:bold; display:inline'>Process Payroll</div> button below.");
|
||||
cur_frm.append_tip("You can make this draft permanent by clicking on <div style='font-weight:bold; display:inline'>Submit</div> button above.")
|
||||
}
|
||||
|
||||
// execute if doc is submitted
|
||||
else if(doc.docstatus==1 && cur_frm.doctype=='Salary Slip'){
|
||||
cur_frm.set_tip("You have submitted this " + cur_frm.doctype + ".");
|
||||
cur_frm.append_tip("(To make changes in this "+ cur_frm.doctype + " click on the <div style='font-weight:bold; display:inline'>Cancel</div> button above.)");
|
||||
}
|
||||
|
||||
// execute if doc has only save permission
|
||||
else if(doc.docstatus==0 && (cur_frm.doctype=='IT Checklist' || cur_frm.doctype=='Salary Structure' || cur_frm.doctype=='Employee')){
|
||||
cur_frm.set_tip("You have saved this " + cur_frm.doctype + ".");
|
||||
|
||||
for(var i=0; i<next_step_list.length; i++){
|
||||
if(i==0) cur_frm.append_tip("To proceed select the Next Steps tab below and click the button to create " + next_step_list[i] +".");
|
||||
else cur_frm.append_tip("You can also create a " + next_step_list[i] + " for this " + cur_frm.doctype + ".");
|
||||
}
|
||||
}
|
||||
|
||||
// execute when doc is amended
|
||||
else if(doc.docstatus==2){
|
||||
cur_frm.set_tip("To make this " + cur_frm.doctype + " editable click on the <div style='font-weight:bold; display:inline'>Amend</div> button above.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Executes when doc is edit status of doc is changed
|
||||
// ==================================================
|
||||
cur_frm.cscript.edit_status_changed = function(doc, cdt, cdn){
|
||||
cur_frm.cscript.get_tips();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-05-28 14:31:18', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 9, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'harshada@webnotestech.com', 'document_type': '', 'name': 'Payroll Tips Common', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-11-03 10:13:58', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
@@ -0,0 +1,71 @@
|
||||
// Global dictionary of next steps for doctypes
|
||||
// ============================================
|
||||
pscript.tip_prod_dict = {'Production Order':['Material Transfer', 'Backflush']};
|
||||
|
||||
|
||||
// Set tips depending on conditions
|
||||
// ================================
|
||||
cur_frm.cscript.get_tips = function(doc, cdt, cdn){
|
||||
var next_step_list = pscript.tip_prod_dict[cur_frm.doctype] ? pscript.tip_prod_dict[cur_frm.doctype] : 0;
|
||||
|
||||
if(cur_frm.doctype!='Production Planning Tool'){
|
||||
// new doc
|
||||
if(doc.__islocal){
|
||||
if(doc.status=='Cancelled' || doc.amended_from)
|
||||
cur_frm.set_tip("You can now make changes in this " + cur_frm.doctype + " and save it by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
else{
|
||||
cur_frm.set_tip("To create " + cur_frm.doctype + " please start by entering all the mandatory fields (marked <div style='color:Red; display:inline'> Red</div>).");
|
||||
if(cur_frm.doctype=='Stock Entry') cur_frm.append_tip("If your purpose is Production Order, please go to <div style='font-weight:bold; display:inline'>Items</div> tab and click <div style='font-weight:bold; display:inline'>Get Items</div> to fetch the items.");
|
||||
cur_frm.append_tip("You can then save this form by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
}
|
||||
}
|
||||
|
||||
// doc exists
|
||||
else if(!doc.__islocal){
|
||||
// execute when doc is saved
|
||||
if(doc.docstatus==0 && cur_frm.doctype!='Production Planning Tool')
|
||||
cur_frm.set_tip("You have saved your " + cur_frm.doctype + ". You can make this draft permanent by clicking on <div style='font-weight:bold; display:inline'>Submit</div> button above.");
|
||||
|
||||
// execute if doc is submitted
|
||||
else if(doc.docstatus==1){
|
||||
cur_frm.set_tip("You have submitted this " + cur_frm.doctype + ".");
|
||||
for(var i=0; i<next_step_list.length; i++){
|
||||
if(i==0) cur_frm.append_tip("To proceed select the <div style='font-weight:bold; display:inline'>Next Steps</div> tab below. To transfer raw materials to Finished Goods Warehouse click on <div style='font-weight:bold; display:inline'>" + next_step_list[i] +"</div>.");
|
||||
else cur_frm.append_tip("To update the quantity of finished goods and raw materials in their respective warehouses click on <div style='font-weight:bold; display:inline'>" + next_step_list[i] + "</div>.");
|
||||
}
|
||||
cur_frm.append_tip("(To amend this "+ cur_frm.doctype + " click on the <div style='font-weight:bold; display:inline'>Cancel</div> button above.)");
|
||||
}
|
||||
|
||||
// execute when doc is amended
|
||||
else if(doc.docstatus==2){
|
||||
cur_frm.set_tip("To make this " + cur_frm.doctype + " editable click on the <div style='font-weight:bold; display:inline'>Amend</div> button above.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Execute if current doctype is Production Planning Tool
|
||||
// ======================================================
|
||||
cur_frm.cscript.get_PPT_tips = function(doc, cdt, cdn)
|
||||
{
|
||||
cur_frm.set_tip('Welcome to Production Planning Wizard. This helps you to raise production order and see your raw material status as you plan your production.');
|
||||
cur_frm.append_tip("To start fetch all open Production Orders and Sales Orders by clicking on the <div style='font-weight:bold; display:inline'>Get Open Documents</div> button in the <div style='font-weight:bold; display:inline'>Against Document</div> tab below");
|
||||
|
||||
cur_frm.cscript['Get Open Documents'] = function(doc, cdt, cdn){
|
||||
cur_frm.set_tip("To include the required orders in the Production Plan check mark the <div style='font-weight:bold; display:inline'>Include In Plan</div> cell below.");
|
||||
cur_frm.append_tip("Next you can go to the <div style='font-weight:bold; display:inline'>Items</div> tab and click on <div style='font-weight:bold; display:inline'>Get Items</div> button to fetch the items of the selected orders.");
|
||||
}
|
||||
|
||||
cur_frm.cscript['Get Items'] = function(doc, cdt, cdn){
|
||||
cur_frm.set_tip("Now to raise a Production Order just click on <div style='font-weight:bold; display:inline'>Raise Production Ordre</div> button below the table.");
|
||||
cur_frm.append_tip("In order to see the Raw Material Report click on <div style='font-weight:bold; display:inline'>Get Raw Material Report</div> button below the table.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Executes when doc is edit status of doc is changed
|
||||
// ==================================================
|
||||
cur_frm.cscript.edit_status_changed = function(doc, cdt, cdn){
|
||||
cur_frm.cscript.get_tips();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-05-31 11:03:13', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 37, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Production Tips Common', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
187
application_internal/doctype/profile_control/profile_control.py
Normal file
187
application_internal/doctype/profile_control/profile_control.py
Normal file
@@ -0,0 +1,187 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
self.last_profile = None
|
||||
|
||||
# Sync Profile with Gateway
|
||||
# -------------------------
|
||||
def sync_with_gateway(self,pid):
|
||||
p = Document('Profile',pid)
|
||||
|
||||
# login to gateway
|
||||
from webnotes.utils.webservice import FrameworkServer
|
||||
fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
|
||||
|
||||
account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
|
||||
|
||||
# call add profile
|
||||
ret = fw.runserverobj('Profile Control','Profile Control','add_profile_gateway',str([p.first_name, p.middle_name, p.last_name, p.email, p.name, account_id]))
|
||||
|
||||
if ret.get('exc'):
|
||||
msgprint(ret['exc'])
|
||||
raise Exception
|
||||
|
||||
def get_role_permission(self,role):
|
||||
perm = sql("select distinct t1.`parent`, t1.`read`, t1.`write`, t1.`create`, t1.`submit`,t1.`cancel`,t1.`amend` from `tabDocPerm` t1, `tabDocType` t2 where t1.`role` ='%s' and t1.docstatus !=2 and t1.permlevel = 0 and t1.`read` = 1 and t2.module != 'Recycle Bin' and t1.parent=t2.name "%role)
|
||||
return perm or ''
|
||||
|
||||
|
||||
# Check if password is expired
|
||||
# --------------------------------
|
||||
def has_pwd_expired(self):
|
||||
if session['user'] != 'Administrator' and session['user'].lower() != 'demo':
|
||||
last_pwd_date = None
|
||||
try:
|
||||
last_pwd_date = sql("select password_last_updated from tabProfile where name=%s",session['user'])[0][0] or ''
|
||||
except:
|
||||
return 'No'
|
||||
if cstr(last_pwd_date) == '':
|
||||
sql("update tabProfile set password_last_updated = '%s' where name='%s'"% (nowdate(),session['user']))
|
||||
return 'No'
|
||||
else:
|
||||
date_diff = (getdate(nowdate()) - last_pwd_date).days
|
||||
expiry_period = sql("select value from tabSingles where doctype='Control Panel' and field='password_expiry_days'")
|
||||
if expiry_period and cint(expiry_period[0][0]) and cint(expiry_period[0][0]) < date_diff:
|
||||
return 'Yes'
|
||||
return 'No'
|
||||
|
||||
def reset_password(self,pwd):
|
||||
if sql("select name from tabProfile where password=PASSWORD(%s) and name=%s", (pwd,session['user'])):
|
||||
return 'Password cannot be same as old password'
|
||||
sql("update tabProfile set password=PASSWORD(%s),password_last_updated=%s where name = %s", (pwd,nowdate(),session['user']))
|
||||
return 'ok'
|
||||
|
||||
#-------------------------------------------------------------------------------------------------------
|
||||
#functions for manage user page
|
||||
#-----------Enable/Disable Profile-----------------------------------------------------------------------------------------------
|
||||
def change_login(self,args):
|
||||
args = eval(args)
|
||||
|
||||
if cint(args['set_disabled'])==0:
|
||||
sql("update `tabProfile` set enabled=1 where name='%s'"%args['user'])
|
||||
else:
|
||||
sql("update `tabProfile` set enabled=0 where name='%s'"%args['user'])
|
||||
|
||||
return 'ok'
|
||||
|
||||
#------------return role list -------------------------------------------------------------------------------------------------
|
||||
# All roles of Role Master
|
||||
def get_role(self):
|
||||
r_list=sql("select name from `tabRole` where name not in ('Administrator','All','Guest')")
|
||||
if r_list[0][0]:
|
||||
r_list = [x[0] for x in r_list]
|
||||
return r_list
|
||||
|
||||
# Only user specific role
|
||||
def get_user_role(self,usr):
|
||||
r_list=sql("select role from `tabUserRole` where parent=%s and role not in ('Administrator','All','Guest')",usr)
|
||||
if r_list[0][0]:
|
||||
r_list = [x[0] for x in r_list]
|
||||
else:
|
||||
r_list=[]
|
||||
return r_list
|
||||
|
||||
# adding new role
|
||||
def add_user_role(self,args):
|
||||
arg=eval(args)
|
||||
sql("delete from `tabUserRole` where parenttype='Profile' and parent ='%s'" % (cstr(arg['user'])))
|
||||
role_list = arg['role_list'].split(',')
|
||||
for r in role_list:
|
||||
pr=Document('UserRole')
|
||||
pr.parent = arg['user']
|
||||
pr.parenttype = 'Profile'
|
||||
pr.role = r
|
||||
pr.parentfield = 'userroles'
|
||||
pr.save(1)
|
||||
|
||||
|
||||
|
||||
# Add new member
|
||||
# ---------------
|
||||
def add_profile(self,arg):
|
||||
|
||||
# Check credit balance
|
||||
get_obj('WN ERP Client Control').check_credit_balance()
|
||||
|
||||
arg=eval(arg)
|
||||
pr=Document('Profile')
|
||||
for d in arg.keys():
|
||||
if d!='role':
|
||||
pr.fields[d] = arg[d]
|
||||
|
||||
pr.enabled=0
|
||||
pr.user_type='System User'
|
||||
pr.save(1)
|
||||
pr_obj = get_obj('Profile',pr.name)
|
||||
if (pr.name):
|
||||
msg="New member is added"
|
||||
pr_obj.on_update()
|
||||
else:
|
||||
msg="Profile not created"
|
||||
|
||||
return cstr(msg)
|
||||
|
||||
# to find currently login user
|
||||
def current_login(self):
|
||||
cl_list=sql("select distinct user from tabSessions")
|
||||
if cl_list:
|
||||
cl_list=[x[0] for x in cl_list]
|
||||
|
||||
return cl_list
|
||||
|
||||
|
||||
# Remove Profile
|
||||
# ---------------
|
||||
def remove_profile(self, user):
|
||||
# delete profile
|
||||
webnotes.model.delete_doc('Profile',user)
|
||||
|
||||
# Update WN ERP Client Control
|
||||
sql("update tabSingles set value = value - 1 where field = 'total_users' and doctype = 'WN ERP Client Control'")
|
||||
|
||||
# login to gateway
|
||||
from webnotes.utils.webservice import FrameworkServer
|
||||
fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
|
||||
|
||||
account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
|
||||
|
||||
# call remove profile
|
||||
ret = fw.runserverobj('Profile Control','Profile Control','remove_app_sub',str([user, account_id, session['user']]))
|
||||
|
||||
if ret.get('exc'):
|
||||
msgprint(ret['exc'])
|
||||
raise Exception
|
||||
|
||||
return "User Removed Successfully"
|
||||
|
||||
|
||||
# Create Profile
|
||||
# ---------------
|
||||
def create_profile(self, email):
|
||||
if sql("select name from tabProfile where name = %s", email):
|
||||
sql("update tabProfile set docstatus = 0 where name = %s", email)
|
||||
else:
|
||||
pr = Document('Profile')
|
||||
pr.email = email
|
||||
pr.enabled=0
|
||||
pr.user_type='System User'
|
||||
pr.save(1)
|
||||
@@ -0,0 +1,55 @@
|
||||
[
|
||||
{
|
||||
'allow_attach': None,
|
||||
'allow_copy': None,
|
||||
'allow_email': None,
|
||||
'allow_print': None,
|
||||
'allow_rename': None,
|
||||
'allow_trash': None,
|
||||
'autoname': None,
|
||||
'change_log': None,
|
||||
'client_script': None,
|
||||
'client_script_core': None,
|
||||
'client_string': None,
|
||||
'colour': 'White:FFF',
|
||||
'creation': '2009-05-29 12:19:21',
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocType',
|
||||
'document_type': None,
|
||||
'dt_template': None,
|
||||
'hide_heading': None,
|
||||
'hide_toolbar': None,
|
||||
'idx': None,
|
||||
'in_create': None,
|
||||
'in_dialog': None,
|
||||
'is_transaction_doc': None,
|
||||
'issingle': 1,
|
||||
'istable': None,
|
||||
'max_attachments': None,
|
||||
'menu_index': None,
|
||||
'modified': '2010-11-03 11:03:11',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Application Internal',
|
||||
'name': 'Profile Control',
|
||||
'name_case': None,
|
||||
'owner': 'Administrator',
|
||||
'parent': None,
|
||||
'parent_node': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'print_outline': None,
|
||||
'read_only': None,
|
||||
'read_only_onload': None,
|
||||
'search_fields': None,
|
||||
'section_style': 'Simple',
|
||||
'server_code': None,
|
||||
'server_code_compiled': None,
|
||||
'server_code_core': None,
|
||||
'server_code_error': '<pre style="text-align: left;"></pre>',
|
||||
'show_in_menu': 0,
|
||||
'smallicon': None,
|
||||
'use_template': None,
|
||||
'version': 12
|
||||
}
|
||||
]
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-05-29 15:19:57', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 8, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'FRD/.########', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Report Filter Detail', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': None, 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-05-29 15:19:57', 'doctype': 'DocField', 'oldfieldname': 'field_label_fr', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Field Label', 'width': None, 'trigger': 'Client', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Report Filter Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02240', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-03-31 10:12:06', 'parenttype': 'DocType', 'fieldname': 'field_label_fr', 'fieldtype': 'Link', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-05-29 15:19:57', 'doctype': 'DocField', 'oldfieldname': 'field_type_fr', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Field Type', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Report Filter Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02241', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-03-31 10:12:06', 'parenttype': 'DocType', 'fieldname': 'field_type_fr', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Text', 'creation': '2009-05-29 15:19:57', 'doctype': 'DocField', 'oldfieldname': 'options_fr', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Options', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Report Filter Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02242', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-03-31 10:12:06', 'parenttype': 'DocType', 'fieldname': 'options_fr', 'fieldtype': 'Text', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-05-29 15:19:57', 'doctype': 'DocField', 'oldfieldname': 'table_name_fr', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Table Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Report Filter Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02243', 'idx': 4, 'default': None, 'colour': None, 'modified': '2010-03-31 10:12:06', 'parenttype': 'DocType', 'fieldname': 'table_name_fr', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-05-29 15:19:57', 'doctype': 'DocField', 'oldfieldname': 'field_name_fr', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Field Name', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'Report Filter Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02244', 'idx': 5, 'default': None, 'colour': None, 'modified': '2010-03-31 10:12:06', 'parenttype': 'DocType', 'fieldname': 'field_name_fr', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
|
||||
0
application_internal/doctype/sms_center/__init__.py
Normal file
0
application_internal/doctype/sms_center/__init__.py
Normal file
8
application_internal/doctype/sms_center/sms_center.js
Normal file
8
application_internal/doctype/sms_center/sms_center.js
Normal file
@@ -0,0 +1,8 @@
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
if(doc.send_to == 'Customer Group')
|
||||
unhide_field('customer_group_name');
|
||||
else
|
||||
hide_field('customer_group_name');
|
||||
}
|
||||
|
||||
cur_frm.cscript.send_to = cur_frm.cscript.refresh;
|
||||
59
application_internal/doctype/sms_center/sms_center.py
Normal file
59
application_internal/doctype/sms_center/sms_center.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def create_receiver_table(self):
|
||||
if self.doc.send_to:
|
||||
self.doc.clear_table(self.doclist, 'receiver_details')
|
||||
rec = ''
|
||||
if self.doc.send_to == 'All Customer':
|
||||
rec = sql("select customer_name, CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(customer_name,'') !='' and ifnull(mobile_no,'')!=''")
|
||||
|
||||
elif self.doc.send_to == 'Customer Group' and self.doc.customer_group_name:
|
||||
|
||||
rec = sql("select t2.customer_name, CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), t1.mobile_no from `tabContact` t1, `tabCustomer` t2 where t2.name = t1.customer_name and ifnull(t1.mobile_no,'')!='' and t2.customer_group = '%s'"%self.doc.customer_group_name)
|
||||
if not rec:
|
||||
msgprint("Either customer having no contact or customer's contact does not have mobile no")
|
||||
raise Exception
|
||||
|
||||
for d in rec:
|
||||
ch = addchild(self.doc, 'receiver_details', 'Receiver Detail', 1, self.doclist)
|
||||
ch.customer_name = d[0]
|
||||
ch.receiver_name = d[1]
|
||||
ch.mobile_no = d[2]
|
||||
else:
|
||||
msgprint("Please select 'Send To' field")
|
||||
|
||||
|
||||
def send_sms(self):
|
||||
if not self.doc.message:
|
||||
msgprint("Please type the message before sending")
|
||||
elif not getlist(self.doclist, 'receiver_details'):
|
||||
msgprint("Receiver Table is blank.")
|
||||
else:
|
||||
receiver_list = []
|
||||
for d in getlist(self.doclist, 'receiver_details'):
|
||||
if d.mobile_no:
|
||||
receiver_list.append(d.mobile_no)
|
||||
if receiver_list:
|
||||
msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.message))
|
||||
1
application_internal/doctype/sms_center/sms_center.txt
Normal file
1
application_internal/doctype/sms_center/sms_center.txt
Normal file
File diff suppressed because one or more lines are too long
30
application_internal/doctype/sso_control/sso_control.py
Normal file
30
application_internal/doctype/sso_control/sso_control.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def logout_sso(self):
|
||||
import webnotes
|
||||
import webnotes.utils.webservice
|
||||
|
||||
if session['data'].get('login_from'):
|
||||
sso = webnotes.utils.webservice.FrameworkServer(session['data'].get('login_from'), '/', '__system@webnotestech.com', 'password')
|
||||
sso.runserverobj('SSO Control', 'SSO Control', 'logout_user', session['user'])
|
||||
1
application_internal/doctype/sso_control/sso_control.txt
Normal file
1
application_internal/doctype/sso_control/sso_control.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-04-07 12:13:03', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 4, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'SSO Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
87
application_internal/doctype/tips_common/tips_common.js
Normal file
87
application_internal/doctype/tips_common/tips_common.js
Normal file
@@ -0,0 +1,87 @@
|
||||
// Global dictionary of next steps for doctypes
|
||||
// ============================================
|
||||
pscript.tip_doc_dict = {'Quotation':['Sales Order'], 'Sales Order':['Delivery Note', 'Sales Invoice'], 'Delivery Note':['Sales Invoice'], 'Receivable Voucher':['Bank Voucher'], 'Indent':['Purchase Order'], 'Purchase Order':['Purchase Invoice'], 'Payable Voucher':['Bank Voucher'], 'Purchase Receipt':['Purchase Invoice'], 'Enquiry':['Quotation'], 'Lead':['Enquiry', 'Customer']};
|
||||
|
||||
pscript.master_doctype_lst =['Authorization Rule','Bank','Batch','Branch','Brand','Business Letter','Business Letter Template','Business Letter Type','Campaign','City','Company','Contact','Cost Center','Country','Customer','Customer Group','Deduction Type','Department','Designation','Earning Type','Employee','Employment Type','Expense Type','File Group','Fiscal Year','Grade','Holiday List','Industry Type','Item','Item Group','KRA Template','Landed Cost Master','Lead','Leave Type', 'Manage Account', 'Mode of Payment','Order Lost Reason','Other Charges','Period','Price List','Print Heading','Project','Purchase Other Charges','Purpose of Service','Sales BOM','Sales Partner','Sales Person','Serial No','State','Supplier','Supplier Type','TDS Category','Term','Territory','Ticket Category','UOM','Warehouse','Warehouse Type','Workflow Rule','Workstation'];
|
||||
|
||||
// Set tips depending on conditions
|
||||
// ================================
|
||||
cur_frm.cscript.get_tips = function(doc, cdt, cdn){
|
||||
|
||||
var next_step_list = pscript.tip_doc_dict[cur_frm.doctype];
|
||||
// from is shown in print format
|
||||
|
||||
|
||||
if(!cur_frm.editable && cur_frm.doctype!='Enquiry' && pscript.master_doctype_lst.join().indexOf(cur_frm.doctype)<0){
|
||||
cur_frm.set_tip("Click on the <div style='font-weight:bold; display:inline'>Edit</div> button above to edit this " + get_doctype_label(cur_frm.doctype) + ".");
|
||||
}
|
||||
|
||||
|
||||
// form is not in print format
|
||||
if(cur_frm.editable){
|
||||
// new doc
|
||||
if(pscript.master_doctype_lst.join().indexOf(cur_frm.doctype)>=0){
|
||||
if(doc.__islocal)
|
||||
cur_frm.set_tip("To create " + get_doctype_label(cur_frm.doctype) + " please start by entering all the mandatory fields (marked <div style='color:Red; display:inline'> Red</div>).<br><br> You can then save this form by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
else
|
||||
cur_frm.set_tip("You have saved this " + get_doctype_label(cur_frm.doctype) + ".");
|
||||
}
|
||||
else {
|
||||
if(doc.__islocal){
|
||||
if(doc.status=='Cancelled' || doc.amended_from)
|
||||
cur_frm.set_tip("You can now make changes in this " + get_doctype_label(cur_frm.doctype) + " and save it by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
else
|
||||
cur_frm.set_tip("To create " + get_doctype_label(cur_frm.doctype) + " please start by entering all the mandatory fields (marked <div style='color:Red; display:inline'> Red</div>).<br><br> You can then save this form by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
}
|
||||
|
||||
// doc exists
|
||||
else if(!doc.__islocal){
|
||||
// execute when doc is saved
|
||||
//if(doc.docstatus==0 && cur_frm.doctype!='Enquiry' && cur_frm.doctype!='Lead')
|
||||
if(doc.docstatus==0 && cur_frm.doctype!='Lead')
|
||||
cur_frm.set_tip("You have saved your " + get_doctype_label(cur_frm.doctype) + ". You can make this draft permanent by clicking on <div style='font-weight:bold; display:inline'>Submit</div> button above.");
|
||||
|
||||
// execute if doc has only save permission
|
||||
//else if(doc.docstatus==0 && (cur_frm.doctype=='Enquiry' || cur_frm.doctype=='Lead')){
|
||||
else if(doc.docstatus==0 && (cur_frm.doctype=='Lead')){
|
||||
cur_frm.set_tip("You have saved this " + get_doctype_label(cur_frm.doctype) + ".");
|
||||
for(var i=0; i<next_step_list.length; i++){
|
||||
if(i==0) cur_frm.append_tip("To proceed select the <div style='font-weight:bold; display:inline'>Next Steps</div> tab below and click the button to create a " + next_step_list[i] +".");
|
||||
else cur_frm.append_tip("You can also create a " + next_step_list[i] + " against this " + get_doctype_label(cur_frm.doctype) + ".");
|
||||
}
|
||||
}
|
||||
// execute if doc is submitted
|
||||
else if(doc.docstatus==1){
|
||||
cur_frm.set_tip("You have submitted this " + get_doctype_label(cur_frm.doctype) + ".");
|
||||
for(var i=0; i<next_step_list.length; i++){
|
||||
if(i==0) cur_frm.append_tip("To proceed select the Next Steps tab below and click the button to create a " + next_step_list[i] +".");
|
||||
else cur_frm.append_tip("You can also create a " + next_step_list[i] + " against this " + get_doctype_label(cur_frm.doctype) + ".");
|
||||
}
|
||||
cur_frm.append_tip("(To amend this "+ get_doctype_label(cur_frm.doctype) + " click on the <div style='font-weight:bold; display:inline'>Cancel</div> button above.)");
|
||||
}
|
||||
|
||||
// execute when doc is amended
|
||||
else if(doc.docstatus==2){
|
||||
cur_frm.set_tip("To make this " + get_doctype_label(cur_frm.doctype) + " editable click on the <div style='font-weight:bold; display:inline'>Amend</div> button above.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Executes when doc is edit status of doc is changed
|
||||
// ==================================================
|
||||
cur_frm.cscript.edit_status_changed = function(doc, cdt, cdn){
|
||||
cur_frm.cscript.get_tips();
|
||||
}
|
||||
|
||||
|
||||
// Executes when module page is loaded
|
||||
pscript.show_module_stats = function(parent, module)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.module = module;
|
||||
alert(profile.can_read)
|
||||
//msgprint(parent, 1);
|
||||
msgprint(module, 1);
|
||||
}
|
||||
1
application_internal/doctype/tips_common/tips_common.txt
Normal file
1
application_internal/doctype/tips_common/tips_common.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-05-28 10:32:20', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 53, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': '', 'name': 'Tips Common', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,140 @@
|
||||
# Note:
|
||||
# You must add the DocType to the override_transfer dict, else it will replace everything
|
||||
# ---------------------------------------------------------------------------------------
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc, self.doclist = doc, doclist
|
||||
|
||||
# Over-ride function dict
|
||||
# -----------------------
|
||||
|
||||
self.override_transfer = {
|
||||
'DocType':'ovr_doctype',
|
||||
'DocType Mapper':'ovr_mapper'
|
||||
}
|
||||
|
||||
def ovr_doctype(self, doclist, ovr, ignore, onupdate):
|
||||
doclist = [Document(fielddata = d) for d in doclist]
|
||||
doc = doclist[0]
|
||||
orig_modified = doc.modified
|
||||
cur_doc = Document('DocType',doc.name)
|
||||
added = 0
|
||||
prevfield = ''
|
||||
prevlabel = ''
|
||||
idx = 0
|
||||
|
||||
# fields
|
||||
# ------
|
||||
for d in getlist(doclist, 'fields'):
|
||||
fld = ''
|
||||
# if exists
|
||||
if d.fieldname:
|
||||
fld = sql("select name from tabDocField where fieldname=%s and parent=%s", (d.fieldname, d.parent))
|
||||
elif d.label: # for buttons where there is no fieldname
|
||||
fld = sql("select name from tabDocField where label=%s and parent=%s", (d.label, d.parent))
|
||||
|
||||
if (not fld) and d.label: # must have label
|
||||
if prevfield:
|
||||
idx = sql("select idx from tabDocField where fieldname = %s and parent = %s",(prevfield,d.parent))[0][0]
|
||||
elif prevlabel and not prevfield:
|
||||
idx = sql("select idx from tabDocField where label = %s and parent = %s",(prevlabel,d.parent))[0][0]
|
||||
sql("update tabDocField set idx = idx + 1 where parent=%s and idx > %s", (d.parent, cint(idx)))
|
||||
|
||||
# add field
|
||||
nd = Document(fielddata = d.fields)
|
||||
nd.oldfieldname, nd.oldfieldtype = '', ''
|
||||
nd.idx = cint(idx)+1
|
||||
nd.save(new = 1, ignore_fields = ignore)
|
||||
added += 1
|
||||
if d.fieldname:
|
||||
prevfield = d.fieldname
|
||||
prevlabel = ''
|
||||
elif d.label:
|
||||
prevfield = ''
|
||||
prevlabel = d.label
|
||||
|
||||
# Print Formats
|
||||
# ------
|
||||
for d in getlist(doclist, 'formats'):
|
||||
fld = ''
|
||||
# if exists
|
||||
if d.format:
|
||||
fld = sql("select name from `tabDocFormat` where format=%s and parent=%s", (d.format, d.parent))
|
||||
|
||||
if (not fld) and d.format: # must have label
|
||||
# add field
|
||||
nd = Document(fielddata = d.fields)
|
||||
nd.oldfieldname, nd.oldfieldtype = '', ''
|
||||
nd.save(new = 1, ignore_fields = ignore)
|
||||
added += 1
|
||||
|
||||
# code
|
||||
# ----
|
||||
|
||||
cur_doc.server_code_core = cstr(doc.server_code_core)
|
||||
cur_doc.client_script_core = cstr(doc.client_script_core)
|
||||
|
||||
cur_doc.save(ignore_fields = ignore)
|
||||
|
||||
if onupdate:
|
||||
so = get_obj('DocType', doc.name, with_children = 1)
|
||||
if hasattr(so, 'on_update'):
|
||||
so.on_update()
|
||||
|
||||
set(doc,'modified',orig_modified)
|
||||
|
||||
if in_transaction: sql("COMMIT")
|
||||
|
||||
return doc.name + (' Upgraded: %s fields added' % added)
|
||||
|
||||
|
||||
def ovr_mapper(self, doclist, ovr, ignore, onupdate):
|
||||
doclist = [Document(fielddata = d) for d in doclist]
|
||||
doc = doclist[0]
|
||||
orig_modified = doc.modified
|
||||
cur_doc = Document('DocType Mapper',doc.name)
|
||||
added = 0
|
||||
|
||||
# Field Mapper Details fields
|
||||
# ------
|
||||
for d in getlist(doclist, 'field_mapper_details'):
|
||||
fld = ''
|
||||
# if exists
|
||||
if d.from_field and d.to_field:
|
||||
fld = sql("select name from `tabField Mapper Detail` where from_field=%s and to_field=%s and parent=%s", (d.from_field, d.to_field, d.parent))
|
||||
|
||||
if (not fld) and d.from_field and d.to_field: # must have label
|
||||
# add field
|
||||
nd = Document(fielddata = d.fields)
|
||||
nd.oldfieldname, nd.oldfieldtype = '', ''
|
||||
nd.save(new = 1, ignore_fields = ignore)
|
||||
added += 1
|
||||
|
||||
# Table Mapper Details fields
|
||||
# ------
|
||||
for d in getlist(doclist, 'table_mapper_details'):
|
||||
fld = ''
|
||||
# if exists
|
||||
if d.from_table and d.to_table:
|
||||
fld = sql("select name from `tabTable Mapper Detail` where from_table=%s and to_table = %s and parent=%s", (d.from_table, d.to_table, d.parent))
|
||||
|
||||
if (not fld) and d.from_table and d.to_table: # must have label
|
||||
# add field
|
||||
nd = Document(fielddata = d.fields)
|
||||
nd.oldfieldname, nd.oldfieldtype = '', ''
|
||||
nd.save(new = 1, ignore_fields = ignore)
|
||||
added += 1
|
||||
|
||||
cur_doc.save(ignore_fields = ignore)
|
||||
|
||||
if onupdate:
|
||||
so = get_obj('DocType Mapper', doc.name, with_children = 1)
|
||||
if hasattr(so, 'on_update'):
|
||||
so.on_update()
|
||||
|
||||
set(doc,'modified',orig_modified)
|
||||
|
||||
if in_transaction: sql("COMMIT")
|
||||
|
||||
return doc.name + (' Upgraded: %s fields added' % added)
|
||||
@@ -0,0 +1,249 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Note:
|
||||
# You must add the DocType to the override_transfer dict, else it will replace everything
|
||||
# ---------------------------------------------------------------------------------------
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc, self.doclist = doc, doclist
|
||||
|
||||
# Over-ride function dict
|
||||
# -----------------------
|
||||
|
||||
self.override_transfer = {
|
||||
'DocType':'ovr_doctype',
|
||||
'DocType Mapper':'ovr_mapper',
|
||||
'TDS Rate Chart':'ovr_tds'
|
||||
}
|
||||
|
||||
def ovr_doctype(self, doclist, ovr, ignore, onupdate):
|
||||
doclist = [Document(fielddata = d) for d in doclist]
|
||||
doc = doclist[0]
|
||||
orig_modified = doc.modified
|
||||
cur_doc = Document('DocType',doc.name)
|
||||
added = 0
|
||||
prevfield = ''
|
||||
prevlabel = ''
|
||||
idx = 0
|
||||
fld_lst = ''
|
||||
|
||||
# fields
|
||||
# ------
|
||||
for d in getlist(doclist, 'fields'):
|
||||
fld = ''
|
||||
# if exists
|
||||
if d.fieldname:
|
||||
fld = sql("select name from tabDocField where fieldname=%s and parent=%s", (d.fieldname, d.parent))
|
||||
elif d.label: # for buttons where there is no fieldname
|
||||
fld = sql("select name from tabDocField where label=%s and parent=%s", (d.label, d.parent))
|
||||
|
||||
if (not fld) and d.label: # must have label
|
||||
if prevfield:
|
||||
idx = sql("select idx from tabDocField where fieldname = %s and parent = %s",(prevfield,d.parent))[0][0]
|
||||
elif prevlabel and not prevfield:
|
||||
idx = sql("select idx from tabDocField where label = %s and parent = %s",(prevlabel,d.parent))[0][0]
|
||||
sql("update tabDocField set idx = idx + 1 where parent=%s and idx > %s", (d.parent, cint(idx)))
|
||||
|
||||
# add field
|
||||
nd = Document(fielddata = d.fields)
|
||||
nd.oldfieldname, nd.oldfieldtype = '', ''
|
||||
nd.idx = cint(idx)+1
|
||||
nd.save(new = 1, ignore_fields = ignore, check_links = 0)
|
||||
fld_lst += "\n"+'Label : '+cstr(d.label)+' --- Fieldtype : '+cstr(d.fieldtype)+' --- Fieldname : '+cstr(d.fieldname)+' --- Options : '+cstr(d.options)
|
||||
added += 1
|
||||
if d.fieldname:
|
||||
prevfield = d.fieldname
|
||||
prevlabel = ''
|
||||
elif d.label:
|
||||
prevfield = ''
|
||||
prevlabel = d.label
|
||||
|
||||
# Print Formats
|
||||
# ------
|
||||
for d in getlist(doclist, 'formats'):
|
||||
fld = ''
|
||||
# if exists
|
||||
if d.format:
|
||||
fld = sql("select name from `tabDocFormat` where format=%s and parent=%s", (d.format, d.parent))
|
||||
|
||||
if (not fld) and d.format: # must have label
|
||||
# add field
|
||||
nd = Document(fielddata = d.fields)
|
||||
nd.oldfieldname, nd.oldfieldtype = '', ''
|
||||
nd.save(new = 1, ignore_fields = ignore, check_links = 0)
|
||||
fld_lst = fld_lst + "\n"+'Format : '+cstr(d.format)
|
||||
added += 1
|
||||
|
||||
# code
|
||||
# ----
|
||||
|
||||
cur_doc.server_code_core = cstr(doc.server_code_core)
|
||||
cur_doc.client_script_core = cstr(doc.client_script_core)
|
||||
|
||||
cur_doc.save(ignore_fields = ignore, check_links = 0)
|
||||
|
||||
if version=='v160':
|
||||
so = get_obj('DocType', doc.name, with_children = 1)
|
||||
if hasattr(so, 'on_update'):
|
||||
so.on_update()
|
||||
elif version=='v170':
|
||||
import webnotes.model.doctype
|
||||
try:
|
||||
webnotes.model.doctype.update_doctype(so.doclist)
|
||||
except:
|
||||
pass
|
||||
|
||||
set(doc,'modified',orig_modified)
|
||||
|
||||
if in_transaction: sql("COMMIT")
|
||||
|
||||
if added == 0:
|
||||
added_fields = ''
|
||||
else:
|
||||
added_fields = ' <div style="color : RED">Added Fields :- '+ cstr(fld_lst)+ '</div>'
|
||||
|
||||
return doc.name + (' Upgraded: %s fields added' % added)+added_fields
|
||||
|
||||
|
||||
def ovr_mapper(self, doclist, ovr, ignore, onupdate):
|
||||
doclist = [Document(fielddata = d) for d in doclist]
|
||||
doc = doclist[0]
|
||||
orig_modified = doc.modified
|
||||
cur_doc = Document('DocType Mapper',doc.name)
|
||||
added = 0
|
||||
fld_lst = ''
|
||||
|
||||
# Field Mapper Details fields
|
||||
# ------
|
||||
for d in getlist(doclist, 'field_mapper_details'):
|
||||
fld = ''
|
||||
# if exists
|
||||
if d.from_field and d.to_field:
|
||||
fld = sql("select name from `tabField Mapper Detail` where from_field=%s and to_field=%s and parent=%s", (d.from_field, d.to_field, d.parent))
|
||||
|
||||
if (not fld) and d.from_field and d.to_field: # must have label
|
||||
# add field
|
||||
nd = Document(fielddata = d.fields)
|
||||
nd.oldfieldname, nd.oldfieldtype = '', ''
|
||||
nd.save(new = 1, ignore_fields = ignore, check_links = 0)
|
||||
fld_lst += "\n"+'From Field : '+cstr(d.from_field)+' --- To Field : '+cstr(d.to_field)
|
||||
added += 1
|
||||
|
||||
# Table Mapper Details fields
|
||||
# ------
|
||||
for d in getlist(doclist, 'table_mapper_details'):
|
||||
fld = ''
|
||||
# if exists
|
||||
if d.from_table and d.to_table:
|
||||
fld = sql("select name from `tabTable Mapper Detail` where from_table=%s and to_table = %s and parent=%s", (d.from_table, d.to_table, d.parent))
|
||||
|
||||
if (not fld) and d.from_table and d.to_table: # must have label
|
||||
# add field
|
||||
nd = Document(fielddata = d.fields)
|
||||
nd.oldfieldname, nd.oldfieldtype = '', ''
|
||||
nd.save(new = 1, ignore_fields = ignore, check_links = 0)
|
||||
fld_lst += "\n"+'From Table : '+cstr(d.from_table)+' --- To Table : '+cstr(d.to_table)
|
||||
added += 1
|
||||
|
||||
cur_doc.save(ignore_fields = ignore, check_links = 0)
|
||||
|
||||
if onupdate:
|
||||
so = get_obj('DocType Mapper', doc.name, with_children = 1)
|
||||
if hasattr(so, 'on_update'):
|
||||
so.on_update()
|
||||
|
||||
set(doc,'modified',orig_modified)
|
||||
|
||||
if in_transaction: sql("COMMIT")
|
||||
|
||||
if added == 0:
|
||||
added_fields = ''
|
||||
else:
|
||||
added_fields = ' <div style="color : RED">Added Fields :- '+ cstr(fld_lst)+ '</div>'
|
||||
return doc.name + (' Upgraded: %s fields added' % added)+added_fields
|
||||
|
||||
|
||||
def ovr_tds(self, doclist, ovr, ignore, onupdate):
|
||||
doclist = [Document(fielddata = d) for d in doclist]
|
||||
doc = doclist[0]
|
||||
orig_modified = doc.modified
|
||||
cur_doc = Document('TDS Rate Chart',doc.name)
|
||||
added = 0
|
||||
fld_lst = ''
|
||||
|
||||
# TDS RATE CHART DETAIL fields
|
||||
# ------
|
||||
for d in getlist(doclist,'rate_chart_detail'):
|
||||
fld = ''
|
||||
# if exists
|
||||
if d.category and d.slab_from and d.slab_to:
|
||||
fld = sql("select name from `tabTDS Rate Detail` where category=%s and slab_from=%s and slab_to = %s and parent=%s", (d.category, d.slab_from, d.slab_to, d.parent))
|
||||
|
||||
if (not fld) and d.category and d.slab_from and d.slab_to:
|
||||
# add field
|
||||
nd = Document(fielddata = d.fields)
|
||||
nd.oldfieldname, nd.oldfieldtype = '', ''
|
||||
nd.save(new = 1, ignore_fields = ignore, check_links = 0)
|
||||
fld_lst += "\n"+'Category : '+cstr(d.category)+' --- Slab From : '+cstr(d.slab_from)+ ' --- Slab To : '+cstr(d.slab_to)
|
||||
added += 1
|
||||
|
||||
cur_doc.save(ignore_fields = ignore)
|
||||
|
||||
if onupdate:
|
||||
so = get_obj('TDS Rate Chart', doc.name, with_children = 1)
|
||||
if hasattr(so, 'on_update'):
|
||||
so.on_update()
|
||||
|
||||
set(doc,'modified',orig_modified)
|
||||
|
||||
if in_transaction: sql("COMMIT")
|
||||
if added == 0:
|
||||
added_fields = ''
|
||||
else:
|
||||
added_fields = ' <div style="color : RED">Added Fields :- '+ cstr(fld_lst)+ '</div>'
|
||||
|
||||
return doc.name + (' Upgraded: %s fields added' % added)+added_fields
|
||||
|
||||
def get_all_modules(self, args):
|
||||
if args == 'Import':
|
||||
from webnotes.utils import module_manager
|
||||
return module_manager.get_modules_from_filesystem()
|
||||
elif args == 'Export':
|
||||
return get_modules_from_table()
|
||||
|
||||
|
||||
def get_modules_from_table(self):
|
||||
from webnotes import handler
|
||||
out = webnotes.session
|
||||
handler.get_modules()
|
||||
return out['mod_list']
|
||||
|
||||
|
||||
|
||||
def export_records(self,args):
|
||||
args = eval(args)
|
||||
msgprint(args)
|
||||
from webnotes.utils import module_manager
|
||||
module_manager.export_to_files(args['modules'],args['record_list'])
|
||||
|
||||
def import_records(self,modules,doctyp_list,execute_patch,sync_cp):
|
||||
from webnotes.utils import module_manager
|
||||
module_manager.import_from_files(modules,doctyp_list,execute_patch,sync_cp)
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-05-28 12:41:41', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 40, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': '', 'name': 'Transfer Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-11-12 16:41:58', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Tray', 'is_transaction_doc': None, 'creation': '2009-04-29 15:02:21', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 2, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': '', 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Transfer Module', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': None, 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': '', 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-04-29 15:02:21', 'doctype': 'DocField', 'oldfieldname': 'module', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Module', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Transfer Module', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01941', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-03-31 11:10:53', 'parenttype': 'DocType', 'fieldname': 'module', 'fieldtype': 'Link', 'options': 'Module Def', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Check', 'creation': '2009-04-29 15:02:21', 'doctype': 'DocField', 'oldfieldname': 'transfer', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Transfer', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Transfer Module', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL01942', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-03-31 11:10:53', 'parenttype': 'DocType', 'fieldname': 'transfer', 'fieldtype': 'Check', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
|
||||
@@ -0,0 +1,44 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self,doc,doclist):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def get_users(self):
|
||||
ret = sql("select name from tabProfile where name!='Administrator' and name!='Guest' and enabled=1")
|
||||
return ret
|
||||
|
||||
def remove_users(self,args):
|
||||
args = eval(args)
|
||||
#for user in args['app_user_list']:
|
||||
#sql("update tabProfile set enabled=0 where email=%s",(user))
|
||||
|
||||
def create_users_profile(self,args):
|
||||
args = eval(args)
|
||||
for email_id in args['user_email_ids']:
|
||||
if sql("select email from tabProfile where email=%s",(email_id)):
|
||||
p = Document('Profile',email_id)
|
||||
p.enabled = 1
|
||||
p.save()
|
||||
else:
|
||||
p = Document('Profile')
|
||||
p.email = email_id
|
||||
p.save(1)
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-03-18 11:09:04', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 2, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'WN Account Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
@@ -0,0 +1,141 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc, self.doclist = doc, doclist
|
||||
|
||||
|
||||
# Check End of Trial Period
|
||||
# -------------------------
|
||||
def trial_payment_reminders(self):
|
||||
if cint(self.doc.is_trial_account)==1:
|
||||
# Trial Period Expiry
|
||||
trial_end_date = add_days(self.doc.account_start_date, 30)
|
||||
days = date_diff(trial_end_date, nowdate())
|
||||
# check if trial period has expired
|
||||
if days < 10 and days >= 0 and has_common(['System Manager'],webnotes.user.get_roles()):
|
||||
return "Your Trial Period expires on '%s'. Please buy credits online using Manage Account." % (formatdate(trial_end_date))
|
||||
|
||||
# trial period has already expired
|
||||
elif days < 0 and days >= -6:
|
||||
extended_days = 7 + days
|
||||
return "Your Trial Period has expired on %s. However, your account will be live for %s days. Please contact your System Manager to buy credits." % (formatdate(trial_end_date),cstr(extended_days))
|
||||
elif not has_common(['Administrator'],webnotes.user.get_roles()) and days < -6:
|
||||
return "Stopped"
|
||||
|
||||
# Account is not a trial account
|
||||
else:
|
||||
return self.account_expiry_reminder()
|
||||
|
||||
|
||||
# Account Expiry Reminder
|
||||
# -----------------------
|
||||
def account_expiry_reminder(self):
|
||||
import webnotes.utils
|
||||
from datetime import datetime
|
||||
# Payment Reminder in case of not enough balance
|
||||
cr_reqd = cint(self.doc.total_users)
|
||||
days_left = cint(self.calc_days())
|
||||
# check if account balance is sufficient
|
||||
if cint(self.doc.credit_balance)<(cr_reqd):
|
||||
|
||||
# Difference between last payment date and current date
|
||||
if self.doc.last_deduction_date: last_payment = date_diff(nowdate(),self.doc.last_deduction_date)
|
||||
else: last_payment = -1
|
||||
|
||||
# 7 days extension
|
||||
remaining_days = days_left - 24
|
||||
if last_payment > 30 or last_payment == -1:
|
||||
if remaining_days < 8 and remaining_days >= 1:
|
||||
return "Your account will be de-activated in " + cstr(remaining_days) + " days. Please contact your System Manager to buy credits."
|
||||
elif remaining_days==0:
|
||||
return "Your account will be disabled from tomorrow. Please contact your System Manager to buy credits."
|
||||
elif not has_common(['Administrator'],webnotes.user.get_roles()):
|
||||
return "Stopped"
|
||||
|
||||
# check if user account is extended for seven days
|
||||
if cint(self.doc.is_trial_account)==0:
|
||||
if days_left < 10 and days_left >= 0:
|
||||
return "You have only %s Credits in your account. Buy credits before %s." % (cint(self.doc.credit_balance),formatdate(self.next_bill_sdate))
|
||||
|
||||
|
||||
|
||||
# Calculate days between current date and billing cycle end date
|
||||
# --------------------------------------------------------------
|
||||
def calc_days(self):
|
||||
if self.doc.billing_cycle_date:
|
||||
next_bill_month = cint(nowdate().split('-')[1])
|
||||
if cint(nowdate().split('-')[2]) > cint(self.doc.billing_cycle_date.split('-')[2]):
|
||||
next_bill_month = cint(nowdate().split('-')[1]) + 1
|
||||
next_bill_year = nowdate().split('-')[0]
|
||||
if next_bill_month > 12:
|
||||
next_bill_month = next_bill_month % 12
|
||||
next_bill_year += 1
|
||||
self.next_bill_sdate = cstr(next_bill_year)+'-'+cstr(next_bill_month)+'-'+(self.calc_next_day(next_bill_year,next_bill_month))
|
||||
#msgprint("next_bill_month :::" + self.next_bill_sdate)
|
||||
return date_diff(self.next_bill_sdate, nowdate())
|
||||
|
||||
|
||||
# Calculate next billing date day
|
||||
# --------------------------------
|
||||
def calc_next_day(self, next_year, next_month):
|
||||
bill_cycle_day = cstr(self.doc.billing_cycle_date).split('-')[2]
|
||||
if cint(next_month) == 2 and next_year%4==0 and (next_year%100!=0 or next_year%400==0) and cint(bill_cycle_day) > 28:
|
||||
bill_cycle_day = '28'
|
||||
elif cint(bill_cycle_day) == 31 and cint(next_month) in (4,6,9,11):
|
||||
bill_cycle_day = '30'
|
||||
return bill_cycle_day
|
||||
|
||||
|
||||
# Update acc credits and balance (making payment from gateway)
|
||||
# -------------------------------------------------------------
|
||||
def update_acc_bal(self,args):
|
||||
args = eval(args)
|
||||
self.doc.credit_balance = cint(self.doc.credit_balance) + cint(args.get('net_cr'))
|
||||
self.doc.total_users = cint(self.doc.total_users) + cint(args.get('total_users'))
|
||||
if cint(self.doc.is_trial_account) == 1:
|
||||
if not self.doc.account_start_date:
|
||||
self.doc.account_start_date = nowdate()
|
||||
self.doc.is_trial_account = 0
|
||||
self.doc.billing_cycle_date = nowdate()
|
||||
self.doc.last_deduction_date = nowdate()
|
||||
self.doc.save()
|
||||
|
||||
|
||||
# Check Credit Balance
|
||||
# ---------------------
|
||||
def check_credit_balance(self):
|
||||
if cint(self.doc.is_trial_account) == 0:
|
||||
if cint(self.doc.credit_balance) < 1:
|
||||
msgprint("You do not have enough credits to add new user. Please buy credits.")
|
||||
raise Exception
|
||||
else:
|
||||
self.doc.credit_balance = cint(self.doc.credit_balance) - 1
|
||||
msgprint("Your one credit is consumed. Balance Credits : %s" % (self.doc.credit_balance))
|
||||
self.doc.total_users = cint(self.doc.total_users) + 1
|
||||
self.doc.save()
|
||||
|
||||
|
||||
# Monthly Deduction
|
||||
# ------------------
|
||||
def monthly_deduction(self, cr_ded):
|
||||
self.doc.credit_balance = cint(self.doc.credit_balance) - cint(cr_ded)
|
||||
self.doc.last_deduction_date = nowdate()
|
||||
self.doc.save()
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user