first cut for lazy loading framework

This commit is contained in:
Rushabh Mehta
2011-09-05 18:43:09 +05:30
parent 09938bda69
commit 66ac2b018a
1512 changed files with 832 additions and 0 deletions

View File

@@ -1,652 +0,0 @@
[
{
'_last_update': None,
'creation': '2010-11-30 22:43:08',
'disabled': 'No',
'docstatus': 0,
'doctype': 'Module Def',
'doctype_list': None,
'file_list': None,
'idx': None,
'is_hidden': 'No',
'last_updated_date': '2011-03-21 12:13:39',
'modified': '2010-09-25 00:00:00',
'modified_by': 'Administrator',
'module_desc': None,
'module_icon': 'wired.png',
'module_label': 'Setup',
'module_name': 'Setup',
'module_page': 'Setup',
'module_seq': 1,
'name': 'Setup',
'owner': 'Administrator',
'parent': None,
'parentfield': None,
'parenttype': None,
'trash_reason': None,
'widget_code': None
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': 'All important setup items in one place',
'display_name': 'Setup Wizard',
'doc_name': 'Setup Wizard',
'doc_type': 'Pages',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': 'lightbulb.gif',
'idx': 1,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00221',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': 'Personalize settings like company banner, date format, print format header etc.',
'display_name': 'Personalize',
'doc_name': 'Personalize Page',
'doc_type': 'Pages',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': 'star.gif',
'idx': 2,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00222',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': 'Enable / Disable users. Set user roles.',
'display_name': 'Manage Users',
'doc_name': 'Manage Users',
'doc_type': 'Pages',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': 'group.gif',
'idx': 3,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00223',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': 'Set global default values and account settings',
'display_name': 'Setup Defaults',
'doc_name': 'Manage Account',
'doc_type': 'Single DocType',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': 'folder.gif',
'idx': 4,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00224',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': 'General Masters',
'display_name': 'Setup Masters',
'doc_name': 'Setup Masters',
'doc_type': 'Pages',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': 'wrench.gif',
'idx': 5,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00225',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': None,
'display_name': 'Sales Browser',
'doc_name': 'Sales Browser',
'doc_type': 'Pages',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 6,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00226',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-24 15:04:47',
'description': None,
'display_name': None,
'doc_name': None,
'doc_type': 'Separator',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 7,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': '000003107',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': "Import data like Customers, Items etc in 'CSV' format",
'display_name': 'Import Data',
'doc_name': 'Import Data',
'doc_type': 'Pages',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': 'disk.gif',
'idx': 8,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00228',
'owner': 'nabin@webnotestech.com',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': 'Set series prefix for transactions',
'display_name': 'Setup Series',
'doc_name': 'Naming Series',
'doc_type': 'Single DocType',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': 'paperclip.gif',
'idx': 9,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00229',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': 'Set approval rights for transactions based on grand total and discount.',
'display_name': 'Authorization Rule',
'doc_name': 'Authorization Rule',
'doc_type': 'Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'transaction\nbased_on\nmaster_name\nsystem_user\nsystem_role\napproving_role\napproving_user\nvalue',
'hide': None,
'icon': 'accept.gif',
'idx': 10,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00230',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': 'Add fields in transactions, masters...',
'display_name': 'Custom Field',
'doc_name': 'Custom Field',
'doc_type': 'Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'dt\nlabel\nfieldtype\noptions',
'hide': None,
'icon': 'paperclip.gif',
'idx': 11,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00231',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 22:43:08',
'description': 'Contains records that you have trashed.',
'display_name': 'Trash',
'doc_name': 'Trash',
'doc_type': 'Pages',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 12,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': 'MDI00232',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-24 15:04:47',
'description': None,
'display_name': 'Price List',
'doc_name': 'Price List',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 13,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': '000003108',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-24 15:04:47',
'description': None,
'display_name': 'Warehouse Type',
'doc_name': 'Warehouse Type',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 14,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': '000003109',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-24 15:04:47',
'description': None,
'display_name': 'Warehouse',
'doc_name': 'Warehouse',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 15,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': '000003110',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-24 15:04:47',
'description': None,
'display_name': 'UOM',
'doc_name': 'UOM',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 16,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': '000003111',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-24 15:04:47',
'description': None,
'display_name': 'Term',
'doc_name': 'Term',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 17,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': '000003112',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-24 15:04:47',
'description': None,
'display_name': 'Taxes and Charges',
'doc_name': 'Other Charges',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 18,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': '000003113',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-24 15:04:47',
'description': None,
'display_name': 'Business Letter Type',
'doc_name': 'Business Letter Type',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 19,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': '000003114',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-24 15:04:47',
'description': None,
'display_name': 'Business Letter Template',
'doc_name': 'Business Letter Template',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 20,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': '000003115',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-24 15:04:47',
'description': None,
'display_name': 'Mode of Payment',
'doc_name': 'Mode of Payment',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 21,
'modified': '2011-03-24 15:04:47',
'modified_by': 'Administrator',
'name': '000003116',
'owner': 'harshada@webnotestech.com',
'parent': 'Setup',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 1,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00042',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Administrator'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 2,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00043',
'owner': 'Administrator',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'System Manager'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 3,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00044',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Sales User'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 4,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00045',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Sales Master Manager'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 5,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00046',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Sales Master Manager'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 6,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00047',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Purchase User'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 7,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00048',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Purchase Master Manager'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 8,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00049',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Purchase Manager'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 9,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00050',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Material User'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 10,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00051',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Material Master Manager'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 11,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00052',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Material Manager'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 12,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00053',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Accounts User'
},
{
'creation': '2010-11-30 22:43:08',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 13,
'modified': '2010-11-30 22:43:08',
'modified_by': 'Administrator',
'name': 'MDR00054',
'owner': 'saumil@webnotestech.com',
'parent': 'Setup',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Accounts Manager'
}
]

View File

@@ -1,26 +0,0 @@
# Role, System Manager
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:51',
'docstatus': 0,
'modified': '2009-07-07 17:00:24',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all Role
{
'doctype': 'Role',
'module': 'Setup',
'name': '__common__',
'role_name': 'System Manager'
},
# Role, System Manager
{
'doctype': 'Role',
'name': 'System Manager'
}
]

View File

View File

@@ -1 +0,0 @@
// Settings

View File

@@ -1,196 +0,0 @@
# 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
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
# Get Names of all Approving Users and Roles
# -------------------------------------------
def get_appr_user_role(self, det, doctype_name, total, based_on, condition, item, company):
amt_list, appr_users, appr_roles = [], [], []
users, roles = '',''
if det:
for x in det:
amt_list.append(flt(x[0]))
max_amount = max(amt_list)
app_dtl = sql("select approving_user, approving_role from `tabAuthorization Rule` where transaction = '%s' and (value = '%s' or value > '%s') and docstatus != 2 and based_on = '%s' and company = '%s' %s" % (doctype_name, flt(max_amount), total, based_on, company, condition))
if not app_dtl:
app_dtl = sql("select approving_user, approving_role from `tabAuthorization Rule` where transaction = '%s' and (value = '%s' or value > '%s') and docstatus != 2 and based_on = '%s' and ifnull(company,'') = '' %s" % (doctype_name, flt(max_amount), total, based_on, condition))
for d in app_dtl:
if(d[0]): appr_users.append(d[0])
if(d[1]): appr_roles.append(d[1])
if not has_common(appr_roles, webnotes.user.get_roles()) and not has_common(appr_users, session['user']):
msg, add_msg = '',''
if max_amount:
dcc = TransactionBase().get_company_currency(self.doc.company)
if based_on == 'Grand Total': msg = "since Grand Total exceeds %s. %s" % (dcc, flt(max_amount))
elif based_on == 'Itemwise Discount': msg = "since Discount exceeds %s for Item Code : %s" % (cstr(max_amount)+'%', item)
elif based_on == 'Average Discount' or based_on == 'Customerwise Discount': msg = "since Discount exceeds %s" % (cstr(max_amount)+'%')
if appr_users: add_msg = "Users : "+cstr(appr_users)
if appr_roles: add_msg = "Roles : "+cstr(appr_roles)
if appr_users and appr_roles: add_msg = "Users : "+cstr(appr_users)+" or "+"Roles : "+cstr(appr_roles)
msgprint("You do not have an authority to submit this %s %s. Please send for approval to %s" % (doctype_name, msg, add_msg))
raise Exception
# Check if authorization rule is set specific to user
# ----------------------------------------------------
def validate_auth_rule(self, doctype_name, total, based_on, cond, company, item = ''):
chk = 1
add_cond1,add_cond2 = '',''
if based_on == 'Itemwise Discount':
add_cond1 += " and master_name = '"+cstr(item)+"'"
itemwise_exists = sql("select value from `tabAuthorization Rule` where transaction = '%s' and value <= '%s' and based_on = '%s' and company = '%s' and docstatus != 2 %s %s" % (doctype_name, total, based_on, company, cond, add_cond1))
if not itemwise_exists:
itemwise_exists = sql("select value from `tabAuthorization Rule` where transaction = '%s' and value <= '%s' and based_on = '%s' and ifnull(company,'') = '' and docstatus != 2 %s %s" % (doctype_name, total, based_on, cond, add_cond1))
if itemwise_exists:
self.get_appr_user_role(itemwise_exists, doctype_name, total, based_on, cond+add_cond1, item,company)
chk = 0
if chk == 1:
if based_on == 'Itemwise Discount': add_cond2 += " and ifnull(master_name,'') = ''"
appr = sql("select value from `tabAuthorization Rule` where transaction = '%s' and value <= '%s' and based_on = '%s' and company = '%s' and docstatus != 2 %s %s" % (doctype_name, total, based_on, company, cond, add_cond2))
if not appr:
appr = sql("select value from `tabAuthorization Rule` where transaction = '%s' and value <= '%s' and based_on = '%s' and ifnull(company,'') = '' and docstatus != 2 %s %s" % (doctype_name, total, based_on, cond, add_cond2))
self.get_appr_user_role(appr, doctype_name, total, based_on, cond+add_cond2, item, company)
# Bifurcate Authorization based on type
# --------------------------------------
def bifurcate_based_on_type(self, doctype_name, total, av_dis, based_on, doc_obj, val, company):
add_cond = ''
auth_value = av_dis
if val == 1: add_cond += " and system_user = '"+session['user']+"'"
elif val == 2: add_cond += " and system_role IN %s" % ("('"+"','".join(webnotes.user.get_roles())+"')")
else: add_cond += " and ifnull(system_user,'') = '' and ifnull(system_role,'') = ''"
if based_on == 'Grand Total': auth_value = total
elif based_on == 'Customerwise Discount':
if doc_obj:
if doc_obj.doc.doctype == 'Receivable Voucher': customer = doc_obj.doc.customer
else: customer = doc_obj.doc.customer_name
add_cond = " and master_name = '"+cstr(customer)+"'"
if based_on == 'Itemwise Discount':
if doc_obj:
for t in getlist(doc_obj.doclist, doc_obj.fname):
self.validate_auth_rule(doctype_name, t.adj_rate, based_on, add_cond, company,t.item_code )
else:
self.validate_auth_rule(doctype_name, auth_value, based_on, add_cond, company)
# Check Approving Authority for transactions other than expense voucher and Appraisal
# -------------------------
def validate_approving_authority(self, doctype_name,company, total, doc_obj = ''):
if doctype_name == 'Payable Voucher': doctype_name = 'Purchase Invoice'
elif doctype_name == 'Receivable Voucher': doctype_name = 'Sales Invoice'
av_dis = 0
if doc_obj:
ref_rate, basic_rate = 0, 0
for d in getlist(doc_obj.doclist, doc_obj.fname):
if d.base_ref_rate and d.basic_rate:
ref_rate += flt(d.base_ref_rate)
basic_rate += flt(d.basic_rate)
if ref_rate: av_dis = 100 - flt(basic_rate * 100 / ref_rate)
final_based_on = ['Grand Total','Average Discount','Customerwise Discount','Itemwise Discount']
# Individual User
# ================
# Check for authorization set for individual user
based_on = [x[0] for x in sql("select distinct based_on from `tabAuthorization Rule` where transaction = '%s' and system_user = '%s' and (company = '%s' or ifnull(company,'')='') and docstatus != 2" %(doctype_name, session['user'], company))]
for d in based_on:
self.bifurcate_based_on_type(doctype_name, total, av_dis, d, doc_obj, 1, company)
# Remove user specific rules from global authorization rules
for r in based_on:
if r in final_based_on and r != 'Itemwise Discount': final_based_on.remove(r)
# Specific Role
# ===============
# Check for authorization set on particular roles
#based_on = [x[0] for x in sql("select based_on from `tabAuthorization Rule` where transaction = '%s' and system_role IN %s and based_on IN %s and docstatus != 2" %(doctype_name, "('"+"','".join(session['data']['profile']['roles'])+"')", "('"+"','".join(final_based_on)+"')"))]
based_on = [x[0] for x in sql("select based_on from `tabAuthorization Rule` where transaction = '%s' and system_role IN %s and based_on IN %s and (company = '%s' or ifnull(company,'')='') and docstatus != 2" %(doctype_name, "('"+"','".join(webnotes.user.get_roles())+"')", "('"+"','".join(final_based_on)+"')",company))]
for d in based_on:
self.bifurcate_based_on_type(doctype_name, total, av_dis, d, doc_obj, 2, company)
# Remove role specific rules from global authorization rules
for r in based_on:
if r in final_based_on and r != 'Itemwise Discount': final_based_on.remove(r)
# Global Rule
# =============
# Check for global authorization
for g in final_based_on:
self.bifurcate_based_on_type(doctype_name, total, av_dis, g, doc_obj, 0, company)
#========================================================================================================================
# payroll related check
def get_value_based_rule(self,doctype_name,employee,total_claimed_amount,company):
val_lst =[]
val = sql("select value from `tabAuthorization Rule` where transaction=%s and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s)) and ifnull(value,0)< %s and company = %s and docstatus!=2",(doctype_name,employee,employee,total_claimed_amount,company))
if not val:
val = sql("select value from `tabAuthorization Rule` where transaction=%s and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s)) and ifnull(value,0)< %s and ifnull(company,'') = '' and docstatus!=2",(doctype_name,employee,employee,total_claimed_amount))
if val:
val_lst = [y[0] for y in val]
else:
val_lst.append(0)
max_val = max(val_lst)
rule = sql("select name, to_emp, to_designation, approving_role, approving_user from `tabAuthorization Rule` where transaction=%s and company = %s and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s)) and ifnull(value,0)= %s and docstatus!=2",(doctype_name,company,employee,employee,flt(max_val)), as_dict=1)
if not rule:
rule = sql("select name, to_emp, to_designation, approving_role, approving_user from `tabAuthorization Rule` where transaction=%s and ifnull(company,'') = '' and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s)) and ifnull(value,0)= %s and docstatus!=2",(doctype_name,employee,employee,flt(max_val)), as_dict=1)
return rule
#---------------------------------------------------------------------------------------------------------------------
# related to payroll module only
def get_approver_name(self, doctype_name, total, doc_obj=''):
app_user=[]
app_specific_user =[]
rule ={}
if doc_obj:
if doctype_name == 'Expense Voucher':
rule = self.get_value_based_rule(doctype_name,doc_obj.doc.employee,doc_obj.doc.total_claimed_amount, doc_obj.doc.company)
elif doctype_name == 'Appraisal':
rule = sql("select name, to_emp, to_designation, approving_role, approving_user from `tabAuthorization Rule` where transaction=%s and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s)) and company = %s and docstatus!=2",(doctype_name,doc_obj.doc.employee, doc_obj.doc.employee, doc_obj.doc.company),as_dict=1)
if not rule:
rule = sql("select name, to_emp, to_designation, approving_role, approving_user from `tabAuthorization Rule` where transaction=%s and (to_emp=%s or to_designation IN (select designation from `tabEmployee` where name=%s)) and ifnull(company,'') = '' and docstatus!=2",(doctype_name,doc_obj.doc.employee, doc_obj.doc.employee),as_dict=1)
if rule:
for m in rule:
if m['to_emp'] or m['to_designation']:
if m['approving_user']:
app_specific_user.append(m['approving_user'])
elif m['approving_role']:
user_lst = [z[0] for z in sql("select distinct t1.name from `tabProfile` t1, `tabUserRole` t2 where t2.role=%s and t2.parent=t1.name and t1.name !='Administrator' and t1.name != 'Guest' and t1.docstatus !=2",m['approving_role'])]
for x in user_lst:
if not x in app_user:
app_user.append(x)
if len(app_specific_user) >0:
return app_specific_user
else:
return app_user

View File

@@ -1,30 +0,0 @@
# DocType, Authorization Control
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:52',
'docstatus': 0,
'modified': '2010-12-16 23:57:05',
'modified_by': 'nabin@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'colour': 'White:FFF',
'doctype': 'DocType',
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'section_style': 'Tabbed',
'server_code_error': ' ',
'version': 216
},
# DocType, Authorization Control
{
'doctype': 'DocType',
'name': 'Authorization Control'
}
]

View File

@@ -1,109 +0,0 @@
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
// Settings Module
cur_frm.cscript.refresh = function(doc,cdt,cdn){
if(doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Total Claimed Amount' || doc.based_on == 'Not Applicable') hide_field('master_name');
else unhide_field('master_name');
if(doc.based_on == 'Not Applicable') hide_field('value');
else unhide_field('value');
if(doc.transaction == 'Expense Voucher' || doc.transaction == 'Appraisal'){
hide_field(['master_name','system_role', 'system_user']);
unhide_field(['to_emp','to_designation']);
if(doc.transaction == 'Appraisal') hide_field('value');
else unhide_field('value');
}
else {
unhide_field(['master_name','system_role', 'system_user','value']);
hide_field(['to_emp','to_designation']);
}
}
cur_frm.cscript.based_on = function(doc){
if(doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Total Claimed Amount' || doc.based_on == 'Not Applicable'){
doc.master_name = '';
refresh_field('master_name');
hide_field('master_name');
}
else{
unhide_field('master_name');
}
if(doc.based_on == 'Not Applicable') {
doc.value =0;
refresh_field('value');
hide_field('value');
}
else unhide_field('value');
}
cur_frm.cscript.transaction = function(doc,cdt,cdn){
if(doc.transaction == 'Expense Voucher' || doc.transaction == 'Appraisal'){
doc.master_name = doc.system_role = doc.system_user = '';
refresh_many(['master_name','system_role', 'system_user']);
hide_field(['master_name','system_role', 'system_user']);
unhide_field(['to_emp','to_designation']);
if(doc.transaction == 'Appraisal') {
doc.value =0;
refresh_many('value');
hide_field('value');
}
else unhide_field('value');
}
else {
unhide_field(['master_name','system_role', 'system_user','value']);
hide_field(['to_emp','to_designation']);
}
if(doc.transaction == 'Expense Voucher') doc.based_on = 'Total Claimed Amount';
if(doc.transaction == 'Appraisal') doc.based_on == 'Not Applicable';
}
// System User Trigger
// -------------------
cur_frm.fields_dict['system_user'].get_query = function(doc) {
return 'SELECT tabProfile.name FROM tabProfile WHERE tabProfile.name not in ("Administrator","Guest") AND tabProfile.%(key)s LIKE "%s" LIMIT 50'
}
// System Role Trigger
// -----------------------
cur_frm.fields_dict['system_role'].get_query = function(doc) {
return 'SELECT tabRole.name FROM tabRole WHERE tabRole.name not in ("Administrator","Guest","All") AND tabRole.%(key)s LIKE "%s" LIMIT 50'
}
// Approving User Trigger
// -----------------------
cur_frm.fields_dict['approving_user'].get_query = function(doc) {
return 'SELECT tabProfile.name FROM tabProfile WHERE tabProfile.name not in ("Administrator","Guest") AND tabProfile.%(key)s LIKE "%s" LIMIT 50'
}
// Approving Role Trigger
// -----------------------
cur_frm.fields_dict['approving_role'].get_query = function(doc) {
return 'SELECT tabRole.name FROM tabRole WHERE tabRole.name not in ("Administrator","Guest","All") AND tabRole.%(key)s LIKE "%s" LIMIT 50'
}
// Master Name Trigger
// --------------------
cur_frm.fields_dict['master_name'].get_query = function(doc){
if(doc.based_on == 'Customerwise Discount')
return 'SELECT `tabCustomer`.`name` FROM `tabCustomer` WHERE `tabCustomer`.docstatus !=2 and `tabCustomer`.`name` LIKE "%s" ORDER BY `tabCustomer`.`name` DESC LIMIT 50';
else if(doc.based_on == 'Itemwise Discount')
return 'SELECT `tabItem`.`name` FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) and `tabItem`.is_sales_item = "Yes" and tabItem.%(key)s LIKE "%s" ORDER BY `tabItem`.`name` DESC LIMIT 50';
else
return 'SELECT `tabItem`.`name` FROM `tabItem` WHERE `tabItem`.`name` = "cheating done to avoid null" ORDER BY `tabItem`.`name` DESC LIMIT 50';
}

View File

@@ -1,91 +0,0 @@
# 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
# Duplicate Entry
# ----------------
def check_duplicate_entry(self):
exists = sql("select name, docstatus from `tabAuthorization Rule` where transaction = %s and based_on = %s and system_user = %s and system_role = %s and approving_user = %s and approving_role = %s and to_emp =%s and to_designation=%s and name != %s", (self.doc.transaction, self.doc.based_on, cstr(self.doc.system_user), cstr(self.doc.system_role), cstr(self.doc.approving_user), cstr(self.doc.approving_role), cstr(self.doc.to_emp), cstr(self.doc.to_designation), self.doc.name))
auth_exists = exists and exists[0][0] or ''
if auth_exists:
if cint(exists[0][1]) == 2:
msgprint("Duplicate Entry. Please remove from trash Authorization Rule : %s." %(auth_exists))
raise Exception
else:
msgprint("Duplicate Entry. Please check Authorization Rule : %s." % (auth_exists))
raise Exception
# Validate Master Name
# ---------------------
def validate_master_name(self):
if self.doc.based_on == 'Customerwise Discount' and not sql("select name from tabCustomer where name = '%s' and docstatus != 2" % (self.doc.master_name)):
msgprint("Please select valid Customer Name for Customerwise Discount.")
raise Exception
elif self.doc.based_on == 'Itemwise Discount' and not sql("select name from tabItem where name = '%s' and docstatus != 2" % (self.doc.master_name)):
msgprint("Please select valid Item Name for Itemwise Discount.")
raise Exception
elif (self.doc.based_on == 'Grand Total' or self.doc.based_on == 'Average Discount') and self.doc.master_name:
msgprint("Please remove Customer / Item Name for %s." % (self.doc.based_on))
raise Exception
# Validate Rule
# --------------
def validate_rule(self):
if not self.doc.transaction == 'Expense Voucher' and not self.doc.transaction == 'Appraisal':
if not self.doc.approving_role and not self.doc.approving_user:
msgprint("Please enter Approving Role or Approving User")
raise Exception
elif self.doc.system_user and self.doc.system_user == self.doc.approving_user:
msgprint("Approving User cannot be same as user the rule is Applicable To (User).")
raise Exception
elif self.doc.system_role and self.doc.system_role == self.doc.approving_role:
msgprint("Approving Role cannot be same as user the rule is Applicable To (Role).")
raise Exception
elif self.doc.system_user and self.doc.approving_role and has_common([self.doc.approving_role],[x[0] for x in sql("select role from `tabUserRole` where parent = '%s'" % (self.doc.system_user))]):
msgprint("System User : %s is assigned role : %s. So rule does not make sense." % (self.doc.system_user,self.doc.approving_role))
raise Exception
elif (self.doc.transaction == 'Purchase Order' or self.doc.transaction == 'Purchase Receipt' or self.doc.transaction == 'Purchase Invoice' or self.doc.transaction == 'Stock Entry') and (self.doc.based_on == 'Average Discount' or self.doc.based_on == 'Customerwise Discount' or self.doc.based_on == 'Itemwise Discount'):
msgprint("You cannot set authorization on basis of Discount for %s." % (self.doc.transaction))
raise Exception
elif self.doc.based_on == 'Average Discount' and flt(self.doc.value) > 100.00:
msgprint("Discount cannot given for more than 100 %s." % ('%'))
raise Exception
elif self.doc.based_on == 'Customerwise Discount' and not self.doc.master_name:
msgprint("Please enter Customer Name for 'Customerwise Discount'")
raise Exception
else:
if self.doc.transaction == 'Appraisal' and self.doc.based_on != 'Not Applicable':
msgprint("Based on is 'Not Applicable' while setting authorization rule for 'Appraisal'")
raise Exception
if self.doc.transaction == 'Expense Voucher' and self.doc.based_on != 'Total Claimed Amount':
msgprint("Authorization rule should be based on 'Total Calimed Amount' while setting authorization rule for 'Expense Voucher'")
raise Exception
def validate(self):
self.check_duplicate_entry()
self.validate_rule()
self.validate_master_name()
if not self.doc.value: self.doc.value = flt(0)

View File

@@ -1,226 +0,0 @@
# DocType, Authorization Rule
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:52',
'docstatus': 0,
'modified': '2010-12-02 18:06:28',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1308741898',
'allow_trash': 1,
'autoname': 'AR.####',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'module': 'Setup',
'name': '__common__',
'search_fields': 'transaction,based_on,system_user,system_role,approving_user,approving_role',
'section_style': 'Simple',
'server_code_error': ' ',
'version': 58
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Authorization Rule',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Authorization Rule',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'System Manager',
'write': 1
},
# DocType, Authorization Rule
{
'doctype': 'DocType',
'name': 'Authorization Rule'
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 2
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'company',
'fieldtype': 'Link',
'idx': 1,
'label': 'Company',
'oldfieldname': 'company',
'oldfieldtype': 'Link',
'options': 'Company',
'reqd': 0,
'search_index': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'transaction',
'fieldtype': 'Select',
'idx': 2,
'label': 'Transaction',
'oldfieldname': 'transaction',
'oldfieldtype': 'Select',
'options': '\nDelivery Note\nPurchase Invoice\nPurchase Order\nPurchase Receipt\nQuotation\nSales Invoice\nSales Order\nStock Entry\nExpense Voucher\nAppraisal',
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'based_on',
'fieldtype': 'Select',
'idx': 3,
'label': 'Based On',
'oldfieldname': 'based_on',
'oldfieldtype': 'Select',
'options': '\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nTotal Claimed Amount\nNot Applicable',
'reqd': 1,
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'master_name',
'fieldtype': 'Link',
'idx': 4,
'label': 'Customer / Item Name',
'oldfieldname': 'master_name',
'oldfieldtype': 'Link',
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'system_role',
'fieldtype': 'Link',
'idx': 5,
'label': 'Applicable To (Role)',
'oldfieldname': 'system_role',
'oldfieldtype': 'Link',
'options': 'Role'
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'system_user',
'fieldtype': 'Link',
'idx': 6,
'label': 'Applicable To (User)',
'oldfieldname': 'system_user',
'oldfieldtype': 'Link',
'options': 'Profile'
},
# DocField
{
'colour': 'White:FFF',
'description': 'This will be used for setting rule in HR module',
'doctype': 'DocField',
'fieldname': 'to_emp',
'fieldtype': 'Link',
'idx': 7,
'label': 'Applicable To (Employee)',
'oldfieldname': 'to_emp',
'oldfieldtype': 'Link',
'options': 'Employee',
'search_index': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'This will be used for setting rule in HR module',
'doctype': 'DocField',
'fieldname': 'to_designation',
'fieldtype': 'Link',
'idx': 8,
'label': 'Applicable To (Designation)',
'oldfieldname': 'to_designation',
'oldfieldtype': 'Link',
'options': 'Designation',
'search_index': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'approving_role',
'fieldtype': 'Link',
'idx': 9,
'label': 'Approving Role',
'oldfieldname': 'approving_role',
'oldfieldtype': 'Link',
'options': 'Role'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'approving_user',
'fieldtype': 'Link',
'idx': 10,
'label': 'Approving User',
'oldfieldname': 'approving_user',
'oldfieldtype': 'Link',
'options': 'Profile'
},
# DocField
{
'default': '0.00',
'doctype': 'DocField',
'fieldname': 'value',
'fieldtype': 'Currency',
'idx': 11,
'label': 'Above Value',
'oldfieldname': 'value',
'oldfieldtype': 'Currency'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 12,
'label': 'Trash Reason',
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text'
}
]

View File

@@ -1,10 +0,0 @@
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}

View File

@@ -1,164 +0,0 @@
# DocType, Brand
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:53',
'docstatus': 0,
'modified': '2010-09-20 14:06:57',
'modified_by': 'yogesh@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'allow_trash': 1,
'autoname': 'field:brand',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'module': 'Setup',
'name': '__common__',
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 5
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Brand',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Brand',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1
},
# DocType, Brand
{
'doctype': 'DocType',
'name': 'Brand'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 1,
'role': 'Material Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 0,
'role': 'Material Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 1,
'role': 'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 4,
'permlevel': 0,
'role': 'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 5,
'permlevel': 0,
'role': 'Material Master Manager',
'write': 1
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 6,
'permlevel': 0,
'role': 'System Manager',
'write': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 1,
'label': 'Trash Reason',
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'brand',
'fieldtype': 'Data',
'idx': 2,
'label': 'Brand Name',
'oldfieldname': 'brand',
'oldfieldtype': 'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'description',
'fieldtype': 'Text',
'idx': 3,
'label': 'Description',
'oldfieldname': 'description',
'oldfieldtype': 'Text',
'permlevel': 0,
'width': '300px'
}
]

View File

@@ -1,43 +0,0 @@
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.abbr && !doc.__islocal) set_field_permlevel('abbr',1);
}
cur_frm.cscript.has_special_chars = function(t) {
var iChars = "!@#$%^*+=-[]\\\';,/{}|\":<>?";
for (var i = 0; i < t.length; i++) {
if (iChars.indexOf(t.charAt(i)) != -1) {
return true;
}
}
return false;
}
cur_frm.cscript.company_name = function(doc){
if(doc.company_name && cur_frm.cscript.has_special_chars(doc.company_name)){
msgprint("<font color=red>Special Characters <b>! @ # $ % ^ * + = - [ ] ' ; , / { } | : < > ?</b> are not allowed for</font>\nCompany Name <b>" + doc.company_name +"</b>")
doc.company_name = '';
refresh_field('company_name');
}
}
cur_frm.cscript.abbr = function(doc){
if(doc.abbr && cur_frm.cscript.has_special_chars(doc.abbr)){
msgprint("<font color=red>Special Characters <b>! @ # $ % ^ * + = - [ ] ' ; , / { } | : < > ?</b> are not allowed for</font>\nAbbr <b>" + doc.abbr +"</b>")
doc.abbr = '';
refresh_field('abbr');
}
}
cur_frm.fields_dict.default_bank_account.get_query = function(doc) {
return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
}
cur_frm.fields_dict.receivables_group.get_query = function(doc) {
return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
}
cur_frm.fields_dict.payables_group.get_query = function(doc) {
return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
}

View File

@@ -1,251 +0,0 @@
# 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
# Create default accounts
# ---------------------------------------------------
def create_default_accounts(self):
self.fld_dict = {'account_name':0,'parent_account':1,'group_or_ledger':2,'is_pl_account':3,'account_type':4,'debit_or_credit':5,'company':6,'tax_rate':7}
acc_list_common = [['Application of Funds (Assets)','','Group','No','','Debit',self.doc.name,''],
['Current Assets','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
['Accounts Receivable','Current Assets','Group','No','','Debit',self.doc.name,''],
['Bank Accounts','Current Assets','Group','No','Bank or Cash','Debit',self.doc.name,''],
['Cash In Hand','Current Assets','Group','No','Bank or Cash','Debit',self.doc.name,''],
['Cash','Cash In Hand','Ledger','No','Bank or Cash','Debit',self.doc.name,''],
['Loans and Advances (Assets)','Current Assets','Group','No','','Debit',self.doc.name,''],
['Securities and Deposits','Current Assets','Group','No','','Debit',self.doc.name,''],
['Earnest Money','Securities and Deposits','Ledger','No','','Debit',self.doc.name,''],
['Stock In Hand','Current Assets','Group','No','','Debit',self.doc.name,''],
['Stock','Stock In Hand','Ledger','No','','Debit',self.doc.name,''],
['Tax Assets','Current Assets','Group','No','','Debit',self.doc.name,''],
['Fixed Assets','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
['Capital Equipments','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
['Computers','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
['Furniture and Fixture','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
['Office Equipments','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
['Plant and Machinery','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
['Investments','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
['Temporary Accounts (Assets)','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
['Temporary Account (Assets)','Temporary Accounts (Assets)','Ledger','No','','Debit',self.doc.name,''],
['Source of Funds (Liabilities)','','Group','No','','Credit',self.doc.name,''],
['Capital Account','Source of Funds (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Reserves and Surplus','Capital Account','Group','No','','Credit',self.doc.name,''],
['Shareholders Funds','Capital Account','Group','No','','Credit',self.doc.name,''],
['Current Liabilities','Source of Funds (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Accounts Payable','Current Liabilities','Group','No','','Credit',self.doc.name,''],
['Duties and Taxes','Current Liabilities','Group','No','','Credit',self.doc.name,''],
['Loans (Liabilities)','Current Liabilities','Group','No','','Credit',self.doc.name,''],
['Secured Loans','Loans (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Unsecured Loans','Loans (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Bank Overdraft Account','Loans (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Temporary Accounts (Liabilities)','Source of Funds (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Temporary Account (Liabilities)','Temporary Accounts (Liabilities)','Ledger','No','','Credit',self.doc.name,''],
['Income','','Group','Yes','','Credit',self.doc.name,''],
['Direct Income','Income','Group','Yes','Income Account','Credit',self.doc.name,''],
['Sales','Direct Income','Ledger','Yes','Income Account','Credit',self.doc.name,''],
['Service','Direct Income','Ledger','Yes','Income Account','Credit',self.doc.name,''],
['Indirect Income','Income','Group','Yes','Income Account','Credit',self.doc.name,''],
['Expenses','','Group','Yes','Expense Account','Debit',self.doc.name,''],
['Direct Expenses','Expenses','Group','Yes','Expense Account','Debit',self.doc.name,''],
['Cost of Goods Sold','Direct Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Indirect Expenses','Expenses','Group','Yes','Expense Account','Debit',self.doc.name,''],
['Advertising and Publicity','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
['Bad Debts Written Off','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Bank Charges','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Books and Periodicals','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Charity and Donations','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Commission on Sales','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Conveyance Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Customer Entertainment Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Depreciation Account','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Freight and Forwarding Charges','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
['Legal Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Miscellaneous Expenses','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
['Office Maintenance Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Office Rent','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Postal Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Print and Stationary','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Rounded Off','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Salary','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Sales Promotion Expenses','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
['Service Charges Paid','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Staff Welfare Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Telephone Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Travelling Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Water and Electricity Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,'']
]
acc_list_india = [
['CENVAT Capital Goods','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
['CENVAT','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['CENVAT Service Tax','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
['CENVAT Service Tax Cess 1','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
['CENVAT Service Tax Cess 2','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
['CENVAT Edu Cess','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['CENVAT SHE Cess','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['Excise Duty 4','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'4.00'],
['Excise Duty 8','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'8.00'],
['Excise Duty 10','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'10.00'],
['Excise Duty 14','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'14.00'],
['Excise Duty Edu Cess 2','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'2.00'],
['Excise Duty SHE Cess 1','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'1.00'],
['P L A','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
['P L A - Cess Portion','Tax Assets','Ledger','No','','Debit',self.doc.name,''],
['Edu. Cess on Excise','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'2.00'],
['Edu. Cess on Service Tax','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'2.00'],
['Edu. Cess on TDS','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'2.00'],
['Excise Duty @ 4','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'4.00'],
['Excise Duty @ 8','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'8.00'],
['Excise Duty @ 10','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'10.00'],
['Excise Duty @ 14','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'14.00'],
['Service Tax','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'10.3'],
['SHE Cess on Excise','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'1.00'],
['SHE Cess on Service Tax','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'1.00'],
['SHE Cess on TDS','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'1.00'],
['Professional Tax','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
['VAT','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
['TDS (Advertisement)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
['TDS (Commission)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
['TDS (Contractor)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
['TDS (Interest)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
['TDS (Rent)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,''],
['TDS (Salary)','Duties and Taxes','Ledger','No','','Credit',self.doc.name,'']
]
# load common account heads
for d in acc_list_common:
self.add_acc(d)
country = sql("select value from tabSingles where field = 'country' and doctype = 'Control Panel'")
country = country and cstr(country[0][0]) or ''
# load taxes (only for India)
if country == 'India':
for d in acc_list_india:
self.add_acc(d)
# Create account
# ---------------------------------------------------
def add_acc(self,lst):
ac = Document('Account')
for d in self.fld_dict.keys():
ac.fields[d] = (d == 'parent_account' and lst[self.fld_dict[d]]) and lst[self.fld_dict[d]] +' - '+ self.doc.abbr or lst[self.fld_dict[d]]
ac.old_parent = ''
ac_obj = get_obj(doc=ac)
ac_obj.validate()
ac_obj.doc.save(1)
ac_obj.on_update()
sql("commit")
sql("start transaction")
# Set letter head
# ---------------------------------------------------
def set_letter_head(self):
if not self.doc.letter_head:
if self.doc.address:
header = """
<div><h3> %(comp)s </h3> %(add)s </div>
""" % {'comp':self.doc.name,
'add':self.doc.address.replace("\n",'<br>')}
self.doc.letter_head = header
# Set default AR and AP group
# ---------------------------------------------------
def set_default_groups(self):
if not self.doc.receivables_group:
set(self.doc, 'receivables_group', 'Accounts Receivable - '+self.doc.abbr)
if not self.doc.payables_group:
set(self.doc, 'payables_group', 'Accounts Payable - '+self.doc.abbr)
# Create default cost center
# ---------------------------------------------------
def create_default_cost_center(self):
glc = get_obj('GL Control')
cc_list = [{'cost_center_name':'Root','company_name':self.doc.name,'company_abbr':self.doc.abbr,'group_or_ledger':'Group','parent_cost_center':'','old_parent':''}, {'cost_center_name':'Default CC Ledger','company_name':self.doc.name,'company_abbr':self.doc.abbr,'group_or_ledger':'Ledger','parent_cost_center':'Root - ' + self.doc.abbr,'old_parent':''}]
for c in cc_list:
glc.add_cc(str(c))
# On update
# ---------------------------------------------------
def on_update(self):
self.set_letter_head()
ac = sql("select name from tabAccount where account_name='Income' and company=%s", self.doc.name)
if not ac:
self.create_default_accounts()
self.set_default_groups()
cc = sql("select name from `tabCost Center` where cost_center_name = 'Root' and company_name = '%s'"%(self.doc.name))
if not cc:
self.create_default_cost_center()
# Trash accounts and cost centers for this company
# ---------------------------------------------------
#def on_trash1(self):
# acc = sql("select name from tabAccount where company = '%s' and docstatus != 2 order by lft desc, rgt desc limit 2" % self.doc.name, debug=1)
# for each in acc:
# get_obj('Account', each[0]).on_trash()
# cc = sql("select name from `tabCost Center` where company_name = '%s' and docstatus != 2" % self.doc.name)
# for each in cc:
# get_obj('Cost Center', each[0]).on_trash()
# msgprint("Company trashed. All the accounts and cost centers related to this company also trashed. You can restore it anytime from Setup -> Manage Trash")
def on_trash(self):
rec = sql("SELECT sum(ab.opening), sum(ab.balance), sum(ab.debit), sum(ab.credit) FROM `tabAccount Balance` ab, `tabAccount` a WHERE ab.account = a.name and a.company = %s", self.doc.name)
if rec[0][0] == 0 and rec[0][1] == 0 and rec[0][2] == 0 and rec[0][3] == 0:
#delete tabAccount Balance
sql("delete ab.* from `tabAccount Balance` ab, `tabAccount` a where ab.account = a.name and a.company = %s", self.doc.name)
#delete tabAccount
sql("delete from `tabAccount` where company = %s order by lft desc, rgt desc", self.doc.name)
#delete cost center child table - budget detail
sql("delete bd.* from `tabBudget Detail` bd, `tabCost Center` cc where bd.parent = cc.name and cc.company_name = %s", self.doc.name)
#delete cost center
sql("delete from `tabCost Center` WHERE company_name = %s order by lft desc, rgt desc", self.doc.name)
#update value as blank for tabDefaultValue defkey=company
sql("update `tabDefaultValue` set defvalue = '' where defkey='company' and defvalue = %s", self.doc.name)
#update value as blank for tabSingles Manage Account
sql("update `tabSingles` set value = '' where doctype='Manage Account' and field = 'default_company' and value = %s", self.doc.name)
# Restore accounts and cost centers for this company
# ---------------------------------------------------
def on_restore(self):
acc = sql("select name from tabAccount where company = '%s' and docstatus = 2" % self.doc.name)
for each in acc:
get_obj('Account', each[0]).on_restore()
cc = sql("select name from `tabCost Center` where company_name = '%s' and docstatus = 2" % self.doc.name)
for each in cc:
get_obj('Cost Center', each[0]).on_restore()
msgprint("Company restored. All the accounts and cost centers related to this company also restored.")
# on rename
# ---------
def on_rename(self,newdn,olddn):
sql("update `tabCompany` set company_name = '%s' where name = '%s'" %(newdn,olddn))

View File

@@ -1,377 +0,0 @@
# DocType, Company
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:55',
'docstatus': 0,
'modified': '2011-07-01 17:43:29',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1309506817',
'allow_trash': 1,
'autoname': 'field:company_name',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'module': 'Setup',
'name': '__common__',
'section_style': 'Tabbed',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 93
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Company',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# These values are common for all DocPerm
{
'cancel': 0,
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Company',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1
},
# DocType, Company
{
'doctype': 'DocType',
'name': 'Company'
},
# DocPerm
{
'amend': 0,
'create': 1,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 0,
'role': 'System Manager',
'submit': 0,
'write': 1
},
# DocPerm
{
'amend': 0,
'create': 1,
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 0,
'role': 'System Manager',
'submit': 0,
'write': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 1,
'role': 'All'
},
# DocField
{
'description': 'Please Enter Company Name and Abbr and save the document. Once saved Accounting Settings will be populated automatically',
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 1,
'label': 'Details',
'oldfieldtype': 'Section Break',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'company_name',
'fieldtype': 'Data',
'idx': 2,
'label': 'Company',
'no_copy': 0,
'oldfieldname': 'company_name',
'oldfieldtype': 'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': 'White:FFF',
'description': 'Please Enter Abbreviation or Short Name properly as it will be added as Suffix to all Account Heads.',
'doctype': 'DocField',
'fieldname': 'abbr',
'fieldtype': 'Data',
'idx': 3,
'label': 'Abbr',
'no_copy': 0,
'oldfieldname': 'abbr',
'oldfieldtype': 'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'address',
'fieldtype': 'Small Text',
'idx': 4,
'label': 'Address',
'oldfieldname': 'address',
'oldfieldtype': 'Small Text',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_currency',
'fieldtype': 'Select',
'idx': 5,
'label': 'Default Currency',
'options': 'link:Currency',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 6,
'oldfieldtype': 'Column Break',
'permlevel': 0,
'width': '50%'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'phone_no',
'fieldtype': 'Data',
'idx': 7,
'label': 'Phone No',
'oldfieldname': 'phone_no',
'oldfieldtype': 'Data',
'options': 'Phone',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'email',
'fieldtype': 'Data',
'idx': 8,
'label': 'Email',
'oldfieldname': 'email',
'oldfieldtype': 'Data',
'options': 'Email',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'fax',
'fieldtype': 'Data',
'idx': 9,
'label': 'Fax',
'oldfieldname': 'fax',
'oldfieldtype': 'Data',
'options': 'Phone',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'website',
'fieldtype': 'Data',
'idx': 10,
'label': 'Website',
'oldfieldname': 'website',
'oldfieldtype': 'Data',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Company registration numbers for your reference. Example: VAT Registration Numbers etc.',
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 11,
'label': 'Registration Info',
'oldfieldtype': 'Section Break',
'permlevel': 0,
'width': '50%'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Company registration numbers for your reference. Tax numbers etc.',
'doctype': 'DocField',
'fieldname': 'registration_details',
'fieldtype': 'Code',
'idx': 12,
'label': 'Registration Details',
'oldfieldname': 'registration_details',
'oldfieldtype': 'Code',
'permlevel': 0
},
# DocField
{
'depends_on': 'eval:!doc.__islocal',
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 13,
'label': 'Accounting Settings',
'oldfieldtype': 'Section Break',
'permlevel': 0
},
# DocField
{
'depends_on': 'eval:!doc.__islocal',
'doctype': 'DocField',
'fieldname': 'default_bank_account',
'fieldtype': 'Link',
'idx': 14,
'label': 'Default Bank Account',
'no_copy': 1,
'oldfieldname': 'default_bank_account',
'oldfieldtype': 'Link',
'options': 'Account',
'permlevel': 0,
'trigger': 'Client'
},
# DocField
{
'depends_on': 'eval:!doc.__islocal',
'doctype': 'DocField',
'fieldname': 'receivables_group',
'fieldtype': 'Link',
'idx': 15,
'label': 'Receivables Group',
'no_copy': 1,
'oldfieldname': 'receivables_group',
'oldfieldtype': 'Link',
'options': 'Account',
'permlevel': 0,
'trigger': 'Client'
},
# DocField
{
'depends_on': 'eval:!doc.__islocal',
'doctype': 'DocField',
'fieldname': 'payables_group',
'fieldtype': 'Link',
'idx': 16,
'label': 'Payables Group',
'no_copy': 1,
'oldfieldname': 'payables_group',
'oldfieldtype': 'Link',
'options': 'Account',
'permlevel': 0,
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 17,
'oldfieldtype': 'Column Break',
'permlevel': 0,
'width': '50%'
},
# DocField
{
'colour': 'White:FFF',
'depends_on': 'eval:!doc.__islocal',
'doctype': 'DocField',
'fieldname': 'yearly_bgt_flag',
'fieldtype': 'Select',
'idx': 18,
'label': 'If Yearly Budget Exceeded',
'oldfieldname': 'yearly_bgt_flag',
'oldfieldtype': 'Select',
'options': '\nWarn\nIgnore\nStop',
'permlevel': 0
},
# DocField
{
'depends_on': 'eval:!doc.__islocal',
'doctype': 'DocField',
'fieldname': 'monthly_bgt_flag',
'fieldtype': 'Select',
'idx': 19,
'label': 'If Monthly Budget Exceeded',
'oldfieldname': 'monthly_bgt_flag',
'oldfieldtype': 'Select',
'options': '\nWarn\nIgnore\nStop',
'permlevel': 0
},
# DocField
{
'depends_on': 'eval:!doc.__islocal',
'doctype': 'DocField',
'fieldname': 'credit_days',
'fieldtype': 'Int',
'idx': 20,
'label': 'Credit Days',
'oldfieldname': 'credit_days',
'oldfieldtype': 'Int',
'permlevel': 0
},
# DocField
{
'depends_on': 'eval:!doc.__islocal',
'doctype': 'DocField',
'fieldname': 'credit_limit',
'fieldtype': 'Currency',
'idx': 21,
'label': 'Credit Limit',
'oldfieldname': 'credit_limit',
'oldfieldtype': 'Currency',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 22,
'label': 'Trash Reason',
'no_copy': 1,
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1
}
]

View File

@@ -1,562 +0,0 @@
// common partner functions
// =========================
/*
// make shipping list body
// ------------------------
cur_frm.cscript.make_sl_body = function(){
cur_frm.fields_dict['Shipping HTML'].wrapper.innerHTML = '';
cur_frm.shipping_html = $a(cur_frm.fields_dict['Shipping HTML'].wrapper,'div');
}
*/
// make history list body
// -----------------------
cur_frm.cscript.make_hl_body = function(){
cur_frm.fields_dict['History HTML'].wrapper.innerHTML = '';
cur_frm.history_html = $a(cur_frm.fields_dict['History HTML'].wrapper,'div');
}
/*
// set shipping list message
// --------------------------
cur_frm.cscript.set_sl_msg = function(doc){
cur_frm.shipping_html.innerHTML = 'Shipping Address Details will appear only when you save the ' + doc.doctype.toLowerCase();
}
*/
/*
// set history list message
// -------------------------
cur_frm.cscript.set_hl_msg = function(doc){
cur_frm.history_html.innerHTML= 'History Details will appear only when you save the ' + doc.doctype.toLowerCase();
}
*/
/*
// make shipping address
// -------------
cur_frm.cscript.make_shipping_address = function(doc, dt, dn){
cur_frm.shipping_html.innerHTML = '';
var dsn = cur_frm.doc.customer_name;
var dsa = cur_frm.doc.address;
cl = new AddressList(cur_frm.shipping_html,dt,dn,dsn,dsa);
}
*/
// make history
// -------------
cur_frm.cscript.make_history = function(doc,dt,dn){
cur_frm.history_html.innerHTML = '';
cur_frm.cscript.make_history_list(cur_frm.history_html,doc);
}
// make history list
// ------------------
cur_frm.cscript.make_history_list = function(parent,doc){
var sel = $a(parent,'select');
var ls = ['Select Transaction..'];
for(d in cur_frm.history_dict){
ls.push(d);
}
add_sel_options(sel,ls,'Select..');
var body = $a(parent,'div');
body.innerHTML = '<div class="help_box">Please select a transaction type to see History</div>';
sel.body = body;
sel.doc = doc;
sel.onchange = function(){
for(d in cur_frm.history_dict){
if(sel_val(this) == d){
this.body.innerHTML = '';
eval(cur_frm.history_dict[d]);
return;
}
else{
// pass
}
}
}
}
// run list
// ---------
cur_frm.cscript.run_list = function(lst,parent,q,q_max,doc,dn,nm){
parent.innerHTML = '';
$dh(parent);
lst.doc = doc;
lst.dn = dn;
lst.nm = nm;
lst.page_len = 10;
lst.get_query = function(){
this.query = q;
this.query_max = q_max;
}
lst.make(parent);
lst.run();
lst.onrun = function(){
$ds(parent);
if(!this.has_data()){
parent.innerHTML = '';
var dv = $a(parent,'div','help_box');
$a(dv,'span').innerHTML = "No " + this.dn + " found. ";
var lbl = 'Create the <b>first</b> ' + this.dn + ' for ' + this.doc.name;
var sp = $a(dv,'span');
sp.nm = this.nm;
$(sp).html(lbl).addClass('link_type').click(function(){ newdoc(this.nm); });
}
}
}
// get sates on country trigger
// -----------------------------
cur_frm.cscript.get_states=function(doc,dt,dn){
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])},
function(r,rt){
if(r.message) {
set_field_options('state', r.message);
}
}
);
}
cur_frm.cscript.country = function(doc, dt, dn) {
cur_frm.cscript.get_states(doc, dt, dn);
}
// territory help - cutsomer + sales partner
// -----------------------------------------
cur_frm.cscript.TerritoryHelp = function(doc,dt,dn){
var call_back = function(){
var sb_obj = new SalesBrowser();
sb_obj.set_val('Territory');
}
loadpage('Sales Browser',call_back);
}
// get query select Territory
// ---------------------------
if(cur_frm.fields_dict['territory']){
cur_frm.fields_dict['territory'].get_query = function(doc,dt,dn) {
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
}
}
// =======================================================================================================
// contact list
// --------------
ContactList = function(parent,dt,dn,dsn){
var me = this;
this.dt = dt;
this.dn = dn;
this.dsn = dsn ? dsn : dn;
this.wrapper = $a(parent,'div');
me.get_list();
}
// add contact
// ------------
ContactList.prototype.add_contact = function(){
var me = this;
// onload - set default values
var cont = LocalDB.create('Contact');
var c = locals['Contact'][cont];
if(me.dt == 'Customer') {
c.is_customer = 1;
c.customer = me.dn;
c.customer_name = me.dsn;
}
else if(me.dt == 'Supplier'){
c.is_supplier = 1;
c.supplier = me.dn;
c.supplier_name = me.dsn;
}
else if(me.dt == 'Sales Partner'){
c.is_sales_partner = 1;
c.sales_partner = me.dn;
//c.sales_partner_name = me.dsn;
}
loaddoc('Contact',c.name);
}
// get contact list
// -----------------
ContactList.prototype.get_list = function(){
var me = this;
me.make_list();
var dt = me.dt.toLowerCase().split(' ').join('_');
// build query
me.lst.get_query = function(){
this.query = repl("select name, first_name, last_name, concat_ws(' ', first_name, last_name), email_id, contact_no, department, designation, is_primary_contact, has_login, disable_login from tabContact where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
this.query_max = repl("select count(name) from tabContact where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
}
// render list ui
me.lst.show_cell = function(cell,ri,ci,d){
me.render_list(cell,ri,ci,d);
}
// run query
me.lst.run();
// onrun
me.lst.onrun = function(){
if(!this.has_data()){
this.rec_label.innerHTML = '';
$a(this.rec_label,'span').innerHTML = "You do not have any contact. ";
$($a(this.rec_label,'span')).html('Add a new contact').addClass('link_type').click(function(){ me.add_contact(); });
$dh(this.results);
}
else{
$ds(this.results);
}
}
}
// make list
// -----------
ContactList.prototype.make_list = function(){
var me = this;
var l = new Listing();
l.colwidths = ['5%','30%','30%','20%','20%'];
l.colnames = ['Sr.','Contact Name','Email Id','Contact No', 'Action'];
l.page_len = 10;
me.lst = l;
l.make(me.wrapper);
// Add contact button
me.add_btn = $btn(l.btn_area,'+ Add Contact', function(){ me.add_contact();}, {fontWeight:'bold'});
}
// make contact cell
// ------------------
ContactList.prototype.render_list = function(cell,ri,ci,d){
var me = this;
// name
if(ci == 0){
var nm = $a($a(cell,'div'),'span','',{cursor:'pointer'});
nm.innerHTML = d[ri][3];
nm.id = d[ri][0];
nm.onclick = function(){
loaddoc('Contact', this.id);
// on save callback - refresh list
}
// department and designation
var des = d[ri][7] ? d[ri][7] : '';
var dep = d[ri][6] ? d[ri][6] : '';
var sp = $a(cell,'div','comment');
sp.innerHTML = des + (dep ? (', ' + dep) : '');
}
// email id, contact no, department, designation
// -----------------------------------------------------
if(ci == 1) cell.innerHTML = d[ri][4] ? d[ri][4] : '-';
if(ci == 2) cell.innerHTML = d[ri][5] ? d[ri][5] : '-';
// actions
// --------------------------------------
if(ci== 3) me.make_actions(cell,ri,ci,d);
}
// make actions
// ---------------
ContactList.prototype.make_actions = function(cell,ri,ci,d){
var me = this;
var tab = make_table(cell,1,2,'100%',['40%','60%']);
// Edit and Delete
var t = make_table($td(tab,0,0),1,2);
var edit = $a($td(t,0,0),'div','wn-icon ic-doc_edit');
$(edit).click(function(){ loaddoc('Contact',d[ri][0]); });
edit.setAttribute('title','Edit');
// Below code should be uncommented once customer/venodr invitation process is stable
// ===========================================================================
/*
var del = $a($td(t,0,1),'div','wn-icon ic-trash');
$(del).click(function(){ me.delete_contact(d[ri][0],d[ri][4]) });
set_custom_tooltip(del, 'Delete');
// Invite, Enable and Disable - Integrate after gateway logic incorporated
if(d[ri][9] == 'Yes') {
if(d[ri][10] == 'Yes'){
var enb = $a($td(tab,0,1),'div','wn-icon ic-checkmark');
$(enb).click(function(){ me.enable_login(d[ri][0], d[ri][4]); });
}
else{
var dsb = $a($td(tab,0,1),'div','wn-icon ic-delete');
$(dsb).click(function(){ me.disable_login(d[ri][0], d[ri][4]) });
}
}
else{
var inv = $a($td(tab,0,1),'div','wn-icon ic-mail');
$(inv).click(function(){ me.invite_contact(d[ri][0], d[ri][4], d[ri][1], d[ri][2]) });
}*/
}
// enable login
// ----------------------------------------------------------
ContactList.prototype.enable_login = function(id, email_id){
var me = this;
var callback = function(r,rt){
me.get_list();
if(!r.exc) msgprint('Login for contact enabled',1);
else errprint(r.exc);
}
var args = {};
args.contact = id;
args.email = email_id;
$c_obj('Contact Control','enable_login',JSON.stringify(args),callback);
}
// disable login
// -------------------------------------------------------------
ContactList.prototype.disable_login = function(id, email_id){
var me = this;
var callback = function(r,rt){
me.get_list();
if(!r.exc) msgprint('Login for contact disabled',1);
else errprint(r.exc);
}
var args = {};
args.contact = id;
args.email = email_id;
$c_obj('Contact Control','disable_login',JSON.stringify(args),callback);
}
// delete contact
// -----------------
ContactList.prototype.delete_contact = function(id,email_id,has_login){
var me = this;
var callback = function(r,rt){
me.get_list();
if(!r.exc) msgprint('Contact deleted successfully');
else errprint(r.exc);
}
var args = {};
args.contact = id;
args.email = email_id;
args.has_login = has_login;
$c_obj('Contact Control','delete_contact',JSON.stringify(args),callback);
}
// invite user
// --------------------------------------------------------
ContactList.prototype.invite_contact = function(id,email_id,first_name,last_name){
var me = this;
if(!email_id){
msgprint("Please add email id and save the contact first. You can then invite contact to view transactions.")
}
else{
var callback = function(r,rt){
if(!r.exc) msgprint('Invitation sent');
else errprint(r.exc);
}
var args = {
'contact' : id,
'email' : email_id,
'first_name' : first_name ? first_name : '',
'last_name' : last_name ? last_name : '',
'usert_type' : 'Partner'
};
$c_obj('Contact Control','invite_contact',JSON.stringify(args),callback);
}
}
// address list
// --------------
AddressList = function(parent,dt,dn,dsn,dsa){
var me = this;
this.dt = dt;
this.dn = dn;
this.dsn = dsn ? dsn : dn;
this.dsa = dsa ? dsa : '';
this.wrapper = $a(parent,'div');
me.get_addr_list();
}
// add contact
// ------------
AddressList.prototype.add_address = function(){
var me = this;
// onload - set default values
var addr = LocalDB.create('Shipping Address');
var a = locals['Shipping Address'][addr];
a.customer = me.dn;
a.customer_name = me.dsn;
a.customer_address = me.dsa;
loaddoc('Shipping Address',a.name);
}
// get address list
// -----------------
AddressList.prototype.get_addr_list = function(){
var me = this;
me.make_addr_list();
var dt = me.dt.toLowerCase().split(' ').join('_');
// build query
me.lst.get_query = function(){
this.query = repl("select name, ship_to, shipping_address, is_primary_address, shipping_details from `tabShipping Address` where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
this.query_max = repl("select count(name) from `tabShipping Address` where %(dt)s = '%(dn)s'",{'dt':dt, 'dn':me.dn});
}
// render list ui
me.lst.show_cell = function(cell,ri,ci,d){
me.render_list(cell,ri,ci,d);
}
// run query
me.lst.run();
// onrun
me.lst.onrun = function(){
if(!this.has_data()){
this.rec_label.innerHTML = '';
$a(this.rec_label,'span').innerHTML = "You do not have any shipping address.";
$($a(this.rec_label,'span')).html('Add a new address').addClass('link_type').click(function(){ me.add_address(); });
$dh(this.results);
}
else{
$ds(this.results);
}
}
}
// make list
// -----------
AddressList.prototype.make_addr_list = function(){
var me = this;
var l = new Listing();
l.colwidths = ['5%', '15%', '25%','10%','35%','10%'];
l.colnames = ['Sr.', 'Ship To', 'Shipping Address','Primary Address', 'Shipping Details', 'Action'];
l.page_len = 10;
me.lst = l;
l.make(me.wrapper);
// Add address button
me.add_btn = $btn(l.btn_area,'+ Add Address', function(){ me.add_address();}, {fontWeight:'bold'});
}
// make address cell
// ------------------
AddressList.prototype.render_list = function(cell,ri,ci,d){
var me = this;
// name
if(ci == 0){
var nm = $a($a(cell,'div'),'span','',{cursor:'pointer'});
nm.innerHTML = d[ri][1];
nm.id = d[ri][0];
nm.onclick = function(){
loaddoc('Shipping Address', this.id);
}
}
// shipping address, primary address, shipping details
// ----------------------------------------------------
if(ci == 1) cell.innerHTML = d[ri][2] ? d[ri][2] : '-';
if(ci == 2) cell.innerHTML = d[ri][3] ? d[ri][3] : '-';
if(ci == 3) cell.innerHTML = d[ri][4] ? d[ri][4] : '-';
// actions
// --------------------------------------
if(ci== 4) me.make_actions(cell,ri,ci,d);
}
// make actions
// ---------------
AddressList.prototype.make_actions = function(cell,ri,ci,d){
var me = this;
var tab = make_table(cell,1,2,'100%',['40%','60%']);
// Edit and Delete
var t = make_table($td(tab,0,0),1,2);
var edit = $a($td(t,0,0),'div','wn-icon ic-doc_edit');
$(edit).click(function(){ loaddoc('Shipping Address',d[ri][0]); });
edit.setAttribute('title','Edit');
}

View File

@@ -1,103 +0,0 @@
# 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 enable_login(self,arg):
arg = eval(arg)
sql("update tabContact set disable_login = 'No' where name=%s",arg['contact'])
sql("update tabProfile set enabled=1 where name=%s",arg['email'])
def disable_login(self,arg):
arg = eval(arg)
sql("update tabContact set disable_login = 'Yes' where name=%s",arg['contact'])
sql("update tabProfile set enabled=0 where name=%s",arg['email'])
def create_login(self,arg):
arg = eval(arg)
cont_det = sql("select * from tabContact where name=%s",(arg['contact']),as_dict=1)
if cont_det[0]['docstatus'] !=0:
msgprint('Please save the corresponding contact first')
raise Exception
if sql("select name from tabProfile where name=%s",cont_det[0]['email_id']):
msgprint('Profile with same name already exist.')
raise Exception
else:
p = Document('Profile')
p.name = cont_det[0]['email_id']
p.first_name = cont_det[0]['first_name']
p.last_name = cont_det[0]['last_name']
p.email = cont_det[0]['email_id']
p.cell_no = cont_det[0]['contact_no']
p.password = 'password'
p.enabled = 1
p.user_type = 'Partner';
p.save(1)
get_obj(doc=p).on_update()
role = []
if cont_det[0]['contact_type'] == 'Individual':
role = ['Customer']
else:
if cont_det[0]['is_customer']:
role.append('Customer')
if cont_det[0]['is_supplier']:
role.append('Supplier')
if cont_det[0]['is_sales_partner']:
role.append('Partner')
if role:
prof_nm = p.name
for i in role:
r = Document('UserRole')
r.parent = p.name
r.role = i
r.parenttype = 'Profile'
r.parentfield = 'userroles'
r.save(1)
if i == 'Customer':
def_keys = ['from_company','customer_name','customer']
def_val = cont_det[0]['customer_name']
self.set_default_val(def_keys,def_val,prof_nm)
if i == 'Supplier':
def_keys = ['supplier_name','supplier']
def_val = cont_det[0]['supplier_name']
self.set_default_val(def_keys,def_val,prof_nm)
sql("update tabContact set has_login = 'Yes' where name=%s",cont_det[0]['name'])
sql("update tabContact set disable_login = 'No' where name=%s",cont_det[0]['name'])
msgprint('User login is created.')
#------set default values---------
def set_default_val(self,def_keys,def_val,prof_nm):
for d in def_keys:
kv = Document('DefaultValue')
kv.defkey = d
kv.defvalue = def_val
kv.parent = prof_nm
kv.parenttype = 'Profile'
kv.parentfield = 'defaults'
kv.save(1)

View File

@@ -1,88 +0,0 @@
# DocType, Contact Control
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:56',
'docstatus': 0,
'modified': '2010-09-20 14:06:57',
'modified_by': 'yogesh@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'colour': 'White:FFF',
'doctype': 'DocType',
'in_create': 1,
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'read_only': 1,
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 25
},
# These values are common for all DocField
{
'doctype': 'DocField',
'fieldtype': 'Text',
'name': '__common__',
'parent': 'Contact Control',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 0,
'doctype': 'DocPerm',
'idx': 1,
'name': '__common__',
'parent': 'Contact Control',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'System Manager',
'write': 1
},
# DocType, Contact Control
{
'doctype': 'DocType',
'name': 'Contact Control'
},
# DocPerm
{
'doctype': 'DocPerm'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'header',
'idx': 1,
'label': 'Header'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'customer_intro',
'idx': 2,
'label': 'Customer Intro'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'supplier_intro',
'idx': 3,
'label': 'Supplier Intro'
}
]

View File

@@ -1,13 +0,0 @@
//Tips not required
/*
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}
*/

View File

@@ -1,100 +0,0 @@
# DocType, Country
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:56',
'docstatus': 0,
'modified': '2010-09-20 14:06:57',
'modified_by': 'yogesh@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'autoname': 'field:country_name',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'in_create': 0,
'module': 'Setup',
'name': '__common__',
'read_only': 0,
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 11
},
# These values are common for all DocField
{
'doctype': 'DocField',
'fieldname': 'country_name',
'fieldtype': 'Data',
'idx': 1,
'label': 'Country Name',
'name': '__common__',
'oldfieldname': 'country_name',
'oldfieldtype': 'Data',
'parent': 'Country',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'reqd': 1
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Country',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'write': 1
},
# DocType, Country
{
'doctype': 'DocType',
'name': 'Country'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'doctype': 'DocPerm',
'idx': 1,
'role': 'Sales Master Manager',
'submit': 0
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 2,
'role': 'Purchase Master Manager'
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 3,
'role': 'HR User'
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 4,
'role': 'HR Manager'
},
# DocField
{
'doctype': 'DocField'
}
]

View File

@@ -1,95 +0,0 @@
# DocType, Currency
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:56',
'docstatus': 0,
'modified': '2010-11-18 16:00:32',
'modified_by': 'yogesh@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'autoname': 'field:currency_name',
'colour': 'White:FFF',
'doctype': 'DocType',
'in_create': 0,
'module': 'Setup',
'name': '__common__',
'read_only': 0,
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 3
},
# These values are common for all DocField
{
'doctype': 'DocField',
'fieldname': 'currency_name',
'fieldtype': 'Data',
'idx': 1,
'label': 'Currency Name',
'name': '__common__',
'oldfieldname': 'currency_name',
'oldfieldtype': 'Data',
'parent': 'Currency',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'reqd': 1
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Currency',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'write': 1
},
# DocType, Currency
{
'doctype': 'DocType',
'name': 'Currency'
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 1,
'role': 'Accounts Manager'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'doctype': 'DocPerm',
'idx': 2,
'role': 'Sales Master Manager',
'submit': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'doctype': 'DocPerm',
'idx': 3,
'role': 'Purchase Master Manager',
'submit': 0
},
# DocField
{
'doctype': 'DocField'
}
]

View File

@@ -1,18 +0,0 @@
cur_frm.cscript.onload = function(){
if(doc.__islocal){
doc.parent_customer_group = 'Root';
refresh('parent_customer_group');
}
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}
//get query select Customer Group
cur_frm.fields_dict['parent_customer_group'].get_query = function(doc,cdt,cdn) {
return 'SELECT `tabCustomer Group`.`name`,`tabCustomer Group`.`parent_customer_group` FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "Yes" AND `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" ORDER BY `tabCustomer Group`.`name` ASC LIMIT 50';
}

View File

@@ -1,45 +0,0 @@
# 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
self.nsm_parent_field = 'parent_customer_group';
# update Node Set Model
def update_nsm_model(self):
import webnotes
import webnotes.utils.nestedset
webnotes.utils.nestedset.update_nsm(self)
# ON UPDATE
#--------------------------------------
def on_update(self):
# update nsm
self.update_nsm_model()
def validate(self):
r = sql("select name from `tabCustomer Group` where name = '%s' and docstatus = 2"%(self.doc.customer_group_name))
if r:
msgprint("%s record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.customer_group_name))
raise Exception

View File

@@ -1,243 +0,0 @@
# DocType, Customer Group
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:57',
'docstatus': 0,
'modified': '2010-09-20 14:06:57',
'modified_by': 'yogesh@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'allow_trash': 1,
'autoname': 'field:customer_group_name',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'in_create': 1,
'module': 'Setup',
'name': '__common__',
'search_fields': 'name,parent_customer_group',
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 33
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Customer Group',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# These values are common for all DocPerm
{
'amend': 0,
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Customer Group',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1,
'submit': 0
},
# DocType, Customer Group
{
'doctype': 'DocType',
'name': 'Customer Group'
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 1,
'role': 'Sales Manager',
'write': 0
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 0,
'role': 'Sales Manager',
'write': 0
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 1,
'role': 'Sales Master Manager',
'write': 0
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 4,
'permlevel': 1,
'role': 'Sales User',
'write': 0
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 5,
'permlevel': 0,
'role': 'Sales User',
'write': 0
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 6,
'permlevel': 0,
'role': 'Sales Master Manager',
'write': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 1,
'label': 'Trash Reason',
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'customer_group_name',
'fieldtype': 'Data',
'idx': 2,
'label': 'Customer Group Name',
'no_copy': 1,
'oldfieldname': 'customer_group_name',
'oldfieldtype': 'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'description',
'fieldtype': 'Text',
'idx': 3,
'label': 'Description',
'oldfieldname': 'description',
'oldfieldtype': 'Text',
'permlevel': 0,
'width': '300px'
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'parent_customer_group',
'fieldtype': 'Link',
'idx': 4,
'label': 'Parent Customer Group',
'oldfieldname': 'parent_customer_group',
'oldfieldtype': 'Link',
'options': 'Customer Group',
'permlevel': 0,
'reqd': 1,
'trigger': 'Client'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Only leaf nodes are allowed in transaction',
'doctype': 'DocField',
'fieldname': 'is_group',
'fieldtype': 'Select',
'idx': 5,
'label': 'Has Child Node',
'oldfieldname': 'is_group',
'oldfieldtype': 'Select',
'options': '\nYes\nNo',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'lft',
'fieldtype': 'Int',
'hidden': 1,
'idx': 6,
'label': 'lft',
'no_copy': 1,
'oldfieldname': 'lft',
'oldfieldtype': 'Int',
'permlevel': 0,
'print_hide': 1,
'report_hide': 1,
'search_index': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'rgt',
'fieldtype': 'Int',
'hidden': 1,
'idx': 7,
'label': 'rgt',
'no_copy': 1,
'oldfieldname': 'rgt',
'oldfieldtype': 'Int',
'permlevel': 0,
'print_hide': 1,
'report_hide': 1,
'search_index': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'old_parent',
'fieldtype': 'Data',
'hidden': 1,
'idx': 8,
'label': 'old_parent',
'no_copy': 1,
'oldfieldname': 'old_parent',
'oldfieldtype': 'Data',
'permlevel': 0,
'print_hide': 1,
'report_hide': 1
}
]

View File

@@ -1,101 +0,0 @@
content_items = ['Sales','Expenses','Bank Balance','Activity']
# make a grid with items and columns of checkboxes
# Parameters:
# parent
# label (main heading)
# items = [] (rows)
# columns = [] (columns of checks)
# widths
# description
class CheckGrid
constructor: (@args) ->
$.extend @, args
@wrapper = $a @parent, 'div', 'check-grid round'
@render()
render: ->
$a @wrapper, 'h3', 'check-grid-title', null, @label
if @description
$a @wrapper, 'div', 'help-box', null, @description
@tab = make_table @wrapper, @items.length + 1, @columns.length, '100%', @widths
@checks = {}
# render heads
for i in [0..@columns.length-1]
$($td(@tab, 0, i))
.addClass('check-grid-head gradient')
.html @columns[i]
@render_rows()
render_rows: ->
# render rows
for i in [0..@items.length-1]
$td(@tab, i+1, 0).innerHTML = @items[i]
# render checkboxes for this row
@checks[@items[i]] = {}
for c in [1..@columns.length-1]
check = $a_input $td(@tab, i+1, c), 'checkbox'
# tag keys to checkbox
check.item = @items[i]
check.column = @columns[c]
# add in my checks
@checks[@items[i]][@columns[c]] = check
# get the values of the checkbox in a double dict
get: =>
val = {}
for item in keys @checks
for column in keys @checks[item]
check = @checks[item][column]
val[check.item] or= {}
val[check.item][check.column] = if check.checked then 1 else 0
val
# set the values of the grid
set: (val) =>
for item in keys @checks
for column in keys @checks[item]
if val[item][column]
@checks[item][column] .checked = val[item][column]
return
# attach it to onload
cx = cur_frm.cscript
cx.onload = (doc, dt, dn) ->
# make the content grid
cx.content_grid = new CheckGrid
parent: cur_frm.fields_dict.Body.wrapper
label: 'Email Settings'
items: content_items
columns: ['Item','Daily','Weekly']
widths: ['60%', '20%', '20%']
description: 'Select items to be compiled for Email Digest'
# make the email grid
cx.email_grid = new CheckGrid
parent: cur_frm.fields_dict.Body.wrapper
label: 'Send To'
items: ['test1@erpnext', 'test2@erpnext']
columns: ['Email','Daily','Weekly']
widths: ['60%', '20%', '20%']
description: 'Select who gets daily and weekly mails'
cx.content_grid.set JSON.parse doc.content_config if doc.content_config
cx.email_grid.set JSON.parse doc.email_config if doc.email_config
return
# update the data before sending
cx.validate = (doc, dt, dn) ->
doc.content_config = JSON.stringify cx.content_grid.get()
doc.email_config = JSON.stringify cx.email_grid.get()

View File

@@ -1,18 +0,0 @@
div.check-grid {
margin: 17px;
}
div.check-grid table {
border-collapse: collapse;
}
div.check-grid table td {
padding: 3px;
border: 1px solid #aaa;
}
td.check-grid-head {
font-weight: bold;
text-align: center;
}

View File

@@ -1,108 +0,0 @@
(function() {
var CheckGrid, content_items, cx;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
content_items = ['Sales', 'Expenses', 'Bank Balance', 'Activity'];
CheckGrid = (function() {
function CheckGrid(args) {
this.args = args;
this.set = __bind(this.set, this);
this.get = __bind(this.get, this);
$.extend(this, args);
this.wrapper = $a(this.parent, 'div', 'check-grid round');
this.render();
}
CheckGrid.prototype.render = function() {
var i, _ref;
$a(this.wrapper, 'h3', 'check-grid-title', null, this.label);
if (this.description) {
$a(this.wrapper, 'div', 'help-box', null, this.description);
}
this.tab = make_table(this.wrapper, this.items.length + 1, this.columns.length, '100%', this.widths);
this.checks = {};
for (i = 0, _ref = this.columns.length - 1; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) {
$($td(this.tab, 0, i)).addClass('check-grid-head gradient').html(this.columns[i]);
}
return this.render_rows();
};
CheckGrid.prototype.render_rows = function() {
var c, check, i, _ref, _results;
_results = [];
for (i = 0, _ref = this.items.length - 1; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) {
$td(this.tab, i + 1, 0).innerHTML = this.items[i];
this.checks[this.items[i]] = {};
_results.push((function() {
var _ref2, _results2;
_results2 = [];
for (c = 1, _ref2 = this.columns.length - 1; 1 <= _ref2 ? c <= _ref2 : c >= _ref2; 1 <= _ref2 ? c++ : c--) {
check = $a_input($td(this.tab, i + 1, c), 'checkbox');
check.item = this.items[i];
check.column = this.columns[c];
_results2.push(this.checks[this.items[i]][this.columns[c]] = check);
}
return _results2;
}).call(this));
}
return _results;
};
CheckGrid.prototype.get = function() {
var check, column, item, val, _i, _j, _len, _len2, _name, _ref, _ref2;
val = {};
_ref = keys(this.checks);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
item = _ref[_i];
_ref2 = keys(this.checks[item]);
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
column = _ref2[_j];
check = this.checks[item][column];
val[_name = check.item] || (val[_name] = {});
val[check.item][check.column] = check.checked ? 1 : 0;
}
}
return val;
};
CheckGrid.prototype.set = function(val) {
var column, item, _i, _j, _len, _len2, _ref, _ref2;
_ref = keys(this.checks);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
item = _ref[_i];
_ref2 = keys(this.checks[item]);
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
column = _ref2[_j];
if (val[item][column]) {
this.checks[item][column].checked = val[item][column];
}
}
}
};
return CheckGrid;
})();
cx = cur_frm.cscript;
cx.onload = function(doc, dt, dn) {
cx.content_grid = new CheckGrid({
parent: cur_frm.fields_dict.Body.wrapper,
label: 'Email Settings',
items: content_items,
columns: ['Item', 'Daily', 'Weekly'],
widths: ['60%', '20%', '20%'],
description: 'Select items to be compiled for Email Digest'
});
cx.email_grid = new CheckGrid({
parent: cur_frm.fields_dict.Body.wrapper,
label: 'Send To',
items: ['test1@erpnext', 'test2@erpnext'],
columns: ['Email', 'Daily', 'Weekly'],
widths: ['60%', '20%', '20%'],
description: 'Select who gets daily and weekly mails'
});
if (doc.content_config) {
cx.content_grid.set(JSON.parse(doc.content_config));
}
if (doc.email_config) {
cx.email_grid.set(JSON.parse(doc.email_config));
}
};
cx.validate = function(doc, dt, dn) {
doc.content_config = JSON.stringify(cx.content_grid.get());
return doc.email_config = JSON.stringify(cx.email_grid.get());
};
}).call(this);

View File

@@ -1,89 +0,0 @@
# DocType, Email Digest
[
# These values are common in all dictionaries
{
'creation': '2011-07-27 14:23:09',
'docstatus': 0,
'modified': '2011-07-27 17:32:27',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1311760331',
'colour': 'White:FFF',
'doctype': 'DocType',
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'section_style': 'Simple',
'show_in_menu': 0,
'version': 4
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Email Digest',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'idx': 1,
'name': '__common__',
'parent': 'Email Digest',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'Administrator',
'write': 1
},
# DocType, Email Digest
{
'doctype': 'DocType',
'name': 'Email Digest'
},
# DocPerm
{
'doctype': 'DocPerm'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'HTML',
'idx': 1,
'label': 'Body'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'content_config',
'fieldtype': 'Text',
'hidden': 1,
'idx': 2,
'label': 'Content Config'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'email_config',
'fieldtype': 'Text',
'hidden': 1,
'idx': 3,
'label': 'Email Config'
}
]

View File

@@ -1,5 +0,0 @@
cur_frm.cscript.refresh = function(doc,cdt,cdn){
if(!doc.outgoing_mail_server || !doc.mail_login || !doc.mail_password || !doc.auto_email_id || !doc.mail_port || !doc.use_ssl){
get_server_fields('set_vals','','',doc, cdt, cdn, 1);
}
}

View File

@@ -1,42 +0,0 @@
import webnotes
sql = webnotes.conn.sql
from webnotes.utils import cint, cstr
class DocType:
def __init__(self,doc,doclist):
self.doc,self.doclist = doc,doclist
def set_vals(self):
res = sql("select field, value from `tabSingles` where doctype = 'Control Panel' and field IN ('outgoing_mail_server','mail_login','mail_password','auto_email_id','mail_port','use_ssl')")
ret = {}
for r in res:
ret[cstr(r[0])]=r[1] and cstr(r[1]) or ''
return ret
def set_cp_value(self, key):
"""
Update value in control panel
"""
if self.doc.fields.get(key):
webnotes.conn.set_value('Control Panel', None, key, self.doc.fields[key])
def on_update(self):
"""
Sets or cancels the event in the scheduler
"""
# update control panel
for f in ('outgoing_mail_server', 'mail_login', 'mail_password', 'auto_email_id', 'mail_port', 'use_ssl'):
self.set_cp_value(f)
# setup scheduler for support emails
if cint(self.doc.sync_support_mails):
if not (self.doc.support_host and self.doc.support_username and self.doc.support_password):
webnotes.msgprint("You must give the incoming POP3 settings for support emails to activiate mailbox integration", raise_exception=1)
from webnotes.utils.scheduler import set_event
set_event('support.doctype.support_ticket.get_support_mails', 60*5, 1)
else:
from webnotes.utils.scheduler import cancel_event
cancel_event('support.doctype.support_ticket.get_support_mails')

View File

@@ -1,257 +0,0 @@
# DocType, Email Settings
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:08:59',
'docstatus': 0,
'modified': '2011-07-25 15:03:51',
'modified_by': 'Administrator',
'owner': 'harshada@webnotestech.com'
},
# These values are common for all DocType
{
'_last_update': '1311586371',
'allow_copy': 1,
'allow_email': 1,
'allow_print': 1,
'colour': 'White:FFF',
'doctype': 'DocType',
'in_create': 1,
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'section_style': 'Simple',
'server_code_error': ' ',
'version': 34
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Email Settings',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Email Settings',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'System Manager',
'write': 1
},
# DocType, Email Settings
{
'doctype': 'DocType',
'name': 'Email Settings'
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 2
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 1,
'label': 'Outgoing Mails'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'HTML',
'idx': 2,
'label': '1',
'options': '<div class="help_box">Set your outgoing mail settings here. All system generated notifications, emails will go from this mail server</div>'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'outgoing_mail_server',
'fieldtype': 'Data',
'idx': 3,
'label': 'Outgoing Mail Server'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'mail_port',
'fieldtype': 'Data',
'idx': 4,
'label': 'Mail Port'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'use_ssl',
'fieldtype': 'Check',
'idx': 5,
'label': 'Use SSL'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'mail_login',
'fieldtype': 'Data',
'idx': 6,
'label': 'Login Id'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'mail_password',
'fieldtype': 'Password',
'idx': 7,
'label': 'Mail Password'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'auto_email_id',
'fieldtype': 'Data',
'idx': 8,
'label': 'Auto Email Id'
},
# DocField
{
'description': 'Set the POP3 email settings to pull emails directly from a mailbox and create Support Tickets',
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 9,
'label': 'Support Ticket Mail Settings'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'HTML',
'idx': 10,
'label': '2',
'options': '<div class="help_box">To automatically create Support Tickets from your incoming mail, set your pop3 settings here.</div>'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 11,
'options': 'Simple'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Check this to pull emails from your mailbox',
'doctype': 'DocField',
'fieldname': 'sync_support_mails',
'fieldtype': 'Check',
'idx': 12,
'label': 'Sync Support Mails'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Your support email id - must be a valid email - this is where your emails will come!',
'doctype': 'DocField',
'fieldname': 'support_email',
'fieldtype': 'Data',
'idx': 13,
'label': 'Support Email'
},
# DocField
{
'colour': 'White:FFF',
'description': 'POP3 mail server (e.g. pop.gmail.com)',
'doctype': 'DocField',
'fieldname': 'support_host',
'fieldtype': 'Data',
'idx': 14,
'label': 'POP3 Mail Server'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'support_use_ssl',
'fieldtype': 'Check',
'idx': 15,
'label': 'Use SSL'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'support_username',
'fieldtype': 'Data',
'idx': 16,
'label': 'User Name'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'support_password',
'fieldtype': 'Password',
'idx': 17,
'label': 'Support Password'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 18
},
# DocField
{
'colour': 'White:FFF',
'description': 'Signature to be appended at the end of every email',
'doctype': 'DocField',
'fieldname': 'support_signature',
'fieldtype': 'Text',
'idx': 19,
'label': 'Signature'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Autoreply when a new mail is received',
'doctype': 'DocField',
'fieldname': 'support_autoreply',
'fieldtype': 'Text',
'idx': 20,
'label': 'Autoreply'
}
]

View File

@@ -1,13 +0,0 @@
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def validate(self):
"""
update settings in defaults
"""
from webnotes.model import default_fields
from webnotes.utils import set_default
for key in self.doc.fields:
if key not in default_fields:
set_default(key, self.doc.fields[key])

View File

@@ -1,288 +0,0 @@
# DocType, Features Setup
[
# These values are common in all dictionaries
{
'creation': '2011-08-25 16:53:56',
'docstatus': 0,
'modified': '2011-08-31 15:05:53',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1314783102',
'colour': 'White:FFF',
'doctype': 'DocType',
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'name_case': 'Title Case',
'section_style': 'Simple',
'show_in_menu': 1,
'version': 16
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Features Setup',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Features Setup',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'write': 1
},
# DocType, Features Setup
{
'doctype': 'DocType',
'name': 'Features Setup'
},
# DocPerm
{
'doctype': 'DocPerm',
'role': 'System Manager'
},
# DocPerm
{
'doctype': 'DocPerm',
'role': 'Administrator'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'label': 'Materials'
},
# DocField
{
'colour': 'White:FFF',
'description': 'To track item in sales and purchase documents based on their serial nos. This is can also used to track warranty details of the product.',
'doctype': 'DocField',
'fieldname': 'item_searial_nos',
'fieldtype': 'Check',
'label': 'Item Serial Nos'
},
# DocField
{
'colour': 'White:FFF',
'description': 'To track items in sales and purchase documents with batch nos<br><b>Preferred Industry: Chemicals etc</b>',
'doctype': 'DocField',
'fieldname': 'item_batch_nos',
'fieldtype': 'Check',
'label': 'Item Batch Nos'
},
# DocField
{
'colour': 'White:FFF',
'description': 'To track brand name in the following documents<br>\nDelivery Note, Enuiry, Indent, Item, Purchase Order, Purchase Voucher, Purchaser Receipt, Quotation, Receivable Voucher, Sales BOM, Sales Order, Serial No',
'doctype': 'DocField',
'fieldname': 'brands',
'fieldtype': 'Check',
'label': 'Brands'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break'
},
# DocField
{
'colour': 'White:FFF',
'description': '1. To maintain the customer wise item code and to make them searchable based on their code use this option',
'doctype': 'DocField',
'fieldname': 'item_advanced',
'fieldtype': 'Check',
'label': 'Item Advanced'
},
# DocField
{
'colour': 'White:FFF',
'description': 'If Sale BOM is defined, the actual BOM of the Pack is displayed as table.\nAvailable in Delivery Note and Sales Order',
'doctype': 'DocField',
'fieldname': 'packing_details',
'fieldtype': 'Check',
'label': 'Packing Detials'
},
# DocField
{
'colour': 'White:FFF',
'description': 'To get Item Group in details table',
'doctype': 'DocField',
'fieldname': 'item_group_in_details',
'fieldtype': 'Check',
'label': 'Item Groups in Details'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'label': 'Sales and Purchase'
},
# DocField
{
'colour': 'White:FFF',
'description': 'All export related fields like currency, conversion rate, export total, export grand total etc are available in <br>\nDelivery Note, POS, Quotation, Sales Invoice, Sales Order etc.',
'doctype': 'DocField',
'fieldname': 'exports',
'fieldtype': 'Check',
'label': 'Exports'
},
# DocField
{
'colour': 'White:FFF',
'description': 'All import related fields like currency, conversion rate, import total, import grand total etc are available in <br>\nPurchase Receipt, Supplier Quotation, Purchase Invoice, Purchase Order etc.',
'doctype': 'DocField',
'fieldname': 'imports',
'fieldtype': 'Check',
'label': 'Imports'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Field available in Delivery Note, Quotation, Receivable Voucher, Sales Order',
'doctype': 'DocField',
'fieldname': 'discounts',
'fieldtype': 'Check',
'label': 'Discounts'
},
# DocField
{
'colour': 'White:FFF',
'description': 'To track any installation or commissioning related work after sales',
'doctype': 'DocField',
'fieldname': 'after_sales_installations',
'fieldtype': 'Check',
'label': 'After Sale Installations'
},
# DocField
{
'description': 'Available in \nBill Of Materials, Delivery Note, Payable Voucher, Production Order, Purchase Order, Purchase Receipt, Receivable Voucher, Sales Order, Stock Entry, Timesheet',
'doctype': 'DocField',
'fieldname': 'projects',
'fieldtype': 'Check',
'label': 'Projects'
},
# DocField
{
'colour': 'White:FFF',
'description': 'If you have Sales Team and Sale Partners (Channel Partners) they can be tagged and maintain their contribution in the sales activity',
'doctype': 'DocField',
'fieldname': 'sales_extras',
'fieldtype': 'Check',
'label': 'Sales Extras'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'label': 'Production'
},
# DocField
{
'colour': 'White:FFF',
'description': 'If you involve in manufacturing activity<br>\nEnables item <b>Is Manufactured</b>',
'doctype': 'DocField',
'fieldname': 'manufacturing',
'fieldtype': 'Check',
'label': 'Manufacturing'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break'
},
# DocField
{
'colour': 'White:FFF',
'description': 'If you follow Quality Inspection<br>\nEnables item QA Required and QA No in Purchase Receipt',
'doctype': 'DocField',
'fieldname': 'quality',
'fieldtype': 'Check',
'label': 'Quality'
},
# DocField
{
'colour': 'White:FFF',
'description': 'To enable <b>Point of Sale</b> features',
'doctype': 'DocField',
'fieldname': 'pos',
'fieldtype': 'Check',
'label': 'Point of Sale'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'label': 'Miscelleneous'
},
# DocField
{
'colour': 'White:FFF',
'description': 'If you have long print formats, this feature can be used to split the page to be printed on multiple pages with all headers and footers on each page',
'doctype': 'DocField',
'fieldname': 'page_break',
'fieldtype': 'Check',
'label': 'Page Break'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Enables <b>More Info.</b> in all documents',
'doctype': 'DocField',
'fieldname': 'more_info',
'fieldtype': 'Check',
'label': 'More Info'
}
]

View File

@@ -1,34 +0,0 @@
# 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_master_lst(self):
return [r[0] for r in sql("select name from `tabDocType` where document_type = 'Master'")]
def get_child_lst(self,nm):
res = [nm]
ret=sql("select options from `tabDocField` where parent='%s' and fieldtype = 'Table'"%nm)
for r in ret:
res.append(r[0])
return res

View File

@@ -1,30 +0,0 @@
# DocType, Import Data Control
[
# These values are common in all dictionaries
{
'creation': '2010-10-04 16:30:30',
'docstatus': 0,
'modified': '2010-12-24 11:43:03',
'modified_by': 'abhishek@webnotestech.com',
'owner': 'harshada@webnotestech.com'
},
# These values are common for all DocType
{
'colour': 'White:FFF',
'doctype': 'DocType',
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'section_style': 'Simple',
'server_code_error': ' ',
'version': 12
},
# DocType, Import Data Control
{
'doctype': 'DocType',
'name': 'Import Data Control'
}
]

View File

@@ -1,18 +0,0 @@
cur_frm.cscript.onload = function(){
if(doc.__islocal){
doc.parent_item_group = 'Root';
refresh('parent_item_group');
}
}
//get query select item group
cur_frm.fields_dict['parent_item_group'].get_query = function(doc,cdt,cdn) {
return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.`is_group` = "Yes" AND `tabItem Group`.`docstatus`!= 2 AND (`tabItem Group`.`rgt` > '+doc.rgt+' or `tabItem Group`.`lft` < '+doc.lft+') AND `tabItem Group`.`name` !="'+doc.item_group_name+'" AND `tabItem Group`.%(key)s LIKE "%s" ORDER BY `tabItem Group`.`name` ASC LIMIT 50';
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}

View File

@@ -1,47 +0,0 @@
# 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.nsm_parent_field = 'parent_item_group';
# update Node Set Model
def update_nsm_model(self):
import webnotes
import webnotes.utils.nestedset
webnotes.utils.nestedset.update_nsm(self)
# ON UPDATE
#--------------------------------------
def on_update(self):
# update nsm
self.update_nsm_model()
def validate(self):
if self.doc.lft and self.doc.rgt:
res = sql("select name from `tabItem Group` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(self.doc.rgt,self.doc.lft,self.doc.parent_item_group,self.doc.item_group_name))
if not res:
msgprint("Please enter proper parent item group.")
raise Exception
r = sql("select name from `tabItem Group` where name = '%s' and docstatus = 2"%(self.doc.item_group_name))
if r:
msgprint("'%s' record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.item_group_name))
raise Exception

View File

@@ -1,262 +0,0 @@
# DocType, Item Group
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:06',
'docstatus': 0,
'modified': '2010-12-24 11:58:29',
'modified_by': 'abhishek@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'allow_trash': 1,
'autoname': 'field:item_group_name',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'in_create': 1,
'issingle': 0,
'module': 'Setup',
'name': '__common__',
'search_fields': 'parent_item_group',
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 54
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Item Group',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Item Group',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1
},
# DocType, Item Group
{
'doctype': 'DocType',
'name': 'Item Group'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 1,
'role': 'Material Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 0,
'role': 'Material Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 1,
'role': 'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 4,
'permlevel': 0,
'role': 'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 5,
'permlevel': 0,
'role': 'System Manager',
'write': 1
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 6,
'permlevel': 0,
'role': 'Material Master Manager',
'write': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 1,
'label': 'Trash Reason',
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'item_group_name',
'fieldtype': 'Data',
'idx': 2,
'label': 'Item Group Name',
'oldfieldname': 'item_group_name',
'oldfieldtype': 'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'show_in_catalogue',
'fieldtype': 'Check',
'idx': 3,
'label': 'Show in catalogue',
'oldfieldname': 'show_in_catalogue',
'oldfieldtype': 'Check',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'description',
'fieldtype': 'Text',
'idx': 4,
'label': 'Description',
'oldfieldname': 'description',
'oldfieldtype': 'Text',
'permlevel': 0,
'width': '300px'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'parent_item_group',
'fieldtype': 'Link',
'idx': 5,
'label': 'Parent Item Group',
'oldfieldname': 'parent_item_group',
'oldfieldtype': 'Link',
'options': 'Item Group',
'permlevel': 0,
'reqd': 1,
'trigger': 'Client'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Only leaf nodes are allowed in transaction',
'doctype': 'DocField',
'fieldname': 'is_group',
'fieldtype': 'Select',
'idx': 6,
'label': 'Has Child Node',
'oldfieldname': 'is_group',
'oldfieldtype': 'Select',
'options': '\nYes\nNo',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'lft',
'fieldtype': 'Int',
'hidden': 1,
'idx': 7,
'in_filter': 1,
'label': 'lft',
'no_copy': 1,
'oldfieldname': 'lft',
'oldfieldtype': 'Int',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'search_index': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'rgt',
'fieldtype': 'Int',
'hidden': 1,
'idx': 8,
'in_filter': 1,
'label': 'rgt',
'no_copy': 1,
'oldfieldname': 'rgt',
'oldfieldtype': 'Int',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'search_index': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'old_parent',
'fieldtype': 'Data',
'hidden': 1,
'idx': 9,
'label': 'old_parent',
'no_copy': 1,
'oldfieldname': 'old_parent',
'oldfieldtype': 'Data',
'permlevel': 0,
'print_hide': 1,
'report_hide': 1
}
]

View File

@@ -1,6 +0,0 @@
// Validate
cur_frm.cscript.validate = function(doc, cdt, cdn) {
$c_obj(make_doclist(cdt, cdn), 'update_cp', '', function(r, rt){
sys_defaults = r.message;
});
}

View File

@@ -1,65 +0,0 @@
# Please edit this list and import only required elements
import webnotes
from webnotes.utils import cint, cstr, get_defaults, set_default, fmt_money, get_last_day, get_first_day
from webnotes import session, form, is_testing, msgprint, errprint
sql = webnotes.conn.sql
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
#---------------------------------------------------------------------------------------------------------------------------------------------
def get_bal(self,arg):
bal = sql("select `tabAccount Balance`.balance,`tabAccount`.debit_or_credit from `tabAccount`,`tabAccount Balance` where `tabAccount Balance`.account=%s and `tabAccount Balance`.period=%s and `tabAccount Balance`.account=`tabAccount`.name ",(arg,self.doc.current_fiscal_year))
if bal:
return fmt_money(flt(bal[0][0])) + ' ' + bal[0][1]
# =========================================================================================================================================
# Update Default
# ---------------
def set_system_default(self, defkey, defvalue):
set_default(defkey, defvalue)
if defkey == 'fiscal_year':
ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", defvalue)
ysd = ysd and ysd[0][0] or ''
if ysd:
set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
set_default('year_end_date', get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
# Update
# --------
def update_cp(self):
def_list = [['fiscal_year',self.doc.current_fiscal_year],
['company',self.doc.default_company],
['currency',self.doc.default_currency],
['price_list_name',self.doc.default_price_list],
['item_group',self.doc.default_item_group],
['customer_group',self.doc.default_customer_group],
['cust_master_name',self.doc.cust_master_name],
['supplier_type',self.doc.default_supplier_type],
['supp_master_name',self.doc.supp_master_name],
['territory',self.doc.default_territory],
['stock_uom',self.doc.default_stock_uom],
['fraction_currency',self.doc.default_currency_fraction],
['valuation_method',self.doc.default_valuation_method]]
for d in def_list:
self.set_system_default(d[0],d[1])
# Update Currency Format
sql("update `tabSingles` set value = '%s' where field = 'currency_format' and doctype = 'Control Panel'" % self.doc.default_currency_format)
sql("update `tabSingles` set value = '%s' where field = 'date_format' and doctype = 'Control Panel'" %self.doc.date_format)
return get_defaults()

View File

@@ -1,526 +0,0 @@
# DocType, Manage Account
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:09',
'docstatus': 0,
'modified': '2011-05-19 11:16:11',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1308741898',
'allow_copy': 1,
'allow_email': 1,
'allow_print': 1,
'colour': 'White:FFF',
'doctype': 'DocType',
'hide_toolbar': 0,
'in_create': 1,
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'read_only': 1,
'section_style': 'Tabbed',
'server_code_error': ' ',
'show_in_menu': 1,
'version': 514
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Manage Account',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Manage Account',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1
},
# DocType, Manage Account
{
'doctype': 'DocType',
'name': 'Manage Account'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 1,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 0,
'role': 'System Manager',
'submit': 0,
'write': 1
},
# DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 0,
'role': 'System Manager',
'write': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 1,
'role': 'System Manager',
'write': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 4,
'permlevel': 1,
'role': 'All'
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 5,
'permlevel': 2,
'role': 'System Manager',
'write': 1
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 1,
'label': 'Company'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_company',
'fieldtype': 'Link',
'idx': 2,
'label': 'Default Company',
'options': 'Company',
'reqd': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'current_fiscal_year',
'fieldtype': 'Link',
'idx': 3,
'label': 'Current Fiscal Year',
'options': 'Fiscal Year',
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'date_format',
'fieldtype': 'Select',
'idx': 4,
'label': 'Date Format',
'options': 'yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 5,
'width': '50%'
},
# DocField
{
'default': 'INR',
'doctype': 'DocField',
'fieldname': 'default_currency',
'fieldtype': 'Select',
'idx': 6,
'label': 'Default Currency',
'options': 'link:Currency',
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_currency_format',
'fieldtype': 'Select',
'idx': 7,
'label': 'Default Currency Format',
'options': 'Lacs\nMillions'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_currency_fraction',
'fieldtype': 'Data',
'idx': 8,
'label': 'Default Currency Fraction'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'sms_sender_name',
'fieldtype': 'Data',
'idx': 9,
'label': 'SMS Sender Name'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 10,
'label': 'Stock'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 11,
'width': '50%'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_item_group',
'fieldtype': 'Link',
'idx': 12,
'label': 'Default Item Group',
'options': 'Item Group'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'HTML',
'idx': 13,
'label': 'IGHelp',
'options': '<a href="javascript:cur_frm.cscript.TreePage(\'Item Group\');">To manage Item Groups, click here</a>'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_stock_uom',
'fieldtype': 'Link',
'idx': 14,
'label': 'Default Stock UOM',
'options': 'UOM'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_valuation_method',
'fieldtype': 'Select',
'idx': 15,
'label': 'Default Valuation Method',
'options': 'FIFO\nMoving Average'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_warehouse_type',
'fieldtype': 'Link',
'idx': 16,
'label': 'Default Warehouse Type',
'options': 'Warehouse Type'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 17,
'width': '50%'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Percentage you are allowed to receive or deliver more against the quantity ordered. <p>For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units</p>',
'doctype': 'DocField',
'fieldname': 'tolerance',
'fieldtype': 'Currency',
'idx': 18,
'label': 'Allowance Percent'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Stock level frozen up to this date, nobody can do / modify entry except authorized person',
'doctype': 'DocField',
'fieldname': 'stock_frozen_upto',
'fieldtype': 'Date',
'idx': 19,
'label': 'Stock Frozen Upto'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Users with this role are allowed to do / modify stock entry before frozen date',
'doctype': 'DocField',
'fieldname': 'stock_auth_role',
'fieldtype': 'Link',
'idx': 20,
'label': 'Authorized Role (Frozen Entry)',
'options': 'Role'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 21,
'label': 'Accounts'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Accounting entry frozen up to this date, nobody can do / modify entry except authorized person',
'doctype': 'DocField',
'fieldname': 'acc_frozen_upto',
'fieldtype': 'Date',
'idx': 22,
'label': 'Accounts Frozen Upto'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Users with this role are allowed to do / modify accounting entry before frozen date',
'doctype': 'DocField',
'fieldname': 'bde_auth_role',
'fieldtype': 'Link',
'idx': 23,
'label': 'Authourized Role (Frozen Entry)',
'options': 'Role'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'credit_controller',
'fieldtype': 'Link',
'idx': 24,
'label': 'Credit Controller',
'options': 'Role'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 25,
'label': 'Selling'
},
# DocField
{
'colour': 'White:FFF',
'default': 'Customer Name',
'doctype': 'DocField',
'fieldname': 'cust_master_name',
'fieldtype': 'Select',
'idx': 26,
'label': 'Customer Master created by ',
'options': 'Customer Name\nNaming Series'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_customer_group',
'fieldtype': 'Link',
'idx': 27,
'label': 'Default Customer Group',
'options': 'Customer Group'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'HTML',
'idx': 28,
'label': 'CGHelp',
'options': '<a href="javascript:cur_frm.cscript.TreePage(\'Customer Group\');">To manage Customer Groups, click here</a>'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_territory',
'fieldtype': 'Link',
'idx': 29,
'label': 'Default Territory',
'options': 'Territory'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'HTML',
'idx': 30,
'label': 'TerritoryHelp',
'options': '<a href="javascript:cur_frm.cscript.TreePage(\'Territory\');">To manage Territory, click here</a>'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_price_list',
'fieldtype': 'Link',
'idx': 31,
'label': 'Default Price List',
'options': 'Price List'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 32,
'width': '50%'
},
# DocField
{
'colour': 'White:FFF',
'default': 'No',
'doctype': 'DocField',
'fieldname': 'so_required',
'fieldtype': 'Select',
'idx': 33,
'label': 'Sales Order Required',
'options': 'No\nYes'
},
# DocField
{
'colour': 'White:FFF',
'default': 'No',
'doctype': 'DocField',
'fieldname': 'dn_required',
'fieldtype': 'Select',
'idx': 34,
'label': 'Delivery Note Required',
'options': 'No\nYes'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 35,
'label': 'Buying'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'default_supplier_type',
'fieldtype': 'Link',
'idx': 36,
'label': 'Default Supplier Type',
'options': 'Supplier Type'
},
# DocField
{
'colour': 'White:FFF',
'default': 'Supplier Name',
'doctype': 'DocField',
'fieldname': 'supp_master_name',
'fieldtype': 'Select',
'idx': 37,
'label': 'Supplier Master created by ',
'options': 'Supplier Name\nNaming Series'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 38,
'width': '50%'
},
# DocField
{
'colour': 'White:FFF',
'default': 'No',
'doctype': 'DocField',
'fieldname': 'po_required',
'fieldtype': 'Select',
'idx': 39,
'label': 'Purchase Order Required',
'options': 'No\nYes'
},
# DocField
{
'colour': 'White:FFF',
'default': 'No',
'doctype': 'DocField',
'fieldname': 'pr_required',
'fieldtype': 'Select',
'idx': 40,
'label': 'Purchase Receipt Required',
'options': 'No\nYes'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 41,
'label': 'HR',
'options': '<div style="padding-top: 8px;" class="columnHeading">HR</div>'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Employee record is created using selected field. ',
'doctype': 'DocField',
'fieldname': 'emp_created_by',
'fieldtype': 'Select',
'idx': 42,
'label': 'Employee Records to be created by ',
'options': '\nNaming Series\nEmployee Number'
}
]

View File

@@ -1,80 +0,0 @@
# DocType, Market Segment
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:10',
'docstatus': 0,
'modified': '2010-09-20 14:06:57',
'modified_by': 'yogesh@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'allow_trash': 1,
'autoname': 'field:segment_name',
'colour': 'White:FFF',
'doctype': 'DocType',
'in_create': 1,
'module': 'Setup',
'name': '__common__',
'name_case': 'Title Case',
'read_only': 0,
'section_style': 'Simple',
'show_in_menu': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Market Segment',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# DocType, Market Segment
{
'doctype': 'DocType',
'name': 'Market Segment'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 1,
'label': 'Trash Reason',
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'segment_name',
'fieldtype': 'Data',
'idx': 2,
'label': 'Segment Name',
'oldfieldname': 'segment_name',
'oldfieldtype': 'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'details',
'fieldtype': 'Text',
'idx': 3,
'label': 'Details',
'oldfieldname': 'details',
'oldfieldtype': 'Text',
'permlevel': 0
}
]

View File

@@ -1,19 +0,0 @@
// Settings
cur_frm.cscript.onload = function(doc, cdt, cdn){
var callback = function(r, rt){
set_field_options('select_doc_for_series', r.message);
}
$c_obj([doc],'get_transactions','',callback);
// add page head
var ph = new PageHeader(cur_frm.fields_dict['Head HTML'].wrapper, 'Setup Series', 'Set prefix for numbering series on your transactions');
}
cur_frm.cscript.select_doc_for_series = function(doc, cdt, cdn) {
var callback = function(r, rt){
locals[cdt][cdn].set_options = r.message;
refresh_field('set_options');
}
$c_obj([doc],'get_options','',callback)
}

View File

@@ -1,90 +0,0 @@
# Please edit this list and import only required elements
import webnotes
from webnotes.utils import cint, cstr
from webnotes import msgprint, errprint
sql = webnotes.conn.sql
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
#-----------------------------------------------------------------------------------------------------------------------------------
def get_transactions(self):
return "\n".join([''] + [i[0] for i in sql("SELECT `tabDocField`.`parent` FROM `tabDocField`, `tabDocType` WHERE `tabDocField`.`fieldname` = 'naming_series' and `tabDocType`.module !='Recycle Bin' and `tabDocType`.name=`tabDocField`.parent order by `tabDocField`.parent")])
#-----------------------------------------------------------------------------------------------------------------------------------
def get_options_for(self, doctype):
sr = sql("select options from `tabDocField` where parent='%s' and fieldname='naming_series'" % (doctype))
if sr and sr[0][0]:
return sr[0][0].split("\n")
else:
return []
def scrub_options_list(self, ol):
options = filter(lambda x: x, [cstr(n.upper()).strip() for n in ol])
return options
#-----------------------------------------------------------------------------------------------------------------------------------
def set_series_for(self, doctype, ol):
options = self.scrub_options_list(ol)
# validate names
[self.validate_series_name(i) for i in options]
if self.doc.user_must_always_select:
options = [''] + options
default = ''
else:
default = options[0]
# update
sql("update tabDocField set `options`=%s, `default`=%s where parent=%s and fieldname='naming_series'", ("\n".join(options), default, doctype))
self.doc.set_options = "\n".join(options)
#-----------------------------------------------------------------------------------------------------------------------------------
def update_series(self):
self.check_duplicate()
self.set_series_for(self.doc.select_doc_for_series, self.doc.set_options.split("\n"))
msgprint('Series Updated')
#-----------------------------------------------------------------------------------------------------------------------------------
def check_duplicate(self):
from core.doctype.doctype.doctype import DocType
dt = DocType()
sr = sql("select options, parent from `tabDocField` where fieldname='naming_series' and parent != %s", self.doc.select_doc_for_series)
options = self.scrub_options_list(self.doc.set_options.split("\n"))
for series in options:
dt.validate_series(series, self.doc.select_doc_for_series)
for i in sr:
if i[0]:
if series in i[0].split("\n"):
msgprint("Oops! Series name %s is already in use in %s. Please select a new one" % (series, i[1]), raise_exception=1)
#-----------------------------------------------------------------------------------------------------------------------------------
def validate_series_name(self, n):
import re
if not re.match('[a-zA-Z0-9]+(([-/][a-zA-Z0-9])?[-/][a-zA-Z0-9]*)*',n):
msgprint('Special Characters except "-" and "/" not allowed in naming series')
raise Exception
#-----------------------------------------------------------------------------------------------------------------------------------
def get_options(self, arg=''):
so = sql("select options from `tabDocField` where parent=%s and fieldname='naming_series'", self.doc.select_doc_for_series)
if so:
return so[0][0] or ''
#-----------------------------------------------------------------------------------------------------------------------------------
def update_series_start(self):
ser_det = sql("select name from `tabSeries` where name = %s", self.doc.prefix)
if ser_det:
sql("update `tabSeries` set current = '%s' where name = '%s'" % (self.doc.starts_from-1,self.doc.prefix))
else:
sql("insert into tabSeries (name, current) values (%s,%s)",(cstr(self.doc.prefix),cint(self.doc.starts_from)-1))
msgprint("Series Updated Successfully")

View File

@@ -1,206 +0,0 @@
# DocType, Naming Series
[
# These values are common in all dictionaries
{
'creation': '2010-10-27 14:29:55',
'docstatus': 0,
'modified': '2010-11-26 18:45:26',
'modified_by': 'sneha@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'colour': 'White:FFF',
'doctype': 'DocType',
'hide_heading': 1,
'hide_toolbar': 1,
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'read_only': 1,
'section_style': 'Tray',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 58
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Naming Series',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Naming Series',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1
},
# DocType, Naming Series
{
'doctype': 'DocType',
'name': 'Naming Series'
},
# DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 0,
'role': 'System Manager',
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 1,
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 0,
'role': 'System Manager',
'submit': 0,
'write': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 1,
'role': 'System Manager'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 4,
'permlevel': 1,
'role': 'System Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 5,
'permlevel': 0,
'role': 'Guest'
},
# DocField
{
'description': 'Set prefix for numbering series on your transactions',
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 1,
'label': 'Setup Series'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'HTML',
'idx': 2,
'label': 'Head HTML'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'select_doc_for_series',
'fieldtype': 'Select',
'idx': 3,
'label': 'Select Transaction'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'HTML',
'idx': 4,
'label': 'Help HTML',
'options': '<div style="padding: 8px; background-color: #FFD; margin: 8px 0px;">\nWrite the list of series options in the list below. Each on a new line<br>\nAllowed special characters are "/" and "-"<br>\nExamples:<br>\nINV-<br>\nINV-10-<br>\nINVK-<br>\n</div>'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'set_options',
'fieldtype': 'Text',
'idx': 5,
'label': 'Set Series'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Check this if you want to force the user to select a series before saving. There will be no default if you check this.',
'doctype': 'DocField',
'fieldname': 'user_must_always_select',
'fieldtype': 'Check',
'idx': 6,
'label': 'User must always select'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Button',
'idx': 7,
'label': 'Update',
'options': 'update_series'
},
# DocField
{
'description': 'Set starting number for series of your transactions',
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 8,
'label': 'Update Series'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'prefix',
'fieldtype': 'Data',
'idx': 9,
'label': 'Prefix'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'starts_from',
'fieldtype': 'Int',
'idx': 10,
'label': 'Starts From'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Button',
'idx': 11,
'label': 'Update Series Start',
'options': 'update_series_start'
}
]

View File

@@ -1,83 +0,0 @@
# DocType, Naming Series Options
[
# These values are common in all dictionaries
{
'creation': '2010-12-14 10:23:17',
'docstatus': 0,
'modified': '2010-09-20 14:06:57',
'modified_by': 'yogesh@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'autoname': '__NSO.#####',
'colour': 'White:FFF',
'doctype': 'DocType',
'in_create': 1,
'module': 'Setup',
'name': '__common__',
'read_only': 0,
'section_style': 'Simple',
'server_code_error': ' ',
'version': 4
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Naming Series Options',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'idx': 1,
'name': '__common__',
'parent': 'Naming Series Options',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'System Manager'
},
# DocType, Naming Series Options
{
'doctype': 'DocType',
'name': 'Naming Series Options'
},
# DocPerm
{
'doctype': 'DocPerm'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'doc_type',
'fieldtype': 'Data',
'idx': 1,
'label': 'Doc Type',
'oldfieldname': 'doc_type',
'oldfieldtype': 'Data',
'search_index': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'series_options',
'fieldtype': 'Text',
'idx': 2,
'label': 'Series Options',
'oldfieldname': 'series_options',
'oldfieldtype': 'Text'
}
]

View File

@@ -1,10 +0,0 @@
cur_frm.cscript.select_transaction = function(doc, dt, dn) {
if(doc.select_transaction) {
var callback = function(r,rt) {
var doc = locals[dt][dn];
doc.custom_message = r.message;
refresh_field('custom_message');
}
$c_obj('Notification Control','get_message',doc.select_transaction, callback)
}
}

View File

@@ -1,104 +0,0 @@
# Please edit this list and import only required elements
import webnotes
from webnotes.utils import validate_email_add, cint, cstr
from webnotes.model.doc import Document
from webnotes import msgprint
sql = webnotes.conn.sql
# -----------------------------------------------------------------------------------------
def get_formatted_message(head, body):
if head:
head = '<div style="font-size: 19px; margin-bottom: 13px; color: #333; font-family: Arial;">%s</div>' % head
else:
head = ''
return '''
<div style="margin: 13px">
%(head)s
<p style="font-size: 14px; line-height: 1.7em; color: #555; font-family: Arial;">
%(body)s
</p>
</div>
''' % {'head':head, 'body':body.replace('\n', '<br>')}
# Notification control
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
# get message to load in custom text
# ----------------------------------
def get_message(self, arg):
fn = arg.lower().replace(' ', '_') + '_message'
v = sql("select value from tabSingles where field=%s and doctype=%s", (fn, 'Notification Control'))
return v and v[0][0] or ''
# set custom text
# ---------------
def set_message(self, arg=''):
fn = self.doc.select_transaction.lower().replace(' ', '_') + '_message'
webnotes.conn.set(self.doc, fn, self.doc.custom_message)
msgprint("Custom Message for %s updated!" % self.doc.select_transaction)
# notify contact
# --------------
def notify_contact(self, key, dt, dn, contact_email, contact_nm):
if contact_email:
dt_small = dt.replace(' ','_').lower()
if cint(self.doc.fields.get(dt_small)):
self.send_notification(key, dt, dn, contact_email, contact_nm)
# send notification
def send_notification(self, key, dt, dn, contact_email, contact_nm):
import webnotes.utils.encrypt
import os
from webnotes.utils.email_lib import sendmail
cp = Document('Control Panel', 'Control Panel')
banner = cp.client_name
sender_nm = sql("select concat_ws(' ', first_name, last_name) from tabProfile where name = %s", webnotes.session['user'])[0][0] or ''
if contact_nm:
contact_nm = ' ' + contact_nm
else:
contact_nm = ''
msg = '''
<div style="margin-bottom: 13px;">%(company_banner)s</div>
Hi%(contact)s,
%(message)s
<a href="http://%(domain)s/v170/index.cgi?page=Form/%(dt)s/%(dn)s&ac_name=%(account)s&akey=%(akey)s">Click here to see the document.</a></p>
Thanks,
%(sent_by)s
%(company_name)s
''' % {
'company_banner': banner,
'contact': contact_nm,
'message': self.doc.fields[key.lower().replace(' ','_')+'_message'],
'sent_by': sender_nm,
'company_name':cp.company_name,
'dt': dt.replace(' ', '%20'),
'dn': dn.replace('/', '%2F'),
'domain': os.environ.get('HTTP_HOST'),
'account': cp.account_id,
'akey': webnotes.utils.encrypt.encrypt(dn)
}
if not validate_email_add(webnotes.session['user']):
sender = "automail@webnotestech.com"
else:
sender = webnotes.session['user']
rec_lst = [contact_email, sender]
subject = cp.company_name + ' - ' + dt
sendmail(rec_lst, sender, get_formatted_message(None, msg), subject)

View File

@@ -1,330 +0,0 @@
# DocType, Notification Control
[
# These values are common in all dictionaries
{
'creation': '2010-09-01 15:48:07',
'docstatus': 0,
'modified': '2010-10-14 10:48:02',
'modified_by': 'nabin@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'allow_copy': 1,
'allow_email': 1,
'allow_print': 1,
'colour': 'White:FFF',
'doctype': 'DocType',
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'section_style': 'Simple',
'server_code_error': ' ',
'version': 79
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Notification Control',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Notification Control',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1
},
# DocType, Notification Control
{
'doctype': 'DocType',
'name': 'Notification Control'
},
# DocPerm
{
'create': 0,
'doctype': 'DocPerm',
'idx': 1,
'role': 'Guest',
'write': 0
},
# DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'idx': 2,
'role': 'System Manager',
'write': 1
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 1,
'label': 'Send Auto-notification for'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 2,
'label': 'Sales',
'width': '50%'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'enquiry',
'fieldtype': 'Check',
'hidden': 1,
'idx': 3,
'label': 'Enquiry',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'quotation',
'fieldtype': 'Check',
'idx': 4,
'label': 'Quotation'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'sales_order',
'fieldtype': 'Check',
'idx': 5,
'label': 'Sales Order'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'delivery_note',
'fieldtype': 'Check',
'idx': 6,
'label': 'Delivery Note'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'receivable_voucher',
'fieldtype': 'Check',
'idx': 7,
'label': 'Sales Invoice'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 8,
'label': 'Purchase',
'width': '50%'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'purchase_order',
'fieldtype': 'Check',
'idx': 9,
'label': 'Purchase Order'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'purchase_receipt',
'fieldtype': 'Check',
'idx': 10,
'label': 'Purchase Receipt'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'payable_voucher',
'fieldtype': 'Check',
'idx': 11,
'label': 'Purchase Invoice',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'expense_voucher',
'fieldtype': 'Check',
'idx': 12,
'label': 'Expense Voucher'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 13,
'label': 'Customize the Notification'
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'select_transaction',
'fieldtype': 'Select',
'idx': 14,
'label': 'Select Transaction',
'options': '\nQuotation\nSales Order\nDelivery Note\nSales Invoice\nPayment Received\nPurchase Order\nPurchase Receipt\nPayment Sent',
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'custom_message',
'fieldtype': 'Text Editor',
'idx': 15,
'label': 'Custom Message'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Button',
'idx': 16,
'label': 'Update',
'options': 'set_message'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'quotation_message',
'fieldtype': 'Text',
'hidden': 1,
'idx': 17,
'label': 'Quotation Message',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'sales_order_message',
'fieldtype': 'Text',
'hidden': 1,
'idx': 18,
'label': 'Sales Order Message',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'delivery_note_message',
'fieldtype': 'Text',
'hidden': 1,
'idx': 19,
'label': 'Delivery Note Message',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'sales_invoice_message',
'fieldtype': 'Text',
'hidden': 1,
'idx': 20,
'label': 'Sales Invoice Message',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'payment_received_message',
'fieldtype': 'Text',
'hidden': 1,
'idx': 21,
'label': 'Payment Received Message',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'purchase_order_message',
'fieldtype': 'Text',
'hidden': 1,
'idx': 22,
'label': 'Purchase Order Message',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'purchase_receipt_message',
'fieldtype': 'Text',
'hidden': 1,
'idx': 23,
'label': 'Purchase Receipt Message',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'payment_sent_message',
'fieldtype': 'Text',
'hidden': 1,
'idx': 24,
'label': 'Payment Sent Message',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'expense_voucher_approved_message',
'fieldtype': 'Text',
'hidden': 1,
'idx': 25,
'label': 'Expense Voucher Approved Message',
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'expense_voucher_rejected_message',
'fieldtype': 'Text',
'hidden': 1,
'idx': 26,
'label': 'Expense Voucher Rejected Message',
'print_hide': 1
}
]

View File

@@ -1,10 +0,0 @@
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}

View File

@@ -1,97 +0,0 @@
# DocType, Order Lost Reason
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:10',
'docstatus': 0,
'modified': '2010-09-20 14:06:57',
'modified_by': 'yogesh@webnotestech.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'allow_trash': 1,
'autoname': 'field:order_lost_reason',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'module': 'Setup',
'name': '__common__',
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 4
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Order Lost Reason',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# These values are common for all DocPerm
{
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Order Lost Reason',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'write': 1
},
# DocType, Order Lost Reason
{
'doctype': 'DocType',
'name': 'Order Lost Reason'
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 1,
'role': 'System Manager'
},
# DocPerm
{
'amend': 0,
'doctype': 'DocPerm',
'idx': 2,
'role': 'Sales Master Manager',
'submit': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 1,
'label': 'Trash Reason',
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'order_lost_reason',
'fieldtype': 'Data',
'idx': 2,
'label': 'Order Lost Reason',
'oldfieldname': 'order_lost_reason',
'oldfieldtype': 'Data',
'permlevel': 0,
'reqd': 1
}
]

View File

@@ -1,139 +0,0 @@
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
//
}
/*cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}*/
// For customizing print
cur_frm.pformat.other_charges= function(doc){
//function to make row of table
var make_row = function(title,val,bold){
var bstart = '<b>'; var bend = '</b>';
return '<tr><td style="width:50%;">'+(bold?bstart:'')+title+(bold?bend:'')+'</td>'
+'<td style="width:25%;text-align:right;">'+doc.currency+'</td>'
+'<td style="width:25%;text-align:right;">'+val+'</td>'
+'</tr>'
}
function convert_rate(val){
var new_val = flt(val)/flt(doc.conversion_rate);
return new_val;
}
out ='';
if (!doc.print_without_amount) {
var cl = getchildren('RV Tax Detail',doc.name,'other_charges');
// outer table
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';
// main table
out +='<table class="noborder" style="width:100%">'+make_row('Net Total',fmt_money(convert_rate(doc.net_total)),1);
// add rows
if(cl.length){
for(var i=0;i<cl.length;i++){
if(fmt_money(convert_rate(cl[i].tax_amount))!=0)
out += make_row(cl[i].description,fmt_money(convert_rate(cl[i].tax_amount)),0);
}
}
// grand total
out +=make_row('Grand Total',fmt_money(doc.grand_total_export),1) +make_row('Rounded Total',fmt_money(doc.rounded_total_export),1)
if(doc.in_words_export){
out +='</table></td></tr>';
out += '<tr><td colspan = "2">';
out += '<table><tr><td style="width:25%;"><b>In Words</b></td>'
out+= '<td style="width:50%;">'+doc.in_words_export+'</td></tr>'
}
out +='</table></td></tr></table></div>';
}
return out;
}
cur_frm.cscript.charge_type = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.idx == 1 && (d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total')){
alert("You cannot select Charge Type as 'On Previous Row Amount' or 'On Previous Row Total' for first row");
d.charge_type = '';
}
validated = false;
refresh_field('charge_type',d.name,'other_charges');
cur_frm.cscript.row_id(doc, cdt, cdn);
cur_frm.cscript.rate(doc, cdt, cdn);
cur_frm.cscript.tax_amount(doc, cdt, cdn);
}
cur_frm.cscript.row_id = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.row_id){
alert("Please select Charge Type first");
d.row_id = '';
}
else if((d.charge_type == 'Actual' || d.charge_type == 'On Net Total') && d.row_id) {
alert("You can Enter Row only if your Charge Type is 'On Previous Row Amount' or ' Previous Row Total'");
d.row_id = '';
}
else if((d.charge_type == 'On Previous Row Amount' || d.charge_type == 'On Previous Row Total') && d.row_id){
if(d.row_id >= d.idx){
alert("You cannot Enter Row no. greater than or equal to current row no. for this Charge type");
d.row_id = '';
}
}
validated = false;
refresh_field('row_id',d.name,'other_charges');
}
/*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/
cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type = "Tax" OR tabAccount.account_type = "Chargeable") AND tabAccount.company = "'+doc.company+'" AND tabAccount.name LIKE "%s"'
}
//--------------------filter other charges master company-wise-----------------------------------------
/*
cur_frm.fields_dict.charge.get_query = function(doc) {
return 'SELECT DISTINCT `tabOther Charges`.name FROM `tabOther Charges` WHERE `tabOther Charges`.company = "'+doc.company+'" AND `tabOther Charges`.company is not NULL AND `tabOther Charges`.name LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';
}
*/
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.account_head){
alert("Please select Charge Type first");
validated = false;
d.account_head = '';
}
else if(d.account_head && d.charge_type) {
arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}";
get_server_fields('get_rate', arg, 'other_charges', doc, cdt, cdn, 1);
}
refresh_field('account_head',d.name,'other_charges');
}
cur_frm.cscript.rate = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.rate) {
alert("Please select Charge Type first");
d.rate = '';
}
validated = false;
refresh_field('rate',d.name,'other_charges');
}
cur_frm.cscript.tax_amount = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.tax_amount){
alert("Please select Charge Type first");
d.tax_amount = '';
}
else if(d.charge_type && d.tax_amount) {
alert("You cannot directly enter Amount and if your Charge Type is Actual enter your amount in Rate");
d.tax_amount = '';
}
validated = false;
refresh_field('tax_amount',d.name,'other_charges');
}

View File

@@ -1,34 +0,0 @@
# 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 Tax Rate if account type is Tax
# ===================================================================
def get_rate(self, arg):
get_obj('Sales Common').get_rate(arg, self)
def update_other_default_charges(self):
sql("update `tabOther Charges` set is_default = 0 where ifnull(is_default,0) = 1 and name != '%s' and company = '%s'" % (self.doc.name, self.doc.company))
def on_update(self):
self.update_other_default_charges()

View File

@@ -1,204 +0,0 @@
# DocType, Other Charges
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:11',
'docstatus': 0,
'modified': '2011-01-07 11:04:07',
'modified_by': 'rakesh@iwebnotes.com',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'allow_trash': 1,
'autoname': 'field:title',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'module': 'Setup',
'name': '__common__',
'section_style': 'Tabbed',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 56
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Other Charges',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Other Charges',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1
},
# DocType, Other Charges
{
'doctype': 'DocType',
'name': 'Other Charges'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 1,
'role': 'Sales Master Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 1,
'role': 'Sales User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 0,
'role': 'Sales User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 4,
'permlevel': 0,
'role': 'Accounts Manager',
'submit': 0,
'write': 1
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 5,
'permlevel': 0,
'role': 'System Manager',
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 6,
'permlevel': 0,
'role': 'Sales Master Manager',
'submit': 0,
'write': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 1,
'label': 'Trash Reason',
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 2,
'label': 'Other Charges Details',
'oldfieldtype': 'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'title',
'fieldtype': 'Data',
'idx': 3,
'in_filter': 1,
'label': 'Title',
'oldfieldname': 'title',
'oldfieldtype': 'Data',
'permlevel': 0,
'reqd': 1,
'search_index': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'is_default',
'fieldtype': 'Check',
'idx': 4,
'label': 'Default',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'company',
'fieldtype': 'Link',
'idx': 5,
'in_filter': 1,
'label': 'Company',
'oldfieldname': 'company',
'oldfieldtype': 'Link',
'options': 'Company',
'permlevel': 0,
'reqd': 1,
'search_index': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'other_charges',
'fieldtype': 'Table',
'idx': 6,
'label': 'Other Charges',
'oldfieldname': 'other_charges',
'oldfieldtype': 'Table',
'options': 'RV Tax Detail',
'permlevel': 0
}
]

View File

@@ -1,10 +0,0 @@
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}

View File

@@ -1,122 +0,0 @@
# DocType, Period
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:12',
'docstatus': 0,
'modified': '2010-09-20 14:06:57',
'modified_by': 'umair@iwebnotes.com',
'owner': 'nabin@webnotestech.com'
},
# These values are common for all DocType
{
'autoname': 'field:period_name',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'in_create': 1,
'module': 'Setup',
'name': '__common__',
'section_style': 'Simple',
'server_code_error': ' ',
'version': 5
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Period',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Period',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'System Manager',
'write': 0
},
# DocType, Period
{
'doctype': 'DocType',
'name': 'Period'
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 2
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'period_name',
'fieldtype': 'Data',
'idx': 1,
'label': 'Period Name',
'oldfieldname': 'period_name',
'oldfieldtype': 'Data'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'start_date',
'fieldtype': 'Date',
'idx': 2,
'label': 'Start Date',
'oldfieldname': 'start_date',
'oldfieldtype': 'Date'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'end_date',
'fieldtype': 'Date',
'idx': 3,
'label': 'End Date',
'oldfieldname': 'end_date',
'oldfieldtype': 'Date'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'period_type',
'fieldtype': 'Data',
'idx': 4,
'label': 'Period Type',
'oldfieldname': 'period_type',
'oldfieldtype': 'Data'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'fiscal_year',
'fieldtype': 'Data',
'idx': 5,
'label': 'Fiscal Year',
'oldfieldname': 'fiscal_year',
'oldfieldtype': 'Data'
}
]

View File

@@ -1,61 +0,0 @@
# 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
# Generate Periods
#------------------
def generate_periods(self, fy):
ml = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')
import webnotes.utils
from dateutil.relativedelta import relativedelta
if not sql("select name from `tabPeriod` where fiscal_year = '%s'" % fy):
ysd = sql("select year_start_date from `tabFiscal Year` where name = '%s'"%fy)[0][0]
#create period as fiscal year record name
#----------------------------------------------
arg = {'pn':fy,'sd':ysd,'ed':webnotes.utils.get_last_day(ysd + relativedelta(months=11)).strftime('%Y-%m-%d'),'pt':'Year','fy':fy}
self.create_period(arg)
for i in range(12):
msd = ysd + relativedelta(months=i)
arg = {'pn':ml[cint(msd.strftime('%m'))-1] + ' ' + msd.strftime('%Y'),'sd':msd.strftime('%Y-%m-%d'),'ed':webnotes.utils.get_last_day(msd).strftime('%Y-%m-%d'),'pt':'Month','fy':fy}
self.create_period(arg)
#---------------------------------------------------------
#create period common function
def create_period(self,arg):
p = Document('Period')
p.period_name = arg['pn']
p.start_date = arg['sd']
p.end_date = arg['ed']
p.period_type = arg['pt']
p.fiscal_year = arg['fy']
try:
p.save(1)
except NameError, e:
msgprint('Period %s already exists' % p.period_name)
raise Exception

View File

@@ -1,32 +0,0 @@
# DocType, Period Control
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:12',
'docstatus': 0,
'modified': '2011-01-03 17:46:14',
'modified_by': 'umair@iwebnotes.com',
'owner': 'nabin@webnotestech.com'
},
# These values are common for all DocType
{
'colour': 'White:FFF',
'doctype': 'DocType',
'in_create': 1,
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'read_only': 1,
'section_style': 'Simple',
'server_code_error': ' ',
'version': 36
},
# DocType, Period Control
{
'doctype': 'DocType',
'name': 'Period Control'
}
]

View File

@@ -1,186 +0,0 @@
# 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 Roles and Modules on loading Permission Engine
# -----------------------------------------------------
def get_doctype_list(self):
ret = sql("""SELECT `name` FROM tabDocType
WHERE ifnull(docstatus,0)=0
AND ifnull(istable,0)=0
AND ifnull(issingle,0)=0
AND `module` NOT IN ('System','Utilities','Setup Masters','Roles','Recycle Bin','Mapper','Application Internal','Development')
ORDER BY `name` ASC""")
rl = [''] + [a[0] for a in sql("select name from tabRole where ifnull(docstatus,0)=0")]
return {'doctypes': [r[0] for r in ret], 'roles': rl}
# Get Perm Level, Perm type of Doctypes of Module and Role Selected
# -------------------------------------------------------------------
def get_permissions(self,doctype):
ret = []
# Get permtype for the role selected
ptype = sql("select `role`,`permlevel`,`read`,`write`,`create`,`submit`,`cancel`,`amend` from tabDocPerm where `parent` = %s order by `permlevel` ASC",doctype,as_dict = 1)
# to convert 0L in 0 in values of dictionary
for p in ptype:
for key in p:
if key!='role':
p[key] = cint(p[key])
ret.append(p)
# fields list
fl = ['', 'owner'] + [l[0] for l in sql("select fieldname from tabDocField where parent=%s and fieldtype='Link' and ifnull(options,'')!=''", doctype)]
return {'perms':ret, 'fields':fl}
# get default values
# ------------------
def get_defaults(self, arg):
match_key, with_profiles = arg.split('~~~')
pl = ol = []
# defaults
dl = [a for a in sql("select parent, ifnull(parenttype,'') as parenttype, ifnull(defvalue,'') as defvalue from tabDefaultValue where defkey=%s order by parenttype desc, parent asc", match_key, as_dict=1)]
# options
tn = sql("select options from tabDocField where fieldname=%s and fieldtype='Link' and docstatus=0 limit 1", match_key)[0][0]
ol = [''] + [a[0] for a in sql("select name from `tab%s` where ifnull(docstatus,0)=0" % tn)]
# roles
if with_profiles=='Yes':
# profiles
pl = [''] + [a[0] for a in sql("select name from tabProfile where ifnull(enabled,0)=1")]
return {'dl':dl, 'pl':pl, 'ol':ol}
# delete default
# ----------------------
def delete_default(self, arg):
parent, defkey, defvalue = arg.split('~~~')
sql("delete from tabDefaultValue where parent=%s and defkey=%s and defvalue=%s", (parent, defkey, defvalue))
# add default
# ----------------------
def add_default(self, arg):
parent, parenttype, defkey, defvalue = arg.split('~~~')
if sql("select name from tabDefaultValue where parent=%s and defkey=%s and defvalue=%s", (parent, defkey, defvalue)):
msgprint("This rule already exists!")
return
dv = Document('DefaultValue')
dv.parent = parent
dv.parenttype = parenttype
dv.parentfield = 'defaults'
dv.defkey = defkey
dv.defvalue = defvalue
dv.save(1)
return dv.fields
# Add Permissions
# ----------------------
def add_permission(self,args=''):
parent, role, level = eval(args)
if sql("select name from tabDocPerm where parent=%s and role=%s and permlevel=%s", (parent, role, level)):
msgprint("This permission rule already exists!")
return
d = Document('DocPerm')
d.parent = parent
d.parenttype = 'DocType'
d.parentfield = 'permissions'
d.role = role
d.permlevel = cint(level)
d.docstatus = 0
d.save(1)
sql("update tabDocType set modified = %s where name = %s",(now(), parent))
# Update Permissions
# ----------------------
def update_permissions(self,args=''):
args = eval(args)
di = args['perm_dict']
doctype_keys = di.keys() # ['Enquiry','Competitor','Zone','State']
for parent in doctype_keys:
for permlevel in di[parent].keys():
for role in di[parent][permlevel].keys():
if role:
# check if Permissions for that perm level and Role exists
exists = sql("select name from tabDocPerm where parent = %s and role = %s and ifnull(permlevel, 0) = %s",(parent, role, cint(permlevel)))
# Get values of dictionary of Perm Level
pd = di[parent][permlevel][role]
# update
if exists and (1 in pd.values()):
sql("update tabDocPerm set `read` = %s, `write` = %s, `create` = %s, `submit` = %s, `cancel` = %s, `amend` = %s, `match`=%s where parent = %s and role = %s and permlevel = %s",(pd['read'],pd['write'],pd['create'],pd['submit'],pd['cancel'],pd['amend'], pd.get('match'), parent, role, permlevel))
# new
elif not exists and (1 in pd.values()):
ch = Document('DocPerm')
ch.parentfield = 'permissions'
ch.parenttype = 'DocType'
ch.parent = parent
ch.role = role
ch.permlevel = cint(permlevel)
for key in pd.keys():
ch.fields[key] = pd.get(key, None)
ch.save(1)
# delete
elif exists and (1 not in pd.values()):
sql("delete from tabDocPerm where parent = %s and role = %s and ifnull(permlevel,0) = %s",(parent, role, cint(permlevel)))
sql("update tabDocType set modified = %s where name = %s",(now(), parent))
msgprint("Permissions Updated")
# Get Fields based on DocType and Permlevel
# ----------------------------------------------
def get_fields(self, args = ''):
ret = {}
args = eval(args)
table_fields_dict = {}
table_exists = sql("Select options from tabDocField where fieldtype = 'Table' and parent = %s",args['dt'])
if table_exists:
for d in table_exists:
table_fields_dict[d[0]]= sql("select label,fieldtype,fieldname,options from tabDocField where parent = %s and permlevel = %s",(d[0],args['permlevel']),as_dict = 1)
parent_fields_dict = sql("select label, fieldtype, fieldname, options from tabDocField where parent = %s and permlevel = %s and fieldtype not in ('Section Break','Column Break')",(args['dt'],args['permlevel']),as_dict = 1)
ret['parent_fields_dict'] = parent_fields_dict
ret['table_fields_dict'] = table_fields_dict
return ret

View File

@@ -1,33 +0,0 @@
# DocType, Permission Control
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:12',
'docstatus': 0,
'modified': '2010-12-20 15:09:18',
'modified_by': 'sneha@webnotestech.com',
'owner': 'saumil@webnotestech.com'
},
# These values are common for all DocType
{
'colour': 'White:FFF',
'doctype': 'DocType',
'in_create': 1,
'issingle': 1,
'module': 'Setup',
'name': '__common__',
'read_only': 1,
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 15
},
# DocType, Permission Control
{
'doctype': 'DocType',
'name': 'Permission Control'
}
]

View File

@@ -1,31 +0,0 @@
import webnotes
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
#
# load current banner
#
def onload(self):
self.doc.header_html = webnotes.conn.get_value('Control Panel', None, 'client_name')
#
# on update
#
def validate(self):
if self.doc.file_list and self.doc.set_from_attachment:
self.set_html_from_image()
# update control panel - so it loads new letter directly
webnotes.conn.set_value('Control Panel', None, 'client_name', self.doc.header_html)
# clear the cache so that the new letter head is uploaded
webnotes.conn.sql("delete from __SessionCache")
#
# set html for image
#
def set_html_from_image(self):
file_name = self.doc.file_list.split(',')[0]
self.doc.header_html = '<div><img style="max-height: 120px; max-width: 600px" src="index.cgi?cmd=get_file&fname=' + file_name + '"/></div>'

View File

@@ -1,105 +0,0 @@
# DocType, Personalize
[
# These values are common in all dictionaries
{
'creation': '2011-03-22 16:06:53',
'docstatus': 0,
'modified': '2011-03-17 12:20:29',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1303277497',
'allow_attach': 1,
'allow_copy': 1,
'allow_email': 1,
'allow_print': 1,
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Other',
'in_create': 1,
'issingle': 1,
'max_attachments': 1,
'module': 'Setup',
'name': '__common__',
'read_only': 1,
'section_style': 'Simple',
'version': 4
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Personalize',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': 'DocPerm',
'idx': 1,
'name': '__common__',
'parent': 'Personalize',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'System Manager',
'write': 1
},
# DocType, Personalize
{
'doctype': 'DocType',
'name': 'Personalize'
},
# DocPerm
{
'doctype': 'DocPerm'
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'HTML',
'idx': 1,
'label': 'Help HTML',
'options': '<div class="help_box">You can edit HTML for your banner or add an attachment and click on "Set from Attachment"</div>'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'header_html',
'fieldtype': 'Code',
'idx': 2,
'label': 'Banner HTML'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'set_from_attachment',
'fieldtype': 'Check',
'idx': 3,
'label': 'Set from attachment'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'file_list',
'fieldtype': 'Text',
'hidden': 1,
'idx': 4,
'label': 'File List'
}
]

View File

@@ -1,21 +0,0 @@
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.__islocal) {
set_field_options('Price Help', ''); return;
}
if(!doc.file_list) {
set_field_options('Price Help', '<div class="help_box">To upload a price list, please attach a (.csv) file with 3 columns - <b>Item Code, Price and Currency</b> (no headings necessary). See attachments box in the right column</div>')
} else {
set_field_options('Price Help', '<div class="help_box">To update prices from the attachment, please click on "Update Prices"</div>')
}
}
cur_frm.cscript['Clear Prices'] = function(doc, cdt, cdn) {
if(confirm("This action will clear all rates for '"+ doc.name +"' from the Item Master and cannot be un-done. Are you sure you want to continue?")) {
$c_obj([doc], 'clear_prices', '', function(r, rt) { });
}
}

View File

@@ -1,92 +0,0 @@
# 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.cl = []
# validate currency
def is_currency_valid(self, currency):
if currency in self.cl:
return 1
if sql("select name from tabCurrency where name=%s", currency):
self.cl.append(currency)
return 1
else:
return 0
# update prices in Price List
def update_prices(self):
import csv
data = csv.reader(self.get_csv_data().splitlines())
updated = 0
for line in data:
if len(line)==3:
# if item exists
if sql("select name from tabItem where name=%s", line[0]):
if self.is_currency_valid(line[2]):
# if price exists
ref_ret_detail = sql("select name from `tabRef Rate Detail` where parent=%s and price_list_name=%s and ref_currency=%s", \
(line[0], self.doc.name, line[2]))
if ref_ret_detail:
sql("update `tabRef Rate Detail` set ref_rate=%s where name=%s", (line[1], ref_ret_detail[0][0]))
else:
d = Document('Ref Rate Detail')
d.parent = line[0]
d.parentfield = 'ref_rate_details'
d.parenttype = 'Item'
d.price_list_name = self.doc.name
d.ref_rate = line[1]
d.ref_currency = line[2]
d.save(1)
updated += 1
else:
msgprint("[Ignored] Unknown currency '%s' for Item '%s'" % (line[2], line[0]))
else:
msgprint("[Ignored] Did not find Item '%s'" % line[1])
else:
msgprint("[Ignored] Incorrect format: %s" % str(line))
msgprint("<b>%s</b> items updated" % updated)
# clear prices
def clear_prices(self):
cnt = sql("select count(*) from `tabRef Rate Detail` where price_list_name = %s", self.doc.name)
sql("delete from `tabRef Rate Detail` where price_list_name = %s", self.doc.name)
msgprint("%s prices cleared" % cnt[0][0])
# Update CSV data
def get_csv_data(self):
if not self.doc.file_list:
msgprint("File not attached!")
raise Exception
fid = self.doc.file_list.split(',')[1]
from webnotes.utils import file_manager
fn, content = file_manager.get_file(fid)
if not type(content) == str:
content = content.tostring()
return content

View File

@@ -1,185 +0,0 @@
# DocType, Price List
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:13',
'docstatus': 0,
'modified': '2011-04-18 10:01:48',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1303100817',
'allow_attach': 1,
'allow_trash': 1,
'autoname': 'field:price_list_name',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'module': 'Setup',
'name': '__common__',
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 6
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Price List',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# These values are common for all DocPerm
{
'amend': 0,
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Price List',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1,
'submit': 0
},
# DocType, Price List
{
'doctype': 'DocType',
'name': 'Price List'
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 1,
'role': 'Sales Manager',
'write': 0
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 0,
'role': 'Sales Manager',
'write': 0
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 1,
'role': 'Sales User',
'write': 0
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 4,
'permlevel': 0,
'role': 'Sales User',
'write': 0
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 5,
'permlevel': 0,
'role': 'Sales Master Manager',
'write': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 1,
'label': 'Trash Reason',
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'price_list_name',
'fieldtype': 'Data',
'idx': 2,
'label': 'Price List Name',
'oldfieldname': 'price_list_name',
'oldfieldtype': 'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': 'White:FFF',
'depends_on': 'eval:!doc.__islocal',
'doctype': 'DocField',
'fieldtype': 'HTML',
'idx': 3,
'label': 'Price Help',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'depends_on': 'eval:!doc.__islocal',
'description': 'Click on this button to clear prices for this list in all items',
'doctype': 'DocField',
'fieldtype': 'Button',
'idx': 4,
'label': 'Clear Prices',
'permlevel': 0,
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'file_list',
'fieldtype': 'Text',
'hidden': 1,
'idx': 5,
'label': 'File List',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'depends_on': 'eval:!doc.__islocal',
'description': 'Update prices from the attachment',
'doctype': 'DocField',
'fieldtype': 'Button',
'idx': 6,
'label': 'Update Prices',
'options': 'update_prices',
'permlevel': 0,
'trigger': 'Server'
}
]

View File

@@ -1,10 +0,0 @@
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}

View File

@@ -1,22 +0,0 @@
# 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

View File

@@ -1,103 +0,0 @@
# DocType, Print Heading
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:13',
'docstatus': 0,
'modified': '2010-09-20 14:06:57',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1294312215',
'allow_trash': 1,
'autoname': 'field:print_heading',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'module': 'Setup',
'name': '__common__',
'search_fields': 'print_heading',
'section_style': 'Simple',
'server_code_error': ' ',
'version': 27
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Print Heading',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# These values are common for all DocPerm
{
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 1,
'name': '__common__',
'parent': 'Print Heading',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'All',
'write': 1
},
# DocType, Print Heading
{
'doctype': 'DocType',
'name': 'Print Heading'
},
# DocPerm
{
'doctype': 'DocPerm'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 1,
'label': 'Trash Reason',
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'print_heading',
'fieldtype': 'Data',
'idx': 2,
'in_filter': 1,
'label': 'Print Heading',
'oldfieldname': 'print_heading',
'oldfieldtype': 'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'description',
'fieldtype': 'Small Text',
'idx': 3,
'label': 'Description',
'oldfieldname': 'description',
'oldfieldtype': 'Small Text',
'permlevel': 0,
'width': '300px'
}
]

View File

@@ -1,6 +0,0 @@
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def t1(self):
msgprint('role')

View File

@@ -1,25 +0,0 @@
# 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 t1(self):
msgprint('role')

View File

@@ -1,114 +0,0 @@
# DocType, Role
[
# These values are common in all dictionaries
{
'creation': '2009-05-12 11:19:11',
'docstatus': 0,
'modified': '2010-12-28 17:02:39',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1307624201',
'allow_copy': 0,
'allow_email': 0,
'allow_print': 0,
'autoname': 'field:role_name',
'colour': 'White:FFF',
'doctype': 'DocType',
'hide_heading': 0,
'hide_toolbar': 0,
'idx': 0,
'issingle': 0,
'istable': 0,
'module': 'Setup',
'name': '__common__',
'read_only': 0,
'section_style': 'Simple',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Role',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'cancel': 0,
'create': 1,
'doctype': 'DocPerm',
'execute': 0,
'idx': 1,
'name': '__common__',
'parent': 'Role',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'Administrator',
'submit': 0,
'write': 1
},
# DocType, Role
{
'doctype': 'DocType',
'name': 'Role'
},
# DocPerm
{
'doctype': 'DocPerm'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'module',
'fieldtype': 'Select',
'idx': 1,
'label': 'Module',
'oldfieldname': 'module',
'oldfieldtype': 'Select',
'options': 'link:Module Def',
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'role_name',
'fieldtype': 'Data',
'idx': 2,
'label': 'Role Name',
'oldfieldname': 'role_name',
'oldfieldtype': 'Data',
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'defaults',
'fieldtype': 'Table',
'hidden': 0,
'idx': 3,
'label': 'Defaults',
'oldfieldname': 'defaults',
'oldfieldtype': 'Table',
'options': 'DefaultValue',
'reqd': 0,
'search_index': 0
}
]

View File

@@ -1,215 +0,0 @@
# 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_record_list(self,arg):
parent, type = arg.split(',')
pt_col = "parent_"+type.replace(' ','_').lower()
cl = sql("select name,is_group from `tab%s` where docstatus != 2 and %s ='%s' order by is_group desc"%(type,pt_col,parent),as_dict=1)
return {'parent':parent, 'cl':cl}
#=============================================================================================
# --------get root level records like all territories, all sales person etc---------
def get_fl_node(self,arg):
pt_col = "parent_"+arg.replace(' ','_').lower()
cl = sql("select name,is_group from `tab%s` where docstatus !=2 and %s=''"%(arg,pt_col),as_dict=1)
return {'cl':cl}
#=============================================================================================
def add_node(self,arg):
arg = eval(arg)
node_title = arg['node_title']
n = Document(node_title)
for d in arg.keys():
if d != 'node_title':
n.fields[d]=arg[d]
n.old_parent = ''
n_obj = get_obj(doc=n)
n_obj.validate()
n_obj.doc.save(1)
n_obj.on_update()
return n_obj.doc.name
#=============================================================================================
def trash_record(self,arg):
name,type = arg.split(',')
#validation for trash of default record
if not type == 'Sales Person':
field = 'default_'+type.lower().replace(' ','_')
chk = sql("select value from `tabSingles` where doctype = 'Manage Account' and field = '%s' and value = '%s'"%(field,name))
if chk:
msgprint("'%s' record is set as a default %s in Global Defaults. Please change default %s then try to trash '%s' record."%(name,type.lower(), type.lower(), name))
raise Exception
res = sql("select t1.name from `tab%s` t1, `tab%s` t2 where t1.lft > t2.lft and t1.rgt < t2.rgt and t1.docstatus != 2 and t2.name = '%s'"%(type,type,name))
if res:
msgprint("You can not trashed %s as it contains other nodes."%name)
raise Exception
sql("update `tab%s` set docstatus = 2 where name = '%s'"%(type,name))
#=============================================================================================
def get_parent_lst(self,type):
par_lst = [r[0] for r in sql("select name from `tab%s` where is_group = 'Yes' and docstatus != 2"%type)]
return par_lst
#=============================================================================================
def get_record(self,arg):
name, type = arg.split(',')
dict1 = {'Territory':'parent_territory','Customer Group':'parent_customer_group','Item Group':'parent_item_group','Sales Person':'parent_sales_person'}
parent_name = dict1[type]
query ="select name,"+dict1[type]+",is_group,rgt,lft from `tab"+cstr(type)+"` where name = '%s'"
sv = sql(query%(cstr(name)))
par_lst = [r[0] for r in sql("select distinct name from `tab"+cstr(type)+"` where docstatus !=2 and (rgt > %s or lft < %s) and is_group='Yes'"%(sv[0][3],sv[0][4]))]
dict2 = {}
dict2['name']=sv[0][0]
dict2['parent']=cstr(sv[0][1])
dict2['parent_lst']=par_lst
dict2['is_group']=sv[0][2]
return dict2
#=============================================================================================
def edit_node(self,arg):
arg = eval(arg)
nt = arg['node_title']
nm = nt == 'Territory' and arg['territory_name'] or nt == 'Sales Person' and arg['sales_person_name'] or nt=='Item Group' and arg['item_group_name'] or nt =='Customer Group' and arg['customer_group_name'] or ''
n_obj = get_obj(nt,nm)
for d in arg.keys():
if d != 'node_title':
n_obj.doc.fields[d]=arg[d]
n_obj.doc.save()
n_obj.on_update()
#=============== validation ======================================================================================
def mvalidate(self,args):
r = eval(args)
if r['lft'] == 0:
n = sql("select lft,rgt from `tab%s` where name = '%s'"%(r['node_title'],r['nm']))
r['lft'] = n[0][0]
r['rgt'] = n[0][1]
if r['action'] == 'Update':
#-----------------validate if current node has child node----------------------------------
v1 = self.val_group(r)
if v1 == 'true': return 'true'
#-------------------validation for parent sales person cannot be his child node------------
v1 = self.val_prt(r)
if v1 == 'true': return 'true'
#--------if current record has set as default record in manage account then should not allow to change 'has child node' to 'yes'
v1 = self.group_changed(r)
if v1 == 'true': return 'true'
elif r['action'] == 'Create':
#-------------------validation - record is already exist--------------------------------
v1 = self.duplicate_rcd(r)
if v1 == 'true': return 'true'
#-------------------------------------------------
v1 = self.trash_rcd(r)
if v1 == 'true': return 'true'
return 'false'
#-----------------validate if current node has child node----------------------------------
#------------------if yes then cannot change current node from group to leaf
#ON EDIT
def val_group(self,r):
if r['is_group'] == 'No':
ch = sql("select name from `tab%s` where lft>%s and rgt<%s and docstatus != 2"%(r['node_title'],r['lft'],r['rgt']))
if ch:
msgprint("You can not changed %s from group to leaf node as it contains other nodes."%r['nm'])
return 'true'
return 'false'
#-------------------validation for parent sales person cannot be his child node-------------
#ON EDIT
def val_prt(self,r):
res = sql("select name from `tab%s` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(r['node_title'],r['rgt'],r['lft'],r['parent_nm'],r['nm']))
if not res:
msgprint("Please enter parent %s."%(r['node_title']))
return 'true'
return 'false'
#--------if current record has set as default record then not allowed to changed 'has child node' to 'yes'--------------------
#--------------------------------------------------------
#ON EDIT
def group_changed(self,r):
if r['node_title'] != 'Sales Person' and r['is_group'] == 'Yes':
field = 'default_'+r['node_title'].lower().replace(' ','_')
res = sql("select value from `tabSingles` where field = '%s' and value = '%s'"%(field,r['nm']))
if res:
msgprint("'%s' record is set as default record in Global Defaults.'Has Child Node' field cannot be changed to 'Yes' as only leaf nodes are allowed in transaction."%(r['nm']))
return 'true'
return 'false'
#-------------------validation - record is already exist--------------------------------
#ON CREATE
def trash_rcd(self,r):
res = sql("select name from `tab%s` where name = '%s' and docstatus = 2"%(r['node_title'],r['nm']))
if res:
msgprint("'%s' record is trashed. To untrash please go to Setup & click on Trash."%(r['nm']))
return 'true'
return 'false'
#----------------------------------------------------------------
#ON CREATE
def duplicate_rcd(self,r):
res = sql("select name from `tab%s` where name = '%s' and docstatus != 2"%(r['node_title'],r['nm']))
if res:
msgprint("'%s' record is already exist."%(r['nm']))
return 'true'
return 'false'

Some files were not shown because too many files have changed in this diff Show More