mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-18 22:35:10 +00:00
moved directory structure
This commit is contained in:
5
setup/__init__.py
Normal file
5
setup/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
install_docs = [
|
||||
{'doctype':'Role', 'role_name': 'System Manager', 'name': 'System Manager'},
|
||||
{'doctype':'Role', 'role_name': 'Analytics', 'name': 'Analytics'}
|
||||
]
|
||||
1
setup/doctype/__init__.py
Normal file
1
setup/doctype/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
1
setup/doctype/authorization_control/__init__.py
Normal file
1
setup/doctype/authorization_control/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
217
setup/doctype/authorization_control/authorization_control.py
Normal file
217
setup/doctype/authorization_control/authorization_control.py
Normal file
@@ -0,0 +1,217 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, make_esc
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, getchildren, make_autoname
|
||||
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" % ('%s', '%s', '%s', '%s', '%s', condition), (doctype_name, flt(max_amount), total, based_on, company))
|
||||
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" % ('%s', '%s', '%s', '%s', condition), (doctype_name, flt(max_amount), total, based_on))
|
||||
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" % ('%s', '%s', '%s', '%s', cond, add_cond1), (doctype_name, total, based_on, company))
|
||||
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" % ('%s', '%s', '%s', cond, add_cond1), (doctype_name, total, based_on))
|
||||
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" % ('%s', '%s', '%s', '%s', cond, add_cond2), (doctype_name, total, based_on, company))
|
||||
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"% ('%s', '%s', '%s', cond, add_cond2), (doctype_name, total, based_on))
|
||||
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 == 'Sales Invoice': customer = doc_obj.doc.customer
|
||||
else: customer = doc_obj.doc.customer_name
|
||||
add_cond = " and master_name = '"+make_esc("'")(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 == 'Purchase Invoice': doctype_name = 'Purchase Invoice'
|
||||
elif doctype_name == 'Sales Invoice': 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 (company = %s or ifnull(company,'')='')
|
||||
and docstatus != 2
|
||||
""" % ('%s', "'"+"','".join(webnotes.user.get_roles())+"'", "'"+"','".join(final_based_on)+"'", '%s'), (doctype_name, 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 Claim':
|
||||
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
|
||||
@@ -0,0 +1,30 @@
|
||||
# DocType, Authorization Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:18',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:18',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Tabbed',
|
||||
'server_code_error': u' ',
|
||||
'version': 216
|
||||
},
|
||||
|
||||
# DocType, Authorization Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Authorization Control'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/authorization_rule/__init__.py
Normal file
1
setup/doctype/authorization_rule/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
125
setup/doctype/authorization_rule/authorization_rule.js
Normal file
125
setup/doctype/authorization_rule/authorization_rule.js
Normal file
@@ -0,0 +1,125 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
//--------- 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 Claim' || 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 Claim' || 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 Claim') 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.docstatus != 2 AND tabProfile.enabled = 1 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.docstatus != 2 AND tabProfile.enabled = 1 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';
|
||||
}
|
||||
108
setup/doctype/authorization_rule/authorization_rule.py
Normal file
108
setup/doctype/authorization_rule/authorization_rule.py
Normal file
@@ -0,0 +1,108 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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 Claim' 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 Claim' and self.doc.based_on != 'Total Claimed Amount':
|
||||
msgprint("Authorization rule should be based on 'Total Calimed Amount' while setting authorization rule for 'Expense Claim'")
|
||||
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)
|
||||
212
setup/doctype/authorization_rule/authorization_rule.txt
Normal file
212
setup/doctype/authorization_rule/authorization_rule.txt
Normal file
@@ -0,0 +1,212 @@
|
||||
# DocType, Authorization Rule
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:18',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:18',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1308741898',
|
||||
'allow_trash': 1,
|
||||
'autoname': u'AR.####',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'search_fields': u'transaction,based_on,system_user,system_role,approving_user,approving_role',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 58
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Authorization Rule',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Authorization Rule',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Authorization Rule
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Authorization Rule'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Company',
|
||||
'oldfieldname': u'company',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Company',
|
||||
'reqd': 0,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'transaction',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Transaction',
|
||||
'oldfieldname': u'transaction',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nDelivery Note\nPurchase Invoice\nPurchase Order\nPurchase Receipt\nQuotation\nSales Invoice\nSales Order\nStock Entry\nExpense Claim\nAppraisal',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'based_on',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Based On',
|
||||
'oldfieldname': u'based_on',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nTotal Claimed Amount\nNot Applicable',
|
||||
'reqd': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'master_name',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Customer / Item Name',
|
||||
'oldfieldname': u'master_name',
|
||||
'oldfieldtype': u'Link',
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'system_role',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Applicable To (Role)',
|
||||
'oldfieldname': u'system_role',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Role'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'system_user',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Applicable To (User)',
|
||||
'oldfieldname': u'system_user',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Profile'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'This will be used for setting rule in HR module',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'to_emp',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Applicable To (Employee)',
|
||||
'oldfieldname': u'to_emp',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Employee',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'This will be used for setting rule in HR module',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'to_designation',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Applicable To (Designation)',
|
||||
'oldfieldname': u'to_designation',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Designation',
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'approving_role',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Approving Role',
|
||||
'oldfieldname': u'approving_role',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Role'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'approving_user',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Approving User',
|
||||
'oldfieldname': u'approving_user',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Profile'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'default': u'0.00',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'value',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Above Value',
|
||||
'oldfieldname': u'value',
|
||||
'oldfieldtype': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/brand/__init__.py
Normal file
1
setup/doctype/brand/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
26
setup/doctype/brand/brand.js
Normal file
26
setup/doctype/brand/brand.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
155
setup/doctype/brand/brand.txt
Normal file
155
setup/doctype/brand/brand.txt
Normal file
@@ -0,0 +1,155 @@
|
||||
# DocType, Brand
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:19',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:19',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:brand',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Brand',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Brand',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Brand
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Brand'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material Master Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Material Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Material User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'brand',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Brand Name',
|
||||
'oldfieldname': u'brand',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Description',
|
||||
'oldfieldname': u'description',
|
||||
'oldfieldtype': u'Text',
|
||||
'permlevel': 0,
|
||||
'width': u'300px'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/company/__init__.py
Normal file
1
setup/doctype/company/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
59
setup/doctype/company/company.js
Normal file
59
setup/doctype/company/company.js
Normal file
@@ -0,0 +1,59 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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';
|
||||
}
|
||||
262
setup/doctype/company/company.py
Normal file
262
setup/doctype/company/company.py
Normal file
@@ -0,0 +1,262 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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 validate(self):
|
||||
if self.doc.fields.get('__islocal') and len(self.doc.abbr) > 5:
|
||||
webnotes.msgprint("Abbreviation cannot have more than 5 characters",
|
||||
raise_exception=1)
|
||||
|
||||
# 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,''],
|
||||
['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,''],
|
||||
['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,''],
|
||||
['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,'']
|
||||
]
|
||||
|
||||
acc_list_india = [
|
||||
['CENVAT Capital Goods','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
|
||||
['CENVAT','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
|
||||
['CENVAT Service Tax','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
|
||||
['CENVAT Service Tax Cess 1','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
|
||||
['CENVAT Service Tax Cess 2','Tax Assets','Ledger','No','Chargeable','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','Chargeable','Debit',self.doc.name,''],
|
||||
['P L A - Cess Portion','Tax Assets','Ledger','No','Chargeable','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','Chargeable','Credit',self.doc.name,''],
|
||||
['VAT','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
|
||||
['TDS (Advertisement)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
|
||||
['TDS (Commission)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
|
||||
['TDS (Contractor)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
|
||||
['TDS (Interest)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
|
||||
['TDS (Rent)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
|
||||
['TDS (Salary)','Duties and Taxes','Ledger','No','Chargeable','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.doc.freeze_account='No'
|
||||
ac_obj.doc.master_type = ''
|
||||
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()
|
||||
|
||||
#
|
||||
# ---------------------------------------------------
|
||||
def on_trash(self):
|
||||
"""
|
||||
Trash accounts and cost centers for this company if no gl entry exists
|
||||
"""
|
||||
rec = sql("SELECT name from `tabGL Entry` where ifnull(is_cancelled, 'No') = 'No' and company = %s", self.doc.name)
|
||||
if not rec:
|
||||
# delete gl entry
|
||||
sql("delete from `tabGL Entry` where company = %s", self.doc.name)
|
||||
|
||||
#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 Global Defaults
|
||||
sql("update `tabSingles` set value = '' where doctype='Global Defaults' and field = 'default_company' and value = %s", self.doc.name)
|
||||
|
||||
|
||||
# on rename
|
||||
# ---------
|
||||
def on_rename(self,newdn,olddn):
|
||||
sql("update `tabCompany` set company_name = '%s' where name = '%s'" %(newdn,olddn))
|
||||
sql("update `tabSingles` set value = %s where doctype='Global Defaults' and field = 'default_company' and value = %s", (newdn, olddn))
|
||||
if get_defaults('company') == olddn:
|
||||
set_default('company', newdn)
|
||||
377
setup/doctype/company/company.txt
Normal file
377
setup/doctype/company/company.txt
Normal file
@@ -0,0 +1,377 @@
|
||||
# DocType, Company
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-05-15 12:15:00',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-08-10 12:15:45',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1323855292',
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:company_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Tabbed',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Company',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Company',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Company
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Company'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'All'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'details',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Company Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Company',
|
||||
'no_copy': 0,
|
||||
'oldfieldname': u'company_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cb0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Please Enter Abbreviation or Short Name properly as it will be added as Suffix to all Account Heads.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'abbr',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Abbr',
|
||||
'no_copy': 0,
|
||||
'oldfieldname': u'abbr',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_settings',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Default Settings',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_currency',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Default Currency',
|
||||
'options': u'link:Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'depends_on': u'eval:!doc.__islocal',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_bank_account',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Bank Account',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'default_bank_account',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'depends_on': u'eval:!doc.__islocal',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'receivables_group',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Receivables Group',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'receivables_group',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'depends_on': u'eval:!doc.__islocal',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'payables_group',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Payables Group',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'payables_group',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Account',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'depends_on': u'eval:!doc.__islocal',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'credit_days',
|
||||
'fieldtype': u'Int',
|
||||
'label': u'Credit Days',
|
||||
'oldfieldname': u'credit_days',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'depends_on': u'eval:!doc.__islocal',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'credit_limit',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Credit Limit',
|
||||
'oldfieldname': u'credit_limit',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u'eval:!doc.__islocal',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'yearly_bgt_flag',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'If Yearly Budget Exceeded',
|
||||
'oldfieldname': u'yearly_bgt_flag',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nWarn\nIgnore\nStop',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'depends_on': u'eval:!doc.__islocal',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'monthly_bgt_flag',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'If Monthly Budget Exceeded',
|
||||
'oldfieldname': u'monthly_bgt_flag',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nWarn\nIgnore\nStop',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'For reference only.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company_info',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Company Info',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'address',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Address',
|
||||
'oldfieldname': u'address',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'phone_no',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Phone No',
|
||||
'oldfieldname': u'phone_no',
|
||||
'oldfieldtype': u'Data',
|
||||
'options': u'Phone',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fax',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Fax',
|
||||
'oldfieldname': u'fax',
|
||||
'oldfieldtype': u'Data',
|
||||
'options': u'Phone',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'email',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Email',
|
||||
'oldfieldname': u'email',
|
||||
'oldfieldtype': u'Data',
|
||||
'options': u'Email',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'website',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Website',
|
||||
'oldfieldname': u'website',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Company registration numbers for your reference. Example: VAT Registration Numbers etc.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'registration_info',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Registration Info',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Company registration numbers for your reference. Tax numbers etc.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'registration_details',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'Registration Details',
|
||||
'oldfieldname': u'registration_details',
|
||||
'oldfieldtype': u'Code',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
1
setup/doctype/contact_control/__init__.py
Normal file
1
setup/doctype/contact_control/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
216
setup/doctype/contact_control/contact_control.js
Executable file
216
setup/doctype/contact_control/contact_control.js
Executable file
@@ -0,0 +1,216 @@
|
||||
// common partner functions
|
||||
// =========================
|
||||
|
||||
|
||||
// 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');
|
||||
$(cur_frm.history_html).css({
|
||||
'min-height': '320px',
|
||||
});
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get sates on country trigger
|
||||
// -----------------------------
|
||||
cur_frm.cscript.get_states=function(doc,dt,dn){
|
||||
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// 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';
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.render_contact_row = function(wrapper, data) {
|
||||
// prepare data
|
||||
data.fullname = (data.first_name || '')
|
||||
+ (data.last_name ? ' ' + data.last_name : '');
|
||||
data.primary = data.is_primary_contact ? ' [Primary]' : '';
|
||||
|
||||
// prepare description
|
||||
var description = [];
|
||||
$.each([
|
||||
['phone', 'Tel'],
|
||||
['mobile_no', 'Mobile'],
|
||||
['email_id', 'Email'],
|
||||
['department', 'Department'],
|
||||
['designation', 'Designation']],
|
||||
function(i, v) {
|
||||
if(v[0] && data[v[0]]) {
|
||||
description.push(repl('<h6>%(label)s:</h6> %(value)s', {
|
||||
label: v[1],
|
||||
value: data[v[0]],
|
||||
}));
|
||||
}
|
||||
});
|
||||
data.description = description.join('<br />');
|
||||
|
||||
cur_frm.cscript.render_row_in_wrapper(wrapper, data, 'Contact');
|
||||
}
|
||||
|
||||
cur_frm.cscript.render_address_row = function(wrapper, data) {
|
||||
// prepare data
|
||||
data.fullname = data.address_type;
|
||||
data.primary = '';
|
||||
if (data.is_primary_address) data.primary += ' [Primary]';
|
||||
if (data.is_shipping_address) data.primary += ' [Shipping]';
|
||||
|
||||
// prepare address
|
||||
var address = [];
|
||||
$.each(['address_line1', 'address_line2', 'city', 'state', 'country', 'pincode'],
|
||||
function(i, v) {
|
||||
if(data[v]) address.push(data[v]);
|
||||
});
|
||||
|
||||
data.address = address.join('<br />');
|
||||
data.address = "<p class='address-list'>" + data.address + "</p>";
|
||||
|
||||
// prepare description
|
||||
var description = [];
|
||||
$.each([
|
||||
['address', 'Address'],
|
||||
['phone', 'Tel'],
|
||||
['fax', 'Fax'],
|
||||
['email_id', 'Email']],
|
||||
function(i, v) {
|
||||
if(data[v[0]]) {
|
||||
description.push(repl('<h6>%(label)s:</h6> %(value)s', {
|
||||
label: v[1],
|
||||
value: data[v[0]],
|
||||
}));
|
||||
}
|
||||
});
|
||||
data.description = description.join('<br />');
|
||||
|
||||
cur_frm.cscript.render_row_in_wrapper(wrapper, data, 'Address');
|
||||
|
||||
$(wrapper).find('p.address-list').css({
|
||||
'padding-left': '10px',
|
||||
'margin-bottom': '-10px'
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript.render_row_in_wrapper = function(wrapper, data, doctype) {
|
||||
// render
|
||||
var $wrapper = $(wrapper);
|
||||
|
||||
data.doctype = doctype.toLowerCase();
|
||||
|
||||
$wrapper.append(repl("\
|
||||
<h4><a class='link_type'>%(fullname)s</a>%(primary)s</h4>\
|
||||
<div class='description'>\
|
||||
%(description)s\
|
||||
<p><a class='delete link_type'>delete this %(doctype)s</a></p>\
|
||||
</div>", data));
|
||||
|
||||
// make link
|
||||
$wrapper.find('h4 a.link_type').click(function() {
|
||||
loaddoc(doctype, data.name);
|
||||
});
|
||||
|
||||
// css
|
||||
$wrapper.css({ 'padding': '5px 0px' });
|
||||
$wrapper.find('div.description').css({
|
||||
'padding': '5px 2px',
|
||||
'line-height': '150%',
|
||||
});
|
||||
$wrapper.find('h6').css({ 'display': 'inline-block' });
|
||||
|
||||
// show delete
|
||||
var $delete_doc = $wrapper.find('a.delete');
|
||||
if (wn.model.can_delete(doctype)) {
|
||||
$delete_doc.toggle(true);
|
||||
} else {
|
||||
$delete_doc.toggle(false);
|
||||
}
|
||||
$delete_doc.css({
|
||||
'padding-left': '0px'
|
||||
});
|
||||
|
||||
$delete_doc.click(function() {
|
||||
cur_frm.cscript.delete_doc(doctype, data.name);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript.delete_doc = function(doctype, name) {
|
||||
// confirm deletion
|
||||
var go_ahead = confirm(repl('Delete %(doctype)s "%(name)s"', {
|
||||
doctype: doctype,
|
||||
name: name
|
||||
}));
|
||||
if (!go_ahead) return;
|
||||
|
||||
wn.call({
|
||||
method: 'webnotes.model.delete_doc',
|
||||
args: {
|
||||
dt: doctype,
|
||||
dn: name
|
||||
},
|
||||
callback: function(r) {
|
||||
//console.log(r);
|
||||
if (!r.exc) {
|
||||
// run the correct list
|
||||
var list_name = doctype.toLowerCase() + '_list';
|
||||
cur_frm[list_name].run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
104
setup/doctype/contact_control/contact_control.py
Normal file
104
setup/doctype/contact_control/contact_control.py
Normal file
@@ -0,0 +1,104 @@
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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)
|
||||
84
setup/doctype/contact_control/contact_control.txt
Normal file
84
setup/doctype/contact_control/contact_control.txt
Normal file
@@ -0,0 +1,84 @@
|
||||
# DocType, Contact Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:19',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:19',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 25
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldtype': u'Text',
|
||||
'name': '__common__',
|
||||
'parent': u'Contact Control',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Contact Control',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Contact Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Contact Control'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'header',
|
||||
'label': u'Header'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'customer_intro',
|
||||
'label': u'Customer Intro'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'supplier_intro',
|
||||
'label': u'Supplier Intro'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/country/__init__.py
Normal file
1
setup/doctype/country/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
95
setup/doctype/country/country.txt
Normal file
95
setup/doctype/country/country.txt
Normal file
@@ -0,0 +1,95 @@
|
||||
# DocType, Country
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:19',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:19',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'field:country_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'in_create': 0,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 0,
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 11
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'country_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Country Name',
|
||||
'name': '__common__',
|
||||
'oldfieldname': u'country_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'parent': u'Country',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Country',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Country
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Country'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Sales Master Manager',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Purchase Master Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'HR Manager'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/currency/__init__.py
Normal file
1
setup/doctype/currency/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
3
setup/doctype/currency/currency.js
Normal file
3
setup/doctype/currency/currency.js
Normal file
@@ -0,0 +1,3 @@
|
||||
cur_frm.cscript.refresh = function(doc) {
|
||||
cur_frm.set_intro(doc.__islocal ? "" : "There is nothing to edit.")
|
||||
}
|
||||
94
setup/doctype/currency/currency.txt
Normal file
94
setup/doctype/currency/currency.txt
Normal file
@@ -0,0 +1,94 @@
|
||||
# DocType, Currency
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-11 16:11:45',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:currency_name',
|
||||
'colour': u'White:FFF',
|
||||
'description': u'**Currency** Master',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 0,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 0,
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'currency_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Currency Name',
|
||||
'name': '__common__',
|
||||
'oldfieldname': u'currency_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'parent': u'Currency',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Currency',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Currency
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Currency'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Accounts Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Sales Master Manager',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Purchase Master Manager',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/customer_group/__init__.py
Normal file
1
setup/doctype/customer_group/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
45
setup/doctype/customer_group/customer_group.js
Normal file
45
setup/doctype/customer_group/customer_group.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.cscript.set_breadcrumbs = function(barea) {
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(cur_frm.docname);
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!Sales Browser/Customer Group">\
|
||||
Customer Group Tree</a>');
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!selling-home">Selling</a>');
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.set_root_readonly(doc);
|
||||
}
|
||||
|
||||
cur_frm.cscript.set_root_readonly = function(doc) {
|
||||
// read-only for root customer group
|
||||
if(doc.name==='All Customer Groups') {
|
||||
cur_frm.perm = [[1,0,0], [1,0,0]];
|
||||
cur_frm.set_intro("This is a root customer group and cannot be edited.");
|
||||
} else {
|
||||
cur_frm.set_intro(null);
|
||||
}
|
||||
}
|
||||
|
||||
//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';
|
||||
}
|
||||
61
setup/doctype/customer_group/customer_group.py
Normal file
61
setup/doctype/customer_group/customer_group.py
Normal file
@@ -0,0 +1,61 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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 webnotes.utils.nestedset import DocTypeNestedSet
|
||||
class DocType(DocTypeNestedSet):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
self.nsm_parent_field = 'parent_customer_group';
|
||||
|
||||
def validate(self):
|
||||
if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", (self.doc.customer_group_name)):
|
||||
msgprint("""Another %s record is trashed.
|
||||
To untrash please go to Setup & click on Trash."""%(self.doc.customer_group_name), raise_exception = 1)
|
||||
self.validate_root_details("All Customer Groups", "parent_customer_group")
|
||||
|
||||
def on_trash(self):
|
||||
cust = sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s", self.doc.name)
|
||||
cust = [d[0] for d in cust]
|
||||
|
||||
if cust:
|
||||
msgprint("""Customer Group: %s can not be trashed/deleted because it is used in customer: %s.
|
||||
To trash/delete this, remove/change customer group in customer master""" % (self.doc.name, cust or ''), raise_exception=1)
|
||||
|
||||
if sql("select name from `tabCustomer Group` where parent_customer_group = %s and docstatus != 2", self.doc.name):
|
||||
msgprint("Child customer group exists for this customer group. You can not trash/cancel/delete this customer group.", raise_exception=1)
|
||||
|
||||
# rebuild tree
|
||||
webnotes.conn.set(self.doc,'old_parent', '')
|
||||
self.update_nsm()
|
||||
241
setup/doctype/customer_group/customer_group.txt
Normal file
241
setup/doctype/customer_group/customer_group.txt
Normal file
@@ -0,0 +1,241 @@
|
||||
# DocType, Customer Group
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-12 09:47:20',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1294214943',
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:customer_group_name',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'in_create': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'search_fields': u'name,parent_customer_group',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Customer Group',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Customer Group',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocType, Customer Group
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Customer Group'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales Master Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales User',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales User',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales Master Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'customer_group_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Customer Group Name',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'customer_group_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'parent_customer_group',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Parent Customer Group',
|
||||
'oldfieldname': u'parent_customer_group',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Customer Group',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Only leaf nodes are allowed in transaction',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_group',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Has Child Node',
|
||||
'oldfieldname': u'is_group',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cb0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'This Price List will be selected as default for all Customers under this Group.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_price_list',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Price List',
|
||||
'options': u'Price List',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'lft',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'label': u'lft',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'lft',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'rgt',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'label': u'rgt',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'rgt',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'old_parent',
|
||||
'fieldtype': u'Link',
|
||||
'hidden': 1,
|
||||
'label': u'old_parent',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'old_parent',
|
||||
'oldfieldtype': u'Data',
|
||||
'options': u'Customer Group',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1
|
||||
}
|
||||
]
|
||||
1
setup/doctype/email_digest/__init__.py
Normal file
1
setup/doctype/email_digest/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
10
setup/doctype/email_digest/email_digest.css
Normal file
10
setup/doctype/email_digest/email_digest.css
Normal file
@@ -0,0 +1,10 @@
|
||||
table.profile-list {
|
||||
text-align: left;
|
||||
margin: auto;
|
||||
line-height: 250%;
|
||||
}
|
||||
|
||||
div.dialog-div {
|
||||
text-align: 'center';
|
||||
width: 100%;
|
||||
}
|
||||
122
setup/doctype/email_digest/email_digest.js
Normal file
122
setup/doctype/email_digest/email_digest.js
Normal file
@@ -0,0 +1,122 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, dt, dn) {
|
||||
doc = locals[dt][dn];
|
||||
var save_msg = "You must <b>Save</b> the form before proceeding";
|
||||
var err_msg = "There was an error. One probable reason could be that you haven't saved the form. Please contact support@erpnext.com if the problem persists."
|
||||
|
||||
cur_frm.add_custom_button('View Now', function() {
|
||||
doc = locals[dt][dn];
|
||||
if(doc.__unsaved != 1) {
|
||||
$c_obj(make_doclist(dt, dn), 'get_digest_msg', '', function(r, rt) {
|
||||
if(r.exc) {
|
||||
msgprint(err_msg);
|
||||
console.log(r.exc);
|
||||
} else {
|
||||
//console.log(arguments);
|
||||
var d = new wn.widgets.Dialog({
|
||||
title: 'Email Digest: ' + dn,
|
||||
width: 800
|
||||
});
|
||||
|
||||
$a(d.body, 'div', '', '', r['message']);
|
||||
|
||||
d.show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
msgprint(save_msg);
|
||||
}
|
||||
}, 1);
|
||||
cur_frm.add_custom_button('Send Now', function() {
|
||||
doc = locals[dt][dn];
|
||||
if(doc.__unsaved != 1) {
|
||||
$c_obj(make_doclist(dt, dn), 'send', '', function(r, rt) {
|
||||
if(r.exc) {
|
||||
msgprint(err_msg);
|
||||
console.log(r.exc);
|
||||
} else {
|
||||
//console.log(arguments);
|
||||
msgprint('Message Sent');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
msgprint(save_msg);
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
||||
cur_frm.cscript.addremove_recipients = function(doc, dt, dn) {
|
||||
// Get profile list
|
||||
$c_obj(make_doclist(dt, dn), 'get_profiles', '', function(r, rt) {
|
||||
if(r.exc) {
|
||||
msgprint(r.exc);
|
||||
} else {
|
||||
// Open a dialog and display checkboxes against email addresses
|
||||
doc = locals[dt][dn];
|
||||
var d = new wn.widgets.Dialog({
|
||||
title: 'Add/Remove Recipients',
|
||||
width: 400
|
||||
});
|
||||
var dialog_div = $a(d.body, 'div', 'dialog-div', '', '');
|
||||
var tab = make_table(dialog_div, r.profile_list.length+2, 2, '', ['15%', '85%']);
|
||||
tab.className = 'profile-list';
|
||||
var add_or_update = 'Add';
|
||||
$.each(r.profile_list, function(i, v) {
|
||||
var check = $a_input($td(tab, i+1, 0), 'checkbox');
|
||||
check.value = v.name;
|
||||
if(v.checked==1) {
|
||||
check.checked = 1;
|
||||
add_or_update = 'Update';
|
||||
}
|
||||
if(v.enabled==0) {
|
||||
v.name = "<span style='color: red'>" + v.name + " (disabled user)</span>"
|
||||
}
|
||||
var profile = $a($td(tab, i+1, 1), 'span', '', '', v.name);
|
||||
//profile.onclick = function() { check.checked = !check.checked; }
|
||||
});
|
||||
|
||||
// Display add recipients button
|
||||
if(r.profile_list.length>15) {
|
||||
$btn($td(tab, 0, 1), add_or_update + ' Recipients', function() {
|
||||
cur_frm.cscript.add_to_rec_list(doc, tab, r.profile_list.length);
|
||||
});
|
||||
}
|
||||
$btn($td(tab, r.profile_list.length+1, 1), add_or_update + ' Recipients', function() {
|
||||
cur_frm.cscript.add_to_rec_list(doc, tab, r.profile_list.length);
|
||||
});
|
||||
|
||||
cur_frm.rec_dialog = d;
|
||||
d.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript.add_to_rec_list = function(doc, tab, length) {
|
||||
// add checked profiles to list of recipients
|
||||
var rec_list = [];
|
||||
for(var i = 1; i <= length; i++) {
|
||||
var input = $($td(tab, i, 0)).find('input');
|
||||
if(input.is(':checked')) {
|
||||
rec_list.push(input.attr('value'));
|
||||
}
|
||||
}
|
||||
doc.recipient_list = rec_list.join('\n');
|
||||
cur_frm.rec_dialog.hide();
|
||||
cur_frm.save();
|
||||
cur_frm.refresh_fields();
|
||||
}
|
||||
346
setup/doctype/email_digest/email_digest.py
Normal file
346
setup/doctype/email_digest/email_digest.py
Normal file
@@ -0,0 +1,346 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import fmt_money, formatdate, now_datetime, cstr, esc
|
||||
from datetime import timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
content_sequence = ["income_year_to_date", "bank_balance",
|
||||
"income", "expenses_booked", "collections", "payments",
|
||||
"invoiced_amount", "payables",
|
||||
"new_leads", "new_enquiries", "new_quotations", "new_sales_orders",
|
||||
"new_delivery_notes", "new_purchase_requests", "new_supplier_quotations",
|
||||
"new_purchase_orders", "new_purchase_receipts", "new_stock_entries",
|
||||
"new_support_tickets", "new_communications", "new_projects"]
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc, self.doclist = doc, doclist
|
||||
|
||||
def get_profiles(self):
|
||||
"""get list of profiles"""
|
||||
import webnotes
|
||||
profile_list = webnotes.conn.sql("""
|
||||
select name, enabled from tabProfile
|
||||
where docstatus=0 and name not in ('Administrator', 'Guest')
|
||||
order by enabled desc, name asc""", as_dict=1)
|
||||
|
||||
if self.doc.recipient_list:
|
||||
recipient_list = self.doc.recipient_list.split("\n")
|
||||
else:
|
||||
recipient_list = []
|
||||
for p in profile_list:
|
||||
p["checked"] = p["name"] in recipient_list and 1 or 0
|
||||
|
||||
webnotes.response['profile_list'] = profile_list
|
||||
|
||||
def send(self):
|
||||
# send email only to enabled users
|
||||
valid_users = [p[0] for p in webnotes.conn.sql("""select name from `tabProfile`
|
||||
where enabled=1""")]
|
||||
recipients = filter(lambda r: r in valid_users,
|
||||
self.doc.recipient_list.split("\n"))
|
||||
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
sendmail(recipients=recipients, subject=(self.doc.frequency + " Digest"),
|
||||
sender="ERPNext Notifications <notifications+email_digest@erpnext.com>",
|
||||
msg=self.get_digest_msg())
|
||||
|
||||
def get_digest_msg(self):
|
||||
""""""
|
||||
self.from_date, self.to_date = self.get_from_to_date()
|
||||
self.currency = webnotes.conn.get_value("Company", self.doc.company,
|
||||
"default_currency")
|
||||
|
||||
out = []
|
||||
for ctype in content_sequence:
|
||||
if self.doc.fields.get(ctype) and hasattr(self, "get_"+ctype):
|
||||
# appends [value, html]
|
||||
out.append(getattr(self, "get_"+ctype)())
|
||||
|
||||
return self.get_msg_html(out)
|
||||
|
||||
def get_msg_html(self, out):
|
||||
with_value = "\n".join([o[1] for o in out if o[0]])
|
||||
|
||||
# seperate out no value items
|
||||
no_value = [o[1] for o in out if not o[0]]
|
||||
if no_value:
|
||||
no_value = """<hr><h4>No Updates For:</h4><br>""" + "\n".join(no_value)
|
||||
|
||||
date = self.doc.frequency == "Daily" and formatdate(self.from_date) or \
|
||||
"%s to %s" % (formatdate(self.from_date), formatdate(self.to_date))
|
||||
|
||||
msg = """<h2>%(digest)s</h2>
|
||||
<p style='color: grey'>%(date)s</p>
|
||||
<h4>%(company)s</h4>
|
||||
<hr>
|
||||
%(with_value)s
|
||||
%(no_value)s""" % {
|
||||
"digest": self.doc.frequency + " Digest",
|
||||
"date": date,
|
||||
"company": self.doc.company,
|
||||
"with_value": with_value,
|
||||
"no_value": no_value or ""
|
||||
}
|
||||
|
||||
return msg
|
||||
|
||||
def get_income_year_to_date(self):
|
||||
return self.get_income(webnotes.conn.get_defaults("year_start_date"),
|
||||
"Income Year To Date")
|
||||
|
||||
def get_bank_balance(self):
|
||||
# account is of type "Bank or Cash"
|
||||
accounts = dict([[a["name"], [a["account_name"], 0]] for a in self.get_accounts()
|
||||
if a["account_type"]=="Bank or Cash"])
|
||||
ackeys = accounts.keys()
|
||||
|
||||
for gle in self.get_gl_entries(None, self.to_date):
|
||||
if gle["account"] in ackeys:
|
||||
accounts[gle["account"]][1] += gle["debit"] - gle["credit"]
|
||||
|
||||
# build html
|
||||
out = self.get_html("Bank/Cash Balance", "", "")
|
||||
for ac in ackeys:
|
||||
if accounts[ac][1]:
|
||||
out += "\n" + self.get_html(accounts[ac][0], self.currency,
|
||||
fmt_money(accounts[ac][1]), style="margin-left: 17px")
|
||||
return sum((accounts[ac][1] for ac in ackeys)), out
|
||||
|
||||
def get_income(self, from_date=None, label=None):
|
||||
# account is PL Account and Credit type account
|
||||
accounts = [a["name"] for a in self.get_accounts()
|
||||
if a["is_pl_account"]=="Yes" and a["debit_or_credit"]=="Credit"]
|
||||
|
||||
income = 0
|
||||
for gle in self.get_gl_entries(from_date or self.from_date, self.to_date):
|
||||
if gle["account"] in accounts:
|
||||
income += gle["credit"] - gle["debit"]
|
||||
|
||||
return income, self.get_html(label or "Income", self.currency, fmt_money(income))
|
||||
|
||||
def get_expenses_booked(self):
|
||||
# account is PL Account and Debit type account
|
||||
accounts = [a["name"] for a in self.get_accounts()
|
||||
if a["is_pl_account"]=="Yes" and a["debit_or_credit"]=="Debit"]
|
||||
|
||||
expense = 0
|
||||
for gle in self.get_gl_entries(self.from_date, self.to_date):
|
||||
if gle["account"] in accounts:
|
||||
expense += gle["debit"] - gle["credit"]
|
||||
|
||||
return expense, self.get_html("Expenses", self.currency, fmt_money(expense))
|
||||
|
||||
def get_collections(self):
|
||||
return self.get_party_total("Customer", "credit", "Collections")
|
||||
|
||||
def get_payments(self):
|
||||
return self.get_party_total("Supplier", "debit", "Payments")
|
||||
|
||||
def get_party_total(self, party_type, gle_field, label):
|
||||
import re
|
||||
# account is of master_type Customer or Supplier
|
||||
accounts = [a["name"] for a in self.get_accounts()
|
||||
if a["master_type"]==party_type]
|
||||
|
||||
# account is "Bank or Cash"
|
||||
bc_accounts = [esc(a["name"], "()|") for a in self.get_accounts()
|
||||
if a["account_type"]=="Bank or Cash"]
|
||||
bc_regex = re.compile("""(%s)""" % "|".join(bc_accounts))
|
||||
|
||||
total = 0
|
||||
for gle in self.get_gl_entries(self.from_date, self.to_date):
|
||||
# check that its made against a bank or cash account
|
||||
if gle["account"] in accounts and gle["against"] and \
|
||||
bc_regex.findall(gle["against"]):
|
||||
total += gle[gle_field]
|
||||
|
||||
return total, self.get_html(label, self.currency, fmt_money(total))
|
||||
|
||||
def get_invoiced_amount(self):
|
||||
# aka receivables
|
||||
return self.get_booked_total("Customer", "debit", "Receivables")
|
||||
|
||||
def get_payables(self):
|
||||
return self.get_booked_total("Supplier", "credit", "Payables")
|
||||
|
||||
def get_booked_total(self, party_type, gle_field, label):
|
||||
# account is of master_type Customer or Supplier
|
||||
accounts = [a["name"] for a in self.get_accounts()
|
||||
if a["master_type"]==party_type]
|
||||
|
||||
total = 0
|
||||
for gle in self.get_gl_entries(self.from_date, self.to_date):
|
||||
if gle["account"] in accounts:
|
||||
total += gle[gle_field]
|
||||
|
||||
return total, self.get_html(label, self.currency, fmt_money(total))
|
||||
|
||||
def get_new_leads(self):
|
||||
return self.get_new_count("Lead", "New Leads")
|
||||
|
||||
def get_new_enquiries(self):
|
||||
return self.get_new_count("Opportunity", "New Opportunities")
|
||||
|
||||
def get_new_quotations(self):
|
||||
return self.get_new_sum("Quotation", "New Quotations", "grand_total")
|
||||
|
||||
def get_new_sales_orders(self):
|
||||
return self.get_new_sum("Sales Order", "New Sales Orders", "grand_total")
|
||||
|
||||
def get_new_delivery_notes(self):
|
||||
return self.get_new_sum("Delivery Note", "New Delivery Notes", "grand_total")
|
||||
|
||||
def get_new_purchase_requests(self):
|
||||
return self.get_new_count("Purchase Request", "New Purchase Requests")
|
||||
|
||||
def get_new_supplier_quotations(self):
|
||||
return self.get_new_sum("Supplier Quotation", "New Supplier Quotations",
|
||||
"grand_total")
|
||||
|
||||
def get_new_purchase_orders(self):
|
||||
return self.get_new_sum("Purchase Order", "New Purchase Orders", "grand_total")
|
||||
|
||||
def get_new_purchase_receipts(self):
|
||||
return self.get_new_sum("Purchase Receipt", "New Purchase Receipts",
|
||||
"grand_total")
|
||||
|
||||
def get_new_stock_entries(self):
|
||||
return self.get_new_sum("Stock Entry", "New Stock Entries", "total_amount")
|
||||
|
||||
def get_new_support_tickets(self):
|
||||
return self.get_new_count("Support Ticket", "New Support Tickets", False)
|
||||
|
||||
def get_new_communications(self):
|
||||
return self.get_new_count("Communication", "New Communications", False)
|
||||
|
||||
def get_new_projects(self):
|
||||
return self.get_new_count("Project", "New Projects", False)
|
||||
|
||||
def get_new_count(self, doctype, label, filter_by_company=True):
|
||||
if filter_by_company:
|
||||
company = """and company="%s" """ % self.doc.company
|
||||
else:
|
||||
company = ""
|
||||
count = webnotes.conn.sql("""select count(*) from `tab%s`
|
||||
where docstatus < 2 %s and
|
||||
date(creation)>=%s and date(creation)<=%s""" % (doctype, company, "%s", "%s"),
|
||||
(self.from_date, self.to_date))
|
||||
count = count and count[0][0] or 0
|
||||
|
||||
return count, self.get_html(label, None, count)
|
||||
|
||||
def get_new_sum(self, doctype, label, sum_field):
|
||||
count_sum = webnotes.conn.sql("""select count(*), sum(ifnull(`%s`, 0))
|
||||
from `tab%s` where docstatus < 2 and company = %s and
|
||||
date(creation)>=%s and date(creation)<=%s""" % (sum_field, doctype, "%s",
|
||||
"%s", "%s"), (self.doc.company, self.from_date, self.to_date))
|
||||
count, total = count_sum and count_sum[0] or (0, 0)
|
||||
|
||||
return count, self.get_html(label, self.currency,
|
||||
"%s - (%s)" % (fmt_money(total), cstr(count)))
|
||||
|
||||
def get_html(self, label, currency, value, style=None):
|
||||
"""get html output"""
|
||||
return """<p style="padding: 5px; %(style)s">
|
||||
<span>%(label)s</span>:
|
||||
<span style="font-weight: bold; font-size: 110%%">
|
||||
<span style="color: grey">%(currency)s</span>%(value)s
|
||||
</span></p>""" % {
|
||||
"style": style or "",
|
||||
"label": label,
|
||||
"currency": currency and (currency+" ") or "",
|
||||
"value": value
|
||||
}
|
||||
|
||||
def get_gl_entries(self, from_date=None, to_date=None):
|
||||
"""get valid GL Entries filtered by company and posting date"""
|
||||
if from_date==self.from_date and to_date==self.to_date and \
|
||||
hasattr(self, "gl_entries"):
|
||||
return self.gl_entries
|
||||
|
||||
gl_entries = webnotes.conn.sql("""select `account`,
|
||||
ifnull(credit, 0) as credit, ifnull(debit, 0) as debit, `against`
|
||||
from `tabGL Entry`
|
||||
where company=%s and ifnull(is_cancelled, "No")="No" and
|
||||
posting_date <= %s %s""" % ("%s", "%s",
|
||||
from_date and "and posting_date>='%s'" % from_date or ""),
|
||||
(self.doc.company, to_date or self.to_date), as_dict=1)
|
||||
|
||||
# cache if it is the normal cases
|
||||
if from_date==self.from_date and to_date==self.to_date:
|
||||
self.gl_entries = gl_entries
|
||||
|
||||
return gl_entries
|
||||
|
||||
def get_accounts(self):
|
||||
if not hasattr(self, "accounts"):
|
||||
self.accounts = webnotes.conn.sql("""select name, is_pl_account,
|
||||
debit_or_credit, account_type, account_name, master_type
|
||||
from `tabAccount` where company=%s and docstatus < 2""",
|
||||
(self.doc.company,), as_dict=1)
|
||||
return self.accounts
|
||||
|
||||
def get_from_to_date(self):
|
||||
today = now_datetime().date()
|
||||
|
||||
# decide from date based on email digest frequency
|
||||
if self.doc.frequency == "Daily":
|
||||
# from date, to_date is yesterday
|
||||
from_date = to_date = today - timedelta(days=1)
|
||||
elif self.doc.frequency == "Weekly":
|
||||
# from date is the previous week's monday
|
||||
from_date = today - timedelta(days=today.weekday(), weeks=1)
|
||||
# to date is sunday i.e. the previous day
|
||||
to_date = from_date + timedelta(days=6)
|
||||
else:
|
||||
# from date is the 1st day of the previous month
|
||||
from_date = today - relativedelta(days=today.day-1, months=1)
|
||||
# to date is the last day of the previous month
|
||||
to_date = today - relativedelta(days=today.day)
|
||||
|
||||
return from_date, to_date
|
||||
|
||||
def get_next_sending(self):
|
||||
from_date, to_date = self.get_from_to_date()
|
||||
|
||||
send_date = to_date + timedelta(days=1)
|
||||
|
||||
if self.doc.frequency == "Daily":
|
||||
next_send_date = send_date + timedelta(days=1)
|
||||
elif self.doc.frequency == "Weekly":
|
||||
next_send_date = send_date + timedelta(weeks=1)
|
||||
else:
|
||||
next_send_date = send_date + relativedelta(months=1)
|
||||
self.doc.next_send = formatdate(next_send_date) + " at midnight"
|
||||
|
||||
return send_date
|
||||
|
||||
def onload(self):
|
||||
self.get_next_sending()
|
||||
|
||||
def send():
|
||||
from webnotes.model.code import get_obj
|
||||
now_date = now_datetime().date()
|
||||
|
||||
for ed in webnotes.conn.sql("""select name from `tabEmail Digest`
|
||||
where enabled=1 and docstatus<2""", as_list=1):
|
||||
ed_obj = get_obj('Email Digest', ed[0])
|
||||
if (now_date == ed_obj.get_next_sending()):
|
||||
ed_obj.send()
|
||||
365
setup/doctype/email_digest/email_digest.txt
Normal file
365
setup/doctype/email_digest/email_digest.txt
Normal file
@@ -0,0 +1,365 @@
|
||||
# DocType, Email Digest
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
u'creation': '2012-07-12 23:29:44',
|
||||
u'docstatus': 0,
|
||||
u'modified': '2012-09-15 19:34:37',
|
||||
u'modified_by': u'Administrator',
|
||||
u'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1324556758',
|
||||
'autoname': u'Prompt',
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Send regular summary reports via Email.',
|
||||
u'doctype': u'DocType',
|
||||
'document_type': u'System',
|
||||
'module': u'Setup',
|
||||
u'name': u'__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
u'name': u'__common__',
|
||||
'parent': u'Email Digest',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
u'doctype': u'DocPerm',
|
||||
u'name': u'__common__',
|
||||
'parent': u'Email Digest',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocType, Email Digest
|
||||
{
|
||||
u'doctype': u'DocType',
|
||||
u'name': u'Email Digest'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'settings',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Email Digest Settings',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'enabled',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Enabled',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'For Company',
|
||||
'options': u'link:Company',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 0,
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'frequency',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'How frequently?',
|
||||
'options': u'Daily\nWeekly\nMonthly',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'depends_on': u'eval:doc.enabled',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'next_send',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Next email will be sent on:',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'Note: Email will not be sent to disabled users',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'recipient_list',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Recipients',
|
||||
'permlevel': 1,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'addremove_recipients',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Add/Remove Recipients',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Check all the items below that you want to send in this digest.',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'select_digest_content',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Select Digest Content',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_leads',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Leads',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_enquiries',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Enquiries',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_quotations',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Quotations',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_sales_orders',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Sales Orders',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_delivery_notes',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Delivery Notes',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_purchase_requests',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Purchase Requests',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_supplier_quotations',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Supplier Quotations',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_purchase_orders',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Purchase Orders',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_purchase_receipts',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Purchase Receipts',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_stock_entries',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Stock Entries',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_support_tickets',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Support Tickets',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_communications',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Communications',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'new_projects',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'New Projects',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'cb1',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'income_year_to_date',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Income Year to Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'bank_balance',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Bank Balance',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'income',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Income',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'expenses_booked',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Expenses Booked',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'collections',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Collections',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'payments',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Payments',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'invoiced_amount',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Receivables',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'payables',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Payables',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
u'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
u'doctype': u'DocPerm',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
1
setup/doctype/email_settings/__init__.py
Normal file
1
setup/doctype/email_settings/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
81
setup/doctype/email_settings/email_settings.py
Normal file
81
setup/doctype/email_settings/email_settings.py
Normal file
@@ -0,0 +1,81 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
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 validate(self):
|
||||
"""Checks connectivity to email servers before saving"""
|
||||
self.validate_outgoing()
|
||||
self.validate_incoming()
|
||||
|
||||
def validate_outgoing(self):
|
||||
"""Checks incoming email settings"""
|
||||
self.doc.encode()
|
||||
if self.doc.outgoing_mail_server:
|
||||
from webnotes.utils import cint
|
||||
from webnotes.utils.email_lib.smtp import SMTPServer
|
||||
smtpserver = SMTPServer(login = self.doc.mail_login,
|
||||
password = self.doc.mail_password,
|
||||
server = self.doc.outgoing_mail_server,
|
||||
port = cint(self.doc.mail_port),
|
||||
use_ssl = self.doc.use_ssl
|
||||
)
|
||||
|
||||
# exceptions are handled in session connect
|
||||
sess = smtpserver.sess
|
||||
|
||||
def validate_incoming(self):
|
||||
"""
|
||||
Checks support ticket email settings
|
||||
"""
|
||||
if self.doc.sync_support_mails and self.doc.support_host:
|
||||
from webnotes.utils.email_lib.receive import POP3Mailbox
|
||||
from webnotes.model.doc import Document
|
||||
import _socket, poplib
|
||||
|
||||
inc_email = Document('Incoming Email Settings')
|
||||
inc_email.encode()
|
||||
inc_email.host = self.doc.support_host
|
||||
inc_email.use_ssl = self.doc.support_use_ssl
|
||||
try:
|
||||
err_msg = 'User Name or Support Password missing. Please enter and try again.'
|
||||
if not (self.doc.support_username and self.doc.support_password):
|
||||
raise AttributeError, err_msg
|
||||
inc_email.username = self.doc.support_username
|
||||
inc_email.password = self.doc.support_password
|
||||
except AttributeError, e:
|
||||
webnotes.msgprint(err_msg)
|
||||
raise e
|
||||
|
||||
pop_mb = POP3Mailbox(inc_email)
|
||||
|
||||
try:
|
||||
pop_mb.connect()
|
||||
except _socket.error, e:
|
||||
# Invalid mail server -- due to refusing connection
|
||||
webnotes.msgprint('Invalid POP3 Mail Server. Please rectify and try again.')
|
||||
raise e
|
||||
except poplib.error_proto, e:
|
||||
webnotes.msgprint('Invalid User Name or Support Password. Please rectify and try again.')
|
||||
raise e
|
||||
254
setup/doctype/email_settings/email_settings.txt
Normal file
254
setup/doctype/email_settings/email_settings.txt
Normal file
@@ -0,0 +1,254 @@
|
||||
# DocType, Email Settings
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-12 16:16:27',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'harshada@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1325570647',
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'description': u'Email Settings for Outgoing and Incoming Emails.',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Email Settings',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Email Settings',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Email Settings
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Email Settings'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Set your outgoing mail SMTP settings here. All system generated notifications, emails will go from this mail server. If you are not sure, leave this blank to use ERPNext servers (emails will still be sent from your email id) or contact your email provider.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'outgoing_mails',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Outgoing Mails'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'SMTP Server (e.g. smtp.gmail.com)',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'outgoing_mail_server',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Outgoing Mail Server'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'use_ssl',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Use SSL'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'If non standard port (e.g. 587)',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'mail_port',
|
||||
'fieldtype': u'Int',
|
||||
'label': u'Mail Port'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cb0',
|
||||
'fieldtype': u'Column Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Set Login and Password if authentication is required.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'mail_login',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Login Id'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'mail_password',
|
||||
'fieldtype': u'Password',
|
||||
'label': u'Mail Password'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'System generated mails will be sent from this email id.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'auto_email_id',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Auto Email Id'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'Set the POP3 email settings to pull emails directly from a mailbox and create Support Tickets',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'support_ticket_mail_settings',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Support Ticket Mail Settings'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'To automatically create Support Tickets from your incoming mail, set your POP3 settings here. You must ideally create a separate email id for the erp system so that all emails will be synced into the system from that mail id. If you are not sure, please contact your EMail Provider.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'section_break0',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Incoming Mail Setting'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Check this to pull emails from your mailbox',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sync_support_mails',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Sync Support Mails'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Your support email id - must be a valid email - this is where your emails will come!',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'support_email',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Support Email'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'POP3 mail server (e.g. pop.gmail.com)',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'support_host',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'POP3 Mail Server'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'support_use_ssl',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Use SSL'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'support_username',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'User Name'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'support_password',
|
||||
'fieldtype': u'Password',
|
||||
'label': u'Support Password'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cb1',
|
||||
'fieldtype': u'Column Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Signature to be appended at the end of every email',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'support_signature',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Signature'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'1',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'send_autoreply',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Send Autoreply'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Autoreply when a new mail is received',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'support_autoreply',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Custom Autoreply Message'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/features_setup/__init__.py
Normal file
1
setup/doctype/features_setup/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
30
setup/doctype/features_setup/features_setup.py
Normal file
30
setup/doctype/features_setup/features_setup.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
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])
|
||||
341
setup/doctype/features_setup/features_setup.txt
Normal file
341
setup/doctype/features_setup/features_setup.txt
Normal file
@@ -0,0 +1,341 @@
|
||||
# DocType, Features Setup
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-13 11:56:31',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-06-07 18:41:50',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1323840127',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'name_case': u'Title Case',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 1,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Features Setup',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Features Setup',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Features Setup
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Features Setup'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Administrator'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'materials',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Materials'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'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': u'DocField',
|
||||
'fieldname': u'fs_item_serial_nos',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Item Serial Nos'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'To track items in sales and purchase documents with batch nos<br><b>Preferred Industry: Chemicals etc</b>',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_item_batch_nos',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Item Batch Nos'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'To track brand name in the following documents<br>\nDelivery Note, Enuiry, Purchase Request, Item, Purchase Order, Purchase Voucher, Purchaser Receipt, Quotation, Sales Invoice, Sales BOM, Sales Order, Serial No',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_brands',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Brands'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'To track items using barcode. You will be able to enter items in Delivery Note and Sales Invoice by scanning barcode of item.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_item_barcode',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Item Barcode'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'1. To maintain the customer wise item code and to make them searchable based on their code use this option',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_item_advanced',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Item Advanced'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'If Sale BOM is defined, the actual BOM of the Pack is displayed as table.\nAvailable in Delivery Note and Sales Order',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_packing_details',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Packing Detials'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'To get Item Group in details table',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_item_group_in_details',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Item Groups in Details'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sales_and_purchase',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Sales and Purchase'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'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': u'DocField',
|
||||
'fieldname': u'fs_exports',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Exports'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'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': u'DocField',
|
||||
'fieldname': u'fs_imports',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Imports'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Field available in Delivery Note, Quotation, Sales Invoice, Sales Order',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_discounts',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Sales Discounts'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Discount Fields will be available in Purchase Order, Purchase Receipt, Purchase Invoice',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_purchase_discounts',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Purchase Discounts'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'To track any installation or commissioning related work after sales',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_after_sales_installations',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'After Sale Installations'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'Available in \nBOM, Delivery Note, Purchase Invoice, Production Order, Purchase Order, Purchase Receipt, Sales Invoice, Sales Order, Stock Entry, Timesheet',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_projects',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Projects'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'If you have Sales Team and Sale Partners (Channel Partners) they can be tagged and maintain their contribution in the sales activity',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_sales_extras',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Sales Extras'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'accounts',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Accounts'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Check if you need automatic recurring invoices. After submitting any sales invoice, Recurring section will be visible.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_recurring_invoice',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Recurring Invoice'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break2',
|
||||
'fieldtype': u'Column Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'To enable <b>Point of Sale</b> features',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_pos',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Point of Sale'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'production',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Production'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'If you involve in manufacturing activity<br>\nEnables item <b>Is Manufactured</b>',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_manufacturing',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Manufacturing'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break3',
|
||||
'fieldtype': u'Column Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'If you follow Quality Inspection<br>\nEnables item QA Required and QA No in Purchase Receipt',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_quality',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Quality'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'miscelleneous',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Miscelleneous'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'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': u'DocField',
|
||||
'fieldname': u'fs_page_break',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Page Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break4',
|
||||
'fieldtype': u'Column Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Enables <b>More Info.</b> in all documents',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fs_more_info',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'More Info'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/global_defaults/__init__.py
Normal file
1
setup/doctype/global_defaults/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
22
setup/doctype/global_defaults/global_defaults.js
Normal file
22
setup/doctype/global_defaults/global_defaults.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Validate
|
||||
cur_frm.cscript.validate = function(doc, cdt, cdn) {
|
||||
$c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){
|
||||
sys_defaults = r.message;
|
||||
});
|
||||
}
|
||||
72
setup/doctype/global_defaults/global_defaults.py
Normal file
72
setup/doctype/global_defaults/global_defaults.py
Normal file
@@ -0,0 +1,72 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
"""Global Defaults"""
|
||||
import webnotes
|
||||
|
||||
keydict = {
|
||||
"fiscal_year": "current_fiscal_year",
|
||||
'company': 'default_company',
|
||||
'currency': 'default_currency',
|
||||
'price_list_name': 'default_price_list',
|
||||
'price_list_currency': 'default_price_list_currency',
|
||||
'item_group': 'default_item_group',
|
||||
'customer_group': 'default_customer_group',
|
||||
'cust_master_name': 'cust_master_name',
|
||||
'supplier_type': 'default_supplier_type',
|
||||
'supp_master_name': 'supp_master_name',
|
||||
'territory': 'default_territory',
|
||||
'stock_uom': 'default_stock_uom',
|
||||
'fraction_currency': 'default_currency_fraction',
|
||||
'valuation_method': 'default_valuation_method',
|
||||
'date_format': 'date_format',
|
||||
'currency_format':'default_currency_format',
|
||||
'account_url':'account_url',
|
||||
'allow_negative_stock' : 'allow_negative_stock',
|
||||
'maintain_same_rate' : 'maintain_same_rate'
|
||||
}
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def get_bal(self,arg):
|
||||
"""get account balance (??)"""
|
||||
from webnotes.utils import fmt_money, flt
|
||||
bal = webnotes.conn.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]
|
||||
|
||||
def on_update(self):
|
||||
"""update defaults"""
|
||||
|
||||
for key in keydict:
|
||||
webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
|
||||
|
||||
# update year start date and year end date from fiscal_year
|
||||
ysd = webnotes.conn.sql("""select year_start_date from `tabFiscal Year`
|
||||
where name=%s""", self.doc.current_fiscal_year)
|
||||
|
||||
ysd = ysd and ysd[0][0] or ''
|
||||
from webnotes.utils import get_first_day, get_last_day
|
||||
if ysd:
|
||||
webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
|
||||
webnotes.conn.set_default('year_end_date', \
|
||||
get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
|
||||
|
||||
def get_defaults(self):
|
||||
return webnotes.conn.get_defaults()
|
||||
554
setup/doctype/global_defaults/global_defaults.txt
Normal file
554
setup/doctype/global_defaults/global_defaults.txt
Normal file
@@ -0,0 +1,554 @@
|
||||
# DocType, Global Defaults
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-20 14:02:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-05-22 14:11:21',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1323855502',
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'hide_toolbar': 0,
|
||||
'in_create': 1,
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': u'Tabbed',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 1,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Global Defaults',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Global Defaults',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Global Defaults
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Global Defaults'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'All'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 2,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'company',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Company'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_company',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Company',
|
||||
'options': u'Company',
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'current_fiscal_year',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Current Fiscal Year',
|
||||
'options': u'Fiscal Year',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'date_format',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Date Format',
|
||||
'options': u'yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'default': u'INR',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_currency',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Default Currency',
|
||||
'options': u'link:Currency',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_currency_format',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Default Currency Format',
|
||||
'options': u'Lacs\nMillions'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_currency_fraction',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Default Currency Fraction'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'stock',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Stock'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break2',
|
||||
'fieldtype': u'Column Break',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_item_group',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Item Group',
|
||||
'options': u'Item Group'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'ighelp',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'IGHelp',
|
||||
'options': u'<a href="#!Sales Browser/Item Group">To manage Item Groups, click here</a>'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_stock_uom',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Stock UOM',
|
||||
'options': u'UOM'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_valuation_method',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Default Valuation Method',
|
||||
'options': u'FIFO\nMoving Average'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Applicable only if valuation method is moving average',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'allow_negative_stock',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Allow Negative Stock'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_warehouse_type',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Warehouse Type',
|
||||
'options': u'Warehouse Type'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'auto_indent',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Raise Purchase Request when stock reaches re-order level'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'default': u'1',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break3',
|
||||
'fieldtype': u'Column Break',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'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': u'DocField',
|
||||
'fieldname': u'tolerance',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Allowance Percent'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Stock level frozen up to this date, nobody can do / modify entry except authorized person',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'stock_frozen_upto',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Stock Frozen Upto'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Users with this role are allowed to do / modify stock entry before frozen date',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'stock_auth_role',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Authorized Role (Frozen Entry)',
|
||||
'options': u'Role'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'accounts',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Accounts'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Accounting entry frozen up to this date, nobody can do / modify entry except authorized person',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'acc_frozen_upto',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Accounts Frozen Upto'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Users with this role are allowed to do / modify accounting entry before frozen date',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'bde_auth_role',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Authourized Role (Frozen Entry)',
|
||||
'options': u'Role'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'credit_controller',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Credit Controller',
|
||||
'options': u'Role'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break4',
|
||||
'fieldtype': u'Column Break'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'account_info',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'Account Info',
|
||||
'options': u'<div class="help-box">For more accounting defaults, Open <a href="#!List/Company">Company</a></div>'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'selling',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Selling'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'Customer Name',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cust_master_name',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Customer Master created by ',
|
||||
'options': u'Customer Name\nNaming Series'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_customer_group',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Customer Group',
|
||||
'options': u'Customer Group'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cghelp',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'CGHelp',
|
||||
'options': u'<a href="#!Sales Browser/Customer Group">To manage Customer Groups, click here</a>'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_territory',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Territory',
|
||||
'options': u'Territory'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'territoryhelp',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'TerritoryHelp',
|
||||
'options': u'<a href="#!Sales Browser/Territory">To manage Territory, click here</a>'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break5',
|
||||
'fieldtype': u'Column Break',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_price_list',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Price List',
|
||||
'options': u'Price List'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_price_list_currency',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Price List Currency',
|
||||
'options': u'Currency'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'No',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'so_required',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Sales Order Required',
|
||||
'options': u'No\nYes'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'No',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'dn_required',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Delivery Note Required',
|
||||
'options': u'No\nYes'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'buying',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Buying'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_supplier_type',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Supplier Type',
|
||||
'options': u'Supplier Type'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'Supplier Name',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'supp_master_name',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Supplier Master created by ',
|
||||
'options': u'Supplier Name\nNaming Series'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break6',
|
||||
'fieldtype': u'Column Break',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'No',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'po_required',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Purchase Order Required',
|
||||
'options': u'No\nYes'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'No',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'pr_required',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Purchase Receipt Required',
|
||||
'options': u'No\nYes'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'maintain_same_rate',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Maintain same rate throughout purchase cycle'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'hr',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'HR',
|
||||
'options': u'<div style="padding-top: 8px;" class="columnHeading">HR</div>'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Employee record is created using selected field. ',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'emp_created_by',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Employee Records to be created by ',
|
||||
'options': u'\nNaming Series\nEmployee Number'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'system',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'System'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sms_sender_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'SMS Sender Name'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/item_group/__init__.py
Normal file
1
setup/doctype/item_group/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
27
setup/doctype/item_group/item_group.js
Normal file
27
setup/doctype/item_group/item_group.js
Normal file
@@ -0,0 +1,27 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.cscript.set_breadcrumbs = function(barea) {
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(cur_frm.docname);
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!Sales Browser/Item Group">\
|
||||
Item Group Tree</a>');
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!selling-home">Selling</a>');
|
||||
}
|
||||
|
||||
//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`.`name` !="'+doc.item_group_name+'" AND `tabItem Group`.%(key)s LIKE "%s" ORDER BY `tabItem Group`.`name` ASC LIMIT 50';
|
||||
}
|
||||
29
setup/doctype/item_group/item_group.py
Normal file
29
setup/doctype/item_group/item_group.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.model.doclist import getlist
|
||||
from webnotes.utils import flt
|
||||
|
||||
from webnotes.utils.nestedset import DocTypeNestedSet
|
||||
|
||||
class DocType(DocTypeNestedSet):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
self.nsm_parent_field = 'parent_item_group';
|
||||
258
setup/doctype/item_group/item_group.txt
Normal file
258
setup/doctype/item_group/item_group.txt
Normal file
@@ -0,0 +1,258 @@
|
||||
# DocType, Item Group
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-12 11:26:21',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1322549700',
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:item_group_name',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'description': u'Item Classification',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'in_create': 1,
|
||||
'issingle': 0,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'search_fields': u'parent_item_group',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Item Group',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Item Group',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Item Group
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Item Group'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Material Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Material User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Material Master Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'item_group_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Item Group Name',
|
||||
'no_copy': 0,
|
||||
'oldfieldname': u'item_group_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Check this if you want to show in website',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'show_in_website',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Show in Website',
|
||||
'no_copy': 0,
|
||||
'permlevel': 0,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cb0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'parent_item_group',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Parent Item Group',
|
||||
'no_copy': 0,
|
||||
'oldfieldname': u'parent_item_group',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Item Group',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Only leaf nodes are allowed in transaction',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_group',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Has Child Node',
|
||||
'no_copy': 0,
|
||||
'oldfieldname': u'is_group',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'no_copy': 0,
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'lft',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'in_filter': 1,
|
||||
'label': u'lft',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'lft',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'rgt',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'in_filter': 1,
|
||||
'label': u'rgt',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'rgt',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'old_parent',
|
||||
'fieldtype': u'Link',
|
||||
'hidden': 1,
|
||||
'label': u'old_parent',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'old_parent',
|
||||
'oldfieldtype': u'Data',
|
||||
'options': u'Item Group',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': 1,
|
||||
'search_index': 0
|
||||
}
|
||||
]
|
||||
1
setup/doctype/market_segment/__init__.py
Normal file
1
setup/doctype/market_segment/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
77
setup/doctype/market_segment/market_segment.txt
Normal file
77
setup/doctype/market_segment/market_segment.txt
Normal file
@@ -0,0 +1,77 @@
|
||||
# DocType, Market Segment
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:21',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:21',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:segment_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'name_case': u'Title Case',
|
||||
'read_only': 0,
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Market Segment',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# DocType, Market Segment
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Market Segment'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'segment_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Segment Name',
|
||||
'oldfieldname': u'segment_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'details',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Details',
|
||||
'oldfieldname': u'details',
|
||||
'oldfieldtype': u'Text',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
setup/doctype/naming_series/__init__.py
Normal file
1
setup/doctype/naming_series/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
54
setup/doctype/naming_series/naming_series.js
Normal file
54
setup/doctype/naming_series/naming_series.js
Normal file
@@ -0,0 +1,54 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Settings
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn){
|
||||
cur_frm.call_server('get_transactions', '', cur_frm.cscript.update_selects);
|
||||
|
||||
cur_frm.cscript.select_doc_for_series(doc);
|
||||
}
|
||||
|
||||
cur_frm.cscript.update_selects = function(r) {
|
||||
set_field_options('select_doc_for_series', r.message.transactions);
|
||||
set_field_options('prefix', r.message.prefixes);
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.select_doc_for_series = function(doc, cdt, cdn) {
|
||||
cur_frm.toggle_display(['help_html','set_options', 'user_must_always_select', 'update'],
|
||||
doc.select_doc_for_series)
|
||||
|
||||
var callback = function(r, rt){
|
||||
locals[cdt][cdn].set_options = r.message;
|
||||
refresh_field('set_options');
|
||||
if(r.message && r.message.split('\n')[0]=='') {
|
||||
cur_frm.set_value('user_must_always_select', 1)
|
||||
}
|
||||
}
|
||||
|
||||
if(doc.select_doc_for_series)
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'get_options','',callback)
|
||||
}
|
||||
|
||||
cur_frm.cscript.update = function() {
|
||||
cur_frm.call_server('update_series', '', cur_frm.cscript.update_selects)
|
||||
}
|
||||
|
||||
cur_frm.cscript.prefix = function(doc) {
|
||||
cur_frm.call_server('get_current', '', function(r) {
|
||||
refresh_field('current_value');
|
||||
})
|
||||
}
|
||||
137
setup/doctype/naming_series/naming_series.py
Normal file
137
setup/doctype/naming_series/naming_series.py
Normal file
@@ -0,0 +1,137 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cint, cstr
|
||||
from webnotes import msgprint, errprint
|
||||
import webnotes.model.doctype
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def get_transactions(self, arg=None):
|
||||
return {
|
||||
"transactions": "\n".join([''] + [i[0] for i in sql("""select `tabDocField`.`parent`
|
||||
FROM `tabDocField`, `tabDocType` WHERE `tabDocField`.`fieldname` = 'naming_series'
|
||||
and `tabDocType`.name=`tabDocField`.parent order by `tabDocField`.parent""")]),
|
||||
"prefixes": "\n".join([''] + [i[0] for i in sql("""select name from tabSeries""")])}
|
||||
|
||||
def scrub_options_list(self, ol):
|
||||
options = filter(lambda x: x, [cstr(n.upper()).strip() for n in ol])
|
||||
return options
|
||||
|
||||
def update_series(self, arg=None):
|
||||
"""update series list"""
|
||||
self.check_duplicate()
|
||||
series_list = self.doc.set_options.split("\n")
|
||||
|
||||
# set in doctype
|
||||
self.set_series_for(self.doc.select_doc_for_series, series_list)
|
||||
|
||||
# create series
|
||||
map(self.insert_series, series_list)
|
||||
|
||||
msgprint('Series Updated')
|
||||
|
||||
return self.get_transactions()
|
||||
|
||||
def set_series_for(self, doctype, ol):
|
||||
options = self.scrub_options_list(ol)
|
||||
|
||||
# validate names
|
||||
for i in options: self.validate_series_name(i)
|
||||
|
||||
if self.doc.user_must_always_select:
|
||||
options = [''] + options
|
||||
default = ''
|
||||
else:
|
||||
default = options[0]
|
||||
|
||||
# update in property setter
|
||||
from webnotes.model.doc import Document
|
||||
prop_dict = {'options': "\n".join(options), 'default': default}
|
||||
for prop in prop_dict:
|
||||
ps_exists = webnotes.conn.sql("""SELECT name FROM `tabProperty Setter`
|
||||
WHERE doc_type = %s AND field_name = 'naming_series'
|
||||
AND property = %s""", (doctype, prop))
|
||||
if ps_exists:
|
||||
ps = Document('Property Setter', ps_exists[0][0])
|
||||
ps.value = prop_dict[prop]
|
||||
ps.save()
|
||||
else:
|
||||
ps = Document('Property Setter', fielddata = {
|
||||
'doctype_or_field': 'DocField',
|
||||
'doc_type': doctype,
|
||||
'field_name': 'naming_series',
|
||||
'property': prop,
|
||||
'value': prop_dict[prop],
|
||||
'property_type': 'Select',
|
||||
'select_doctype': doctype
|
||||
})
|
||||
ps.save(1)
|
||||
|
||||
self.doc.set_options = "\n".join(options)
|
||||
|
||||
from webnotes.utils.cache import CacheItem
|
||||
CacheItem(doctype).clear()
|
||||
|
||||
def check_duplicate(self):
|
||||
from core.doctype.doctype.doctype import DocType
|
||||
dt = DocType()
|
||||
|
||||
parent = sql("select parent from `tabDocField` where fieldname='naming_series' and parent != %s", self.doc.select_doc_for_series)
|
||||
sr = ([webnotes.model.doctype.get_property(p[0], 'options', 'naming_series'), p[0]] for p in parent)
|
||||
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=''):
|
||||
sr = webnotes.model.doctype.get_property(self.doc.select_doc_for_series,
|
||||
'options', 'naming_series')
|
||||
return sr
|
||||
|
||||
def get_current(self, arg=None):
|
||||
"""get series current"""
|
||||
self.doc.current_value = webnotes.conn.sql("""select current from tabSeries where name=%s""",
|
||||
self.doc.prefix)[0][0]
|
||||
|
||||
def insert_series(self, series):
|
||||
"""insert series if missing"""
|
||||
if not webnotes.conn.exists('Series', series):
|
||||
sql("insert into tabSeries (name, current) values (%s,0)", (series))
|
||||
|
||||
def update_series_start(self):
|
||||
if self.doc.prefix:
|
||||
self.insert_series(self.doc.prefix)
|
||||
sql("update `tabSeries` set current = '%s' where name = '%s'" % (self.doc.current_value,self.doc.prefix))
|
||||
msgprint("Series Updated Successfully")
|
||||
else:
|
||||
msgprint("Please select prefix first")
|
||||
193
setup/doctype/naming_series/naming_series.txt
Normal file
193
setup/doctype/naming_series/naming_series.txt
Normal file
@@ -0,0 +1,193 @@
|
||||
# DocType, Naming Series
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-12 15:59:52',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Set prefix for numbering series on your transactions',
|
||||
'doctype': 'DocType',
|
||||
'hide_heading': 0,
|
||||
'hide_toolbar': 1,
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': u'Tray',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Naming Series',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Naming Series',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Naming Series
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Naming Series'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'System Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Guest'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'Set prefix for numbering series on your transactions',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'setup_series',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Setup Series'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'select_doc_for_series',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Select Transaction'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'help_html',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'Help HTML',
|
||||
'options': u'<div class="help-box">\nEdit list of Series in the box below. Each Series Prefix on a new line.<br><br>\nAllowed special characters are "/" and "-"<br>\nExamples:<br>\nINV-<br>\nINV-10-<br>\nINVK-<br>\n</div>'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'set_options',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Series List for this Transaction'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'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': u'DocField',
|
||||
'fieldname': u'user_must_always_select',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'User must always select'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'update',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Update'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Change the starting / current sequence number of an existing series.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'update_series',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Update Series'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'prefix',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Prefix'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'This is the number of the last created transaction with this prefix',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'current_value',
|
||||
'fieldtype': u'Int',
|
||||
'label': u'Current Value'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'update_series_start',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Update Series Number',
|
||||
'options': u'update_series_start'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/naming_series_options/__init__.py
Normal file
1
setup/doctype/naming_series_options/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
@@ -0,0 +1,82 @@
|
||||
# DocType, Naming Series Options
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:21',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:21',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'__NSO.#####',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 0,
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Naming Series Options',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Naming Series Options',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocType, Naming Series Options
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Naming Series Options'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'doc_type',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Doc Type',
|
||||
'oldfieldname': u'doc_type',
|
||||
'oldfieldtype': u'Data',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'series_options',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Series Options',
|
||||
'oldfieldname': u'series_options',
|
||||
'oldfieldtype': u'Text'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/notification_control/__init__.py
Normal file
1
setup/doctype/notification_control/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
66
setup/doctype/notification_control/notification_control.js
Normal file
66
setup/doctype/notification_control/notification_control.js
Normal file
@@ -0,0 +1,66 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.cscript.select_transaction = function(doc, cdt, cdn) {
|
||||
if(doc.select_transaction) {
|
||||
var callback = function(r,rt) {
|
||||
var doc = locals[cdt][cdn];
|
||||
doc.custom_message = r.message;
|
||||
refresh_field('custom_message');
|
||||
}
|
||||
$c_obj(make_doclist(cdt, cdn),'get_message',doc.select_transaction, callback)
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.notify = function(doc, args) {
|
||||
var doc = locals[doc.doctype][doc.name];
|
||||
$c_obj(make_doclist(doc.doctype, doc.name), 'get_formatted_message', {
|
||||
type: args['type'],
|
||||
doctype: args['doctype'],
|
||||
contact_name: args['contact_name'] || doc.contact_display
|
||||
}, function(r, rt) {
|
||||
if(!r.exc) {
|
||||
var res = JSON.parse(r.message);
|
||||
var send_from = (function() {
|
||||
if(user!='Administrator') {
|
||||
return user;
|
||||
} else {
|
||||
return (wn.control_panel.auto_email_id ||
|
||||
'ERPNext Notification<automail@erpnext.com>');
|
||||
}
|
||||
})();
|
||||
if(res.send) {
|
||||
var print_heading = (doc.select_print_heading || args['type'])
|
||||
if(validate_email(args['send_to'] || doc.contact_email || '')) {
|
||||
sendmail(
|
||||
args['send_to'] || doc.contact_email,
|
||||
send_from,
|
||||
send_from,
|
||||
doc.company + " - " + print_heading + " - " + doc.name,
|
||||
res.message,
|
||||
res.print_format
|
||||
);
|
||||
msgprint('This ' + print_heading + ' is being sent to <b>'
|
||||
+ (args['send_to'] || doc.contact_email) + '</b><br />...');
|
||||
} else {
|
||||
msgprint('Invalid/Missing Email Address of Contact. Auto notification for '
|
||||
+ print_heading + ' not sent.');
|
||||
}
|
||||
}
|
||||
}
|
||||
//console.log(JSON.parse(r.message));
|
||||
});
|
||||
}
|
||||
108
setup/doctype/notification_control/notification_control.py
Normal file
108
setup/doctype/notification_control/notification_control.py
Normal file
@@ -0,0 +1,108 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import validate_email_add, cint, cstr
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
# 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)
|
||||
|
||||
|
||||
def get_formatted_message(self, args):
|
||||
"""
|
||||
args can contain:
|
||||
* type
|
||||
* doctype
|
||||
* contact_name
|
||||
"""
|
||||
import json
|
||||
args = json.loads(args)
|
||||
res = {
|
||||
'send': 0,
|
||||
'message': self.prepare_message(args),
|
||||
'print_format': self.get_default_print_format(args)
|
||||
}
|
||||
|
||||
dt_small = args.get('doctype').replace(' ', '_').lower()
|
||||
if cint(self.doc.fields.get(dt_small)):
|
||||
res['send'] = 1
|
||||
|
||||
return json.dumps(res)
|
||||
|
||||
|
||||
def prepare_message(self, args):
|
||||
"""
|
||||
Prepares message body
|
||||
"""
|
||||
if args.get('type'):
|
||||
msg_dict = {}
|
||||
msg_dict['message'] = args.get('message') or self.get_message(args.get('type'))
|
||||
msg_dict['company'] = Document('Control Panel', 'Control Panel').company_name
|
||||
msg_dict['salutation'] = "Hi" + (args.get('contact_name') and (" " + args.get('contact_name')) or "")
|
||||
msg_dict['send_from'] = webnotes.conn.sql("""\
|
||||
SELECT CONCAT_WS(' ', first_name, last_name)
|
||||
FROM `tabProfile`
|
||||
WHERE name = %s""", webnotes.session['user'], as_list=1)[0][0] or ''
|
||||
|
||||
return """\
|
||||
<div>
|
||||
%(salutation)s,
|
||||
|
||||
%(message)s
|
||||
|
||||
Thanks,
|
||||
%(send_from)s
|
||||
%(company)s
|
||||
</div>""" % msg_dict
|
||||
|
||||
else: return ""
|
||||
|
||||
|
||||
def get_default_print_format(self, args):
|
||||
"""
|
||||
Get default print format from doclayer
|
||||
"""
|
||||
doclayer = get_obj('Customize Form', 'Customize Form')
|
||||
doclayer.doc.doc_type = args.get('doctype')
|
||||
doclayer.get()
|
||||
if doclayer.doc.default_print_format:
|
||||
return doclayer.doc.default_print_format
|
||||
else: return 'Standard'
|
||||
273
setup/doctype/notification_control/notification_control.txt
Normal file
273
setup/doctype/notification_control/notification_control.txt
Normal file
@@ -0,0 +1,273 @@
|
||||
# DocType, Notification Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-12 16:20:36',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Send automatic emails to Contacts on Submitting transactions.',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Notification Control',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Notification Control',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Notification Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Notification Control'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Guest',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'When any of the checked transactions are "Submitted", an email is automatically sent to the associated "Contact" in that transaction, with the transaction as an attachment.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'send_autonotification_for',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Send Email Automatically on Submission of'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sales',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Sales',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'quotation',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Quotation'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sales_order',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Sales Order'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'delivery_note',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Delivery Note'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sales_invoice',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Sales Invoice'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'purchase',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Purchase',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'purchase_order',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Purchase Order'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'purchase_receipt',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Purchase Receipt'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'expense_claim',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Expense Claim'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Customize the introductory text that goes as a part of that email. Each transaction has a separate introductory text.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'customize_the_notification',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Customize the Notification'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'select_transaction',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Select Transaction',
|
||||
'options': u'\nQuotation\nSales Order\nDelivery Note\nSales Invoice\nPurchase Order\nPurchase Receipt\nExpense Claim\nExpense Claim Approved\nExpense Claim Rejected',
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'custom_message',
|
||||
'fieldtype': u'Text Editor',
|
||||
'label': u'Custom Message'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'update',
|
||||
'fieldtype': u'Button',
|
||||
'label': u'Update',
|
||||
'options': u'set_message'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'quotation_message',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'Quotation Message',
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sales_order_message',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'Sales Order Message',
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'delivery_note_message',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'Delivery Note Message',
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sales_invoice_message',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'Sales Invoice Message',
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'purchase_order_message',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'Purchase Order Message',
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'purchase_receipt_message',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'Purchase Receipt Message',
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'expense_claim_approved_message',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'Expense Claim Approved Message',
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'expense_claim_rejected_message',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'Expense Claim Rejected Message',
|
||||
'print_hide': 1
|
||||
}
|
||||
]
|
||||
1
setup/doctype/period/__init__.py
Normal file
1
setup/doctype/period/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
26
setup/doctype/period/period.js
Normal file
26
setup/doctype/period/period.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
115
setup/doctype/period/period.txt
Normal file
115
setup/doctype/period/period.txt
Normal file
@@ -0,0 +1,115 @@
|
||||
# DocType, Period
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:22',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:22',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'nabin@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': u'field:period_name',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'in_create': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Period',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Period',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': u'System Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocType, Period
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Period'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'period_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Period Name',
|
||||
'oldfieldname': u'period_name',
|
||||
'oldfieldtype': u'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'start_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'Start Date',
|
||||
'oldfieldname': u'start_date',
|
||||
'oldfieldtype': u'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'end_date',
|
||||
'fieldtype': u'Date',
|
||||
'label': u'End Date',
|
||||
'oldfieldname': u'end_date',
|
||||
'oldfieldtype': u'Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'period_type',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Period Type',
|
||||
'oldfieldname': u'period_type',
|
||||
'oldfieldtype': u'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'fiscal_year',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Fiscal Year',
|
||||
'oldfieldname': u'fiscal_year',
|
||||
'oldfieldtype': u'Data'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/period_control/__init__.py
Normal file
1
setup/doctype/period_control/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
78
setup/doctype/period_control/period_control.py
Normal file
78
setup/doctype/period_control/period_control.py
Normal file
@@ -0,0 +1,78 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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
|
||||
32
setup/doctype/period_control/period_control.txt
Normal file
32
setup/doctype/period_control/period_control.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
# DocType, Period Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:22',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:22',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'nabin@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 36
|
||||
},
|
||||
|
||||
# DocType, Period Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Period Control'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/permission_control/__init__.py
Normal file
1
setup/doctype/permission_control/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
220
setup/doctype/permission_control/permission_control.py
Normal file
220
setup/doctype/permission_control/permission_control.py
Normal file
@@ -0,0 +1,220 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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', 'Core')
|
||||
OR name IN ('Contact', 'Address'))
|
||||
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):
|
||||
import webnotes.model.doctype
|
||||
doclist = webnotes.model.doctype.get(doctype, form=0)
|
||||
|
||||
ptype = [{
|
||||
'role': perm.role,
|
||||
'permlevel': cint(perm.permlevel),
|
||||
'read': cint(perm.read),
|
||||
'write': cint(perm.write),
|
||||
'create': cint(perm.create),
|
||||
'cancel': cint(perm.cancel),
|
||||
'submit': cint(perm.submit),
|
||||
'amend': cint(perm.amend),
|
||||
'match': perm.match
|
||||
} for perm in sorted(doclist,
|
||||
key=lambda d: [d.fields.get('permlevel'),
|
||||
d.fields.get('role')]) if perm.doctype=='DocPerm']
|
||||
|
||||
fl = ['', 'owner'] + [d.fieldname for d in doclist \
|
||||
if d.doctype=='DocField' and ((d.fieldtype=='Link' \
|
||||
and cstr(d.options)!='') or (d.fieldtype=='Select' and
|
||||
'link:' in cstr(d.options).lower()))]
|
||||
|
||||
return {
|
||||
'perms':ptype,
|
||||
'fields':fl,
|
||||
'is_submittable': doclist[0].fields.get('is_submittable')
|
||||
}
|
||||
|
||||
# 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() # ['Opportunity','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))
|
||||
|
||||
|
||||
from webnotes.utils.cache import CacheItem
|
||||
CacheItem(parent).clear()
|
||||
|
||||
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
|
||||
|
||||
33
setup/doctype/permission_control/permission_control.txt
Normal file
33
setup/doctype/permission_control/permission_control.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
# DocType, Permission Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:22',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:22',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'saumil@webnotestech.com'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 15
|
||||
},
|
||||
|
||||
# DocType, Permission Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Permission Control'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/price_list/__init__.py
Normal file
1
setup/doctype/price_list/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
47
setup/doctype/price_list/price_list.js
Normal file
47
setup/doctype/price_list/price_list.js
Normal file
@@ -0,0 +1,47 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
if(doc.__islocal) {
|
||||
cur_frm.set_intro("Save this list to begin.");
|
||||
return;
|
||||
}
|
||||
if(!doc.file_list) {
|
||||
cur_frm.set_intro('<p>1. Click on "Download Template" \
|
||||
to download the template of all Items.</p>'
|
||||
+'<p>2. Update prices and Currency.</p>'
|
||||
+'<p>3. Save it as a CSV (.csv) file.</p>'
|
||||
+'<p>4. Upload the file.</p>');
|
||||
|
||||
cur_frm.add_custom_button('Download Template', function() {
|
||||
$c_obj_csv(cur_frm.get_doclist(), 'download_template');
|
||||
}, 'icon-download')
|
||||
|
||||
cur_frm.add_custom_button('Upload Price List', function() {
|
||||
cur_frm.attachments.add_attachment();
|
||||
}, 'icon-upload')
|
||||
|
||||
|
||||
} else {
|
||||
cur_frm.set_intro('To update prices from the attachment, click on "Update Prices". \
|
||||
To reset prices, delete the attachment (in the sidebar) and upload again.');
|
||||
|
||||
// Update Prices
|
||||
cur_frm.add_custom_button('Update Prices', function() {
|
||||
cur_frm.call_server('update_prices');
|
||||
}, 'icon-refresh')
|
||||
}
|
||||
}
|
||||
105
setup/doctype/price_list/price_list.py
Normal file
105
setup/doctype/price_list/price_list.py
Normal file
@@ -0,0 +1,105 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes import msgprint
|
||||
|
||||
|
||||
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 webnotes.conn.sql("select name from tabCurrency where name=%s", currency):
|
||||
self.cl.append(currency)
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
def download_template(self, arg=None):
|
||||
"""download 3 column template with all Items"""
|
||||
default_currency = webnotes.conn.get_default('currency')
|
||||
item_list = webnotes.conn.sql("""select name from tabItem where
|
||||
(ifnull(is_sales_item,'')='Yes' or ifnull(is_service_item,'')='Yes')""")
|
||||
data = [self.get_price(i[0], default_currency) for i in item_list]
|
||||
return [['Item', 'Rate', 'Currency']] + data
|
||||
|
||||
def get_price(self, item, default_currency):
|
||||
rate = webnotes.conn.sql("""select ref_rate, ref_currency from `tabItem Price`
|
||||
where parent=%s and price_list_name=%s""", (item, self.doc.name))
|
||||
return [item, rate and rate[0][0] or 0, rate and rate[0][1] or default_currency]
|
||||
|
||||
# update prices in Price List
|
||||
def update_prices(self):
|
||||
from core.page.data_import_tool.data_import_tool import read_csv_content
|
||||
|
||||
data = read_csv_content(self.get_csv_data())
|
||||
webnotes.conn.auto_commit_on_many_writes = 1
|
||||
|
||||
updated = 0
|
||||
|
||||
for line in data:
|
||||
if line and len(line)==3 and line[0]!='Item':
|
||||
# if item exists
|
||||
if webnotes.conn.sql("select name from tabItem where name=%s", line[0]):
|
||||
if self.is_currency_valid(line[2]):
|
||||
# if price exists
|
||||
ref_ret_detail = webnotes.conn.sql("select name from `tabItem Price` where parent=%s and price_list_name=%s and ref_currency=%s", \
|
||||
(line[0], self.doc.name, line[2]))
|
||||
if ref_ret_detail:
|
||||
webnotes.conn.sql("update `tabItem Price` set ref_rate=%s where name=%s", (line[1], ref_ret_detail[0][0]))
|
||||
else:
|
||||
d = Document('Item Price')
|
||||
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])
|
||||
|
||||
msgprint("<b>%s</b> items updated" % updated)
|
||||
webnotes.conn.auto_commit_on_many_writes = 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]
|
||||
|
||||
try:
|
||||
from webnotes.utils import file_manager
|
||||
fn, content = file_manager.get_file(fid)
|
||||
except Exception, e:
|
||||
webnotes.msgprint("Unable to open attached file. Please try again.")
|
||||
raise e
|
||||
|
||||
return content
|
||||
132
setup/doctype/price_list/price_list.txt
Normal file
132
setup/doctype/price_list/price_list.txt
Normal file
@@ -0,0 +1,132 @@
|
||||
# DocType, Price List
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-11 17:35:10',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1303100817',
|
||||
'allow_attach': 1,
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:price_list_name',
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Maintain multiple selling rates for the same **Item** using **Price Lists**. You can upload / edit multiple prices by downloading and uploading the template.',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'max_attachments': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Price List',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Price List',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocType, Price List
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Price List'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales User',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales User',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales Master Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'price_list_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Price List Name',
|
||||
'oldfieldname': u'price_list_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'file_list',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'File List'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/print_heading/__init__.py
Normal file
1
setup/doctype/print_heading/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
26
setup/doctype/print_heading/print_heading.js
Normal file
26
setup/doctype/print_heading/print_heading.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
39
setup/doctype/print_heading/print_heading.py
Normal file
39
setup/doctype/print_heading/print_heading.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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
|
||||
99
setup/doctype/print_heading/print_heading.txt
Normal file
99
setup/doctype/print_heading/print_heading.txt
Normal file
@@ -0,0 +1,99 @@
|
||||
# DocType, Print Heading
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:22',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:22',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1294312215',
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:print_heading',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'search_fields': u'print_heading',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 27
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Print Heading',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Print Heading',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': u'All',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Print Heading
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Print Heading'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'print_heading',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Print Heading',
|
||||
'oldfieldname': u'print_heading',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'description',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Description',
|
||||
'oldfieldname': u'description',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 0,
|
||||
'width': u'300px'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/quotation_lost_reason/__init__.py
Normal file
1
setup/doctype/quotation_lost_reason/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
26
setup/doctype/quotation_lost_reason/quotation_lost_reason.js
Normal file
26
setup/doctype/quotation_lost_reason/quotation_lost_reason.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
# DocType, Quotation Lost Reason
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:22',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:22',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:order_lost_reason',
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 4
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Quotation Lost Reason',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Quotation Lost Reason',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Quotation Lost Reason
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Quotation Lost Reason'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Sales Master Manager',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'order_lost_reason',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Quotation Lost Reason',
|
||||
'oldfieldname': u'order_lost_reason',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
}
|
||||
]
|
||||
1
setup/doctype/sales_browser_control/__init__.py
Normal file
1
setup/doctype/sales_browser_control/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
232
setup/doctype/sales_browser_control/sales_browser_control.py
Normal file
232
setup/doctype/sales_browser_control/sales_browser_control.py
Normal file
@@ -0,0 +1,232 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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 = 'Global Defaults' 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 and r['action'] != 'Create':
|
||||
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'
|
||||
@@ -0,0 +1,30 @@
|
||||
# DocType, Sales Browser Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:23',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:23',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 159
|
||||
},
|
||||
|
||||
# DocType, Sales Browser Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Sales Browser Control'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/sales_partner/__init__.py
Normal file
1
setup/doctype/sales_partner/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
101
setup/doctype/sales_partner/sales_partner.js
Normal file
101
setup/doctype/sales_partner/sales_partner.js
Normal file
@@ -0,0 +1,101 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.require('erpnext/setup/doctype/contact_control/contact_control.js');
|
||||
|
||||
cur_frm.cscript.onload = function(doc,dt,dn){
|
||||
// history doctypes and scripts
|
||||
cur_frm.history_dict = {
|
||||
'Sales Order' : 'cur_frm.cscript.make_so_list(this.body, this.doc)',
|
||||
'Delivery Note' : 'cur_frm.cscript.make_dn_list(this.body, this.doc)',
|
||||
'Sales Invoice' : 'cur_frm.cscript.make_si_list(this.body, this.doc)'
|
||||
}
|
||||
|
||||
// make contact, history list body
|
||||
//cur_frm.cscript.make_cl_body();
|
||||
cur_frm.cscript.make_hl_body();
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,dt,dn){
|
||||
|
||||
if(doc.__islocal){
|
||||
hide_field(['address_html', 'contact_html']);
|
||||
//cur_frm.cscript.set_cl_msg(doc);
|
||||
//cur_frm.cscript.set_hl_msg(doc);
|
||||
}
|
||||
else{
|
||||
unhide_field(['address_html', 'contact_html']);
|
||||
// make lists
|
||||
cur_frm.cscript.make_address(doc,dt,dn);
|
||||
cur_frm.cscript.make_contact(doc,dt,dn);
|
||||
cur_frm.cscript.make_history(doc,dt,dn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.make_address = function() {
|
||||
if(!cur_frm.address_list) {
|
||||
cur_frm.address_list = new wn.ui.Listing({
|
||||
parent: cur_frm.fields_dict['address_html'].wrapper,
|
||||
page_length: 2,
|
||||
new_doctype: "Address",
|
||||
get_query: function() {
|
||||
return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where sales_partner='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc"
|
||||
},
|
||||
as_dict: 1,
|
||||
no_results_message: 'No addresses created',
|
||||
render_row: function(wrapper, data) {
|
||||
$(wrapper).css('padding','5px 0px');
|
||||
var link = $ln(wrapper,cstr(data.name), function() { loaddoc("Address", this.dn); }, {fontWeight:'bold'});
|
||||
link.dn = data.name
|
||||
|
||||
$a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_address ? '[Primary]' : '') + (data.is_shipping_address ? '[Shipping]' : ''));
|
||||
$a(wrapper,'div','',{marginTop:'5px', color:'#555'}, data.address_line1 + '<br />' + (data.address_line2 ? data.address_line2 + '<br />' : '') + data.city + '<br />' + (data.state ? data.state + ', ' : '') + data.country + '<br />' + (data.pincode ? 'Pincode: ' + data.pincode + '<br />' : '') + (data.phone ? 'Tel: ' + data.phone + '<br />' : '') + (data.fax ? 'Fax: ' + data.fax + '<br />' : '') + (data.email_id ? 'Email: ' + data.email_id + '<br />' : ''));
|
||||
}
|
||||
});
|
||||
}
|
||||
cur_frm.address_list.run();
|
||||
}
|
||||
|
||||
cur_frm.cscript.make_contact = function() {
|
||||
if(!cur_frm.contact_list) {
|
||||
cur_frm.contact_list = new wn.ui.Listing({
|
||||
parent: cur_frm.fields_dict['contact_html'].wrapper,
|
||||
page_length: 2,
|
||||
new_doctype: "Contact",
|
||||
get_query: function() {
|
||||
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where sales_partner='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"
|
||||
},
|
||||
as_dict: 1,
|
||||
no_results_message: 'No contacts created',
|
||||
render_row: function(wrapper, data) {
|
||||
$(wrapper).css('padding', '5px 0px');
|
||||
var link = $ln(wrapper, cstr(data.name), function() { loaddoc("Contact", this.dn); }, {fontWeight:'bold'});
|
||||
link.dn = data.name
|
||||
|
||||
$a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_contact ? '[Primary]' : ''));
|
||||
$a(wrapper,'div', '',{marginTop:'5px', color:'#555'}, data.first_name + (data.last_name ? ' ' + data.last_name + '<br />' : '<br>') + (data.phone ? 'Tel: ' + data.phone + '<br />' : '') + (data.mobile_no ? 'Mobile: ' + data.mobile_no + '<br />' : '') + (data.email_id ? 'Email: ' + data.email_id + '<br />' : '') + (data.department ? 'Department: ' + data.department + '<br />' : '') + (data.designation ? 'Designation: ' + data.designation + '<br />' : ''));
|
||||
}
|
||||
});
|
||||
}
|
||||
cur_frm.contact_list.run();
|
||||
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['partner_target_details'].grid.get_field("item_group").get_query = function(doc, dt, dn) {
|
||||
return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
|
||||
}
|
||||
|
||||
65
setup/doctype/sales_partner/sales_partner.py
Normal file
65
setup/doctype/sales_partner/sales_partner.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
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, getchildren, make_autoname
|
||||
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.prefix = is_testing and 'test' or 'tab'
|
||||
|
||||
def validate(self):
|
||||
import string
|
||||
|
||||
if not (self.doc.address_line1) and not (self.doc.address_line2) and not (self.doc.city) and not (self.doc.state) and not (self.doc.country) and not (self.doc.pincode):
|
||||
return "Please enter address"
|
||||
|
||||
else:
|
||||
address =["address_line1", "address_line2", "city", "state", "country", "pincode"]
|
||||
comp_address=''
|
||||
for d in address:
|
||||
if self.doc.fields[d]:
|
||||
comp_address += self.doc.fields[d] + "\n"
|
||||
self.doc.address = comp_address
|
||||
|
||||
def check_state(self):
|
||||
return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
|
||||
|
||||
def get_contacts(self,nm):
|
||||
if nm:
|
||||
contact_details =convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where sales_partner = '%s'"%nm))
|
||||
return contact_details
|
||||
else:
|
||||
return ''
|
||||
328
setup/doctype/sales_partner/sales_partner.txt
Normal file
328
setup/doctype/sales_partner/sales_partner.txt
Normal file
@@ -0,0 +1,328 @@
|
||||
# DocType, Sales Partner
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-12 11:22:15',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1322549700',
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:partner_name',
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'description': u'A **Sales Partner** is a third party distributor / dealer / commission agent / affiliate / reseller who sells the companies products for a commission. This is useful if you make the end sale to the **Customer**, involving your **Sales Partner**.\n\nIf you sell to your **Sales Partner** who in-turn sells it to the **Customer**, then you must make a **Customer** instead.',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'in_create': 0,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 0,
|
||||
'section_style': u'Tabbed',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Sales Partner',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Sales Partner',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Sales Partner
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Sales Partner'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales Master Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales Master Manager',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'System Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'basic_info',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Sales Partner Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'partner_name',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Sales Partner Name',
|
||||
'oldfieldname': u'partner_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'partner_type',
|
||||
'fieldtype': u'Select',
|
||||
'in_filter': 1,
|
||||
'label': u'Partner Type',
|
||||
'oldfieldname': u'partner_type',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nChannel Partner\nDistributor\nDealer\nAgent\nRetailer\nImplementation Partner\nReseller',
|
||||
'permlevel': 0,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'commission_rate',
|
||||
'fieldtype': u'Currency',
|
||||
'label': u'Commission Rate',
|
||||
'oldfieldname': u'commission_rate',
|
||||
'oldfieldtype': u'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'territory',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Territory',
|
||||
'options': u'Territory',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'address_contacts',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Address & Contacts',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u'eval:doc.__islocal',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'address_desc',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'Address Desc',
|
||||
'options': u'<em>Addresses will appear only when you save the customer</em>',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'address_html',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'Address HTML',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u'eval:doc.__islocal',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'contact_desc',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'Contact Desc',
|
||||
'options': u'<em>Contact Details will appear only when you save the customer</em>',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'contact_html',
|
||||
'fieldtype': u'HTML',
|
||||
'label': u'Contact HTML',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'partner_target_details_section_break',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Sales Partner Target',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'partner_target_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Partner Target Detail',
|
||||
'oldfieldname': u'partner_target_details',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Target Detail',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Select Budget Distribution to unevenly distribute targets across months.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'distribution_id',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Target Distribution',
|
||||
'oldfieldname': u'distribution_id',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Budget Distribution',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
1
setup/doctype/sales_person/__init__.py
Normal file
1
setup/doctype/sales_person/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
56
setup/doctype/sales_person/sales_person.js
Normal file
56
setup/doctype/sales_person/sales_person.js
Normal file
@@ -0,0 +1,56 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cur_frm.cscript.set_breadcrumbs = function(barea) {
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(cur_frm.docname);
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!Sales Browser/Sales Person">\
|
||||
Sales Person Tree</a>');
|
||||
cur_frm.frm_head.appframe.add_breadcrumb(' in <a href="#!selling-home">Selling</a>');
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.set_root_readonly(doc);
|
||||
}
|
||||
|
||||
cur_frm.cscript.set_root_readonly = function(doc) {
|
||||
// read-only for root
|
||||
if(doc.name==='All Sales Persons') {
|
||||
cur_frm.perm = [[1,0,0], [1,0,0]];
|
||||
cur_frm.set_intro("This is a root sales person and cannot be edited.");
|
||||
} else {
|
||||
cur_frm.set_intro(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.onload = function(){
|
||||
|
||||
}
|
||||
|
||||
//get query select sales person
|
||||
cur_frm.fields_dict['parent_sales_person'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabSales Person`.`name`,`tabSales Person`.`parent_sales_person` FROM `tabSales Person` WHERE `tabSales Person`.`is_group` = "Yes" AND `tabSales Person`.`docstatus`!= 2 AND `tabSales Person`.`name` !="'+doc.sales_person_name+'" AND `tabSales Person`.%(key)s LIKE "%s" ORDER BY `tabSales Person`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
//get query select Territory
|
||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabTerritory`.`name` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
// ******************** ITEM Group ********************************
|
||||
cur_frm.fields_dict['target_details'].grid.get_field("item_group").get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabItem Group`.name FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50'
|
||||
}
|
||||
36
setup/doctype/sales_person/sales_person.py
Normal file
36
setup/doctype/sales_person/sales_person.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.model.doclist import getlist
|
||||
from webnotes.utils import flt
|
||||
|
||||
from webnotes.utils.nestedset import DocTypeNestedSet
|
||||
|
||||
class DocType(DocTypeNestedSet):
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
self.nsm_parent_field = 'parent_sales_person';
|
||||
|
||||
def validate(self):
|
||||
for d in getlist(self.doclist, 'target_details'):
|
||||
if not flt(d.target_qty) and not flt(d.target_amount):
|
||||
webnotes.msgprint("Either target qty or target amount is mandatory.")
|
||||
raise Exception
|
||||
275
setup/doctype/sales_person/sales_person.txt
Normal file
275
setup/doctype/sales_person/sales_person.txt
Normal file
@@ -0,0 +1,275 @@
|
||||
# DocType, Sales Person
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 13:30:54',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-12 10:33:10',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1302765705',
|
||||
'allow_trash': 1,
|
||||
'autoname': u'field:sales_person_name',
|
||||
'colour': u'White:FFF',
|
||||
'description': u'All Sales Transactions can be tagged against multiple **Sales Persons** so that you can set and monitor targets.',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'in_create': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'search_fields': u'name,parent_sales_person',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Sales Person',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Sales Person',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocType, Sales Person
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Sales Person'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales User',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales User',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Sales Master Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'Sales Master Manager',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sales_person_name',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 1,
|
||||
'label': u'Sales Person Name',
|
||||
'oldfieldname': u'sales_person_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Select company name first.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'parent_sales_person',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Parent Sales Person',
|
||||
'oldfieldname': u'parent_sales_person',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Sales Person',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_group',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Has Child Node',
|
||||
'oldfieldname': u'is_group',
|
||||
'oldfieldtype': u'Select',
|
||||
'options': u'\nYes\nNo',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'cb0',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'employee',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Employee',
|
||||
'options': u'Employee',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'lft',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'in_filter': 1,
|
||||
'label': u'lft',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'lft',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'rgt',
|
||||
'fieldtype': u'Int',
|
||||
'hidden': 1,
|
||||
'in_filter': 1,
|
||||
'label': u'rgt',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'rgt',
|
||||
'oldfieldtype': u'Int',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'old_parent',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 1,
|
||||
'label': u'old_parent',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': u'old_parent',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Set targets Item Group-wise for this Sales Person.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'target_details_section_break',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Sales Person Targets',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'target_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Target Details1',
|
||||
'oldfieldname': u'target_details',
|
||||
'oldfieldtype': u'Table',
|
||||
'options': u'Target Detail',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Select Budget Distribution to unevenly distribute targets across months.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'distribution_id',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Target Distribution',
|
||||
'oldfieldname': u'distribution_id',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Budget Distribution',
|
||||
'permlevel': 0,
|
||||
'search_index': 0
|
||||
}
|
||||
]
|
||||
1
setup/doctype/series_detail/__init__.py
Normal file
1
setup/doctype/series_detail/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
61
setup/doctype/series_detail/series_detail.txt
Normal file
61
setup/doctype/series_detail/series_detail.txt
Normal file
@@ -0,0 +1,61 @@
|
||||
# DocType, Series Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:25',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:25',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Series Detail',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Series Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Series Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'series',
|
||||
'fieldtype': u'Read Only',
|
||||
'label': u'Series',
|
||||
'oldfieldname': u'series',
|
||||
'oldfieldtype': u'Read Only'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'remove',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Remove',
|
||||
'oldfieldname': u'remove',
|
||||
'oldfieldtype': u'Check',
|
||||
'trigger': u'Client'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/setup_control/__init__.py
Normal file
1
setup/doctype/setup_control/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
249
setup/doctype/setup_control/setup_control.py
Normal file
249
setup/doctype/setup_control/setup_control.py
Normal file
@@ -0,0 +1,249 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cint, cstr, flt, getdate, now, nowdate
|
||||
from webnotes.model.doc import Document, addchild
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, form, msgprint
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
# Account Setup
|
||||
# ---------------
|
||||
def setup_account(self, args):
|
||||
import webnotes, json
|
||||
args = json.loads(args)
|
||||
webnotes.conn.begin()
|
||||
|
||||
curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start'))
|
||||
#webnotes.msgprint(self.get_fy_details(args.get('fy_start')))
|
||||
|
||||
args['name'] = webnotes.session.get('user')
|
||||
|
||||
# Update Profile
|
||||
if not args.get('last_name') or args.get('last_name')=='None': args['last_name'] = None
|
||||
webnotes.conn.sql("""\
|
||||
UPDATE `tabProfile` SET first_name=%(first_name)s,
|
||||
last_name=%(last_name)s
|
||||
WHERE name=%(name)s AND docstatus<2""", args)
|
||||
|
||||
|
||||
# Fiscal Year
|
||||
master_dict = {'Fiscal Year':{
|
||||
'year': curr_fiscal_year,
|
||||
'year_start_date': fy_start_date,
|
||||
'company': args.get('company_name')}}
|
||||
self.create_records(master_dict)
|
||||
|
||||
# Company
|
||||
master_dict = {'Company':{'company_name':args.get('company_name'),
|
||||
'abbr':args.get('company_abbr'),
|
||||
'default_currency':args.get('currency')
|
||||
}}
|
||||
self.create_records(master_dict)
|
||||
|
||||
def_args = {'current_fiscal_year':curr_fiscal_year,
|
||||
'default_currency': args.get('currency'),
|
||||
'default_company':args.get('company_name'),
|
||||
'default_valuation_method':'FIFO',
|
||||
'default_stock_uom':'Nos',
|
||||
'date_format':'dd-mm-yyyy',
|
||||
'default_currency_format':'Lacs',
|
||||
'so_required':'No',
|
||||
'dn_required':'No',
|
||||
'po_required':'No',
|
||||
'pr_required':'No',
|
||||
'emp_created_by':'Naming Series',
|
||||
'cust_master_name':'Customer Name',
|
||||
'supp_master_name':'Supplier Name',
|
||||
'default_currency_format': \
|
||||
(args.get('currency')=='INR') and 'Lacs' or 'Millions'
|
||||
}
|
||||
|
||||
# Set
|
||||
self.set_defaults(def_args)
|
||||
|
||||
cp_args = {}
|
||||
for k in ['industry', 'country', 'timezone', 'company_name']:
|
||||
cp_args[k] = args[k]
|
||||
|
||||
self.set_cp_defaults(**cp_args)
|
||||
|
||||
self.create_feed_and_todo()
|
||||
|
||||
self.create_email_digest()
|
||||
|
||||
webnotes.clear_cache()
|
||||
msgprint("Company setup is complete")
|
||||
|
||||
import webnotes.utils
|
||||
user_fullname = (args.get('first_name') or '') + (args.get('last_name')
|
||||
and (" " + args.get('last_name')) or '')
|
||||
webnotes.conn.commit()
|
||||
return {'sys_defaults': webnotes.utils.get_defaults(), 'user_fullname': user_fullname}
|
||||
|
||||
def create_feed_and_todo(self):
|
||||
"""update activty feed and create todo for creation of item, customer, vendor"""
|
||||
import home
|
||||
home.make_feed('Comment', 'ToDo', '', webnotes.session['user'],
|
||||
'<i>"' + 'Setup Complete. Please check your <a href="#!todo">\
|
||||
To Do List</a>' + '"</i>', '#6B24B3')
|
||||
|
||||
d = Document('ToDo')
|
||||
d.description = 'Create your first Customer'
|
||||
d.priority = 'High'
|
||||
d.date = nowdate()
|
||||
d.reference_type = 'Customer'
|
||||
d.save(1)
|
||||
|
||||
d = Document('ToDo')
|
||||
d.description = 'Create your first Item'
|
||||
d.priority = 'High'
|
||||
d.date = nowdate()
|
||||
d.reference_type = 'Item'
|
||||
d.save(1)
|
||||
|
||||
d = Document('ToDo')
|
||||
d.description = 'Create your first Supplier'
|
||||
d.priority = 'High'
|
||||
d.date = nowdate()
|
||||
d.reference_type = 'Supplier'
|
||||
d.save(1)
|
||||
|
||||
def create_email_digest(self):
|
||||
"""
|
||||
create a default weekly email digest
|
||||
* Weekly Digest
|
||||
* For all companies
|
||||
* Recipients: System Managers
|
||||
* Full content
|
||||
* Enabled by default
|
||||
"""
|
||||
import webnotes
|
||||
companies_list = webnotes.conn.sql("SELECT company_name FROM `tabCompany`", as_list=1)
|
||||
|
||||
import webnotes.utils
|
||||
system_managers = webnotes.utils.get_system_managers_list()
|
||||
if not system_managers: return
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
for company in companies_list:
|
||||
if company and company[0]:
|
||||
edigest = Document('Email Digest')
|
||||
edigest.name = "Default Weekly Digest - " + company[0]
|
||||
edigest.company = company[0]
|
||||
edigest.frequency = 'Weekly'
|
||||
edigest.recipient_list = "\n".join(system_managers)
|
||||
for f in ['new_leads', 'new_enquiries', 'new_quotations',
|
||||
'new_sales_orders', 'new_purchase_orders',
|
||||
'new_transactions', 'payables', 'payments',
|
||||
'expenses_booked', 'invoiced_amount', 'collections',
|
||||
'income', 'bank_balance', 'stock_below_rl',
|
||||
'income_year_to_date', 'enabled']:
|
||||
edigest.fields[f] = 1
|
||||
exists = webnotes.conn.sql("""\
|
||||
SELECT name FROM `tabEmail Digest`
|
||||
WHERE name = %s""", edigest.name)
|
||||
if (exists and exists[0]) and exists[0][0]:
|
||||
continue
|
||||
else:
|
||||
edigest.save(1)
|
||||
|
||||
# Get Fiscal year Details
|
||||
# ------------------------
|
||||
def get_fy_details(self, fy_start):
|
||||
st = {'1st Jan':'01-01','1st Apr':'04-01','1st Jul':'07-01', '1st Oct': '10-01'}
|
||||
curr_year = getdate(nowdate()).year
|
||||
if cint(getdate(nowdate()).month) < cint((st[fy_start].split('-'))[0]):
|
||||
curr_year = getdate(nowdate()).year - 1
|
||||
stdt = cstr(curr_year)+'-'+cstr(st[fy_start])
|
||||
#eddt = sql("select DATE_FORMAT(DATE_SUB(DATE_ADD('%s', INTERVAL 1 YEAR), INTERVAL 1 DAY),'%%d-%%m-%%Y')" % (stdt.split('-')[2]+ '-' + stdt.split('-')[1] + '-' + stdt.split('-')[0]))
|
||||
if(fy_start == '1st Jan'):
|
||||
fy = cstr(getdate(nowdate()).year)
|
||||
abbr = cstr(fy)[-2:]
|
||||
else:
|
||||
fy = cstr(curr_year) + '-' + cstr(curr_year+1)
|
||||
abbr = cstr(curr_year)[-2:] + '-' + cstr(curr_year+1)[-2:]
|
||||
return fy, stdt, abbr
|
||||
|
||||
|
||||
# Create Company and Fiscal Year
|
||||
# -------------------------------
|
||||
def create_records(self, master_dict):
|
||||
for d in master_dict.keys():
|
||||
rec = Document(d)
|
||||
for fn in master_dict[d].keys():
|
||||
rec.fields[fn] = master_dict[d][fn]
|
||||
# add blank fields
|
||||
for fn in rec.fields:
|
||||
if fn not in master_dict[d].keys()+['name','owner','doctype']:
|
||||
rec.fields[fn] = ''
|
||||
rec_obj = get_obj(doc=rec)
|
||||
rec_obj.doc.save(1)
|
||||
if hasattr(rec_obj, 'on_update'):
|
||||
rec_obj.on_update()
|
||||
|
||||
|
||||
# Set System Defaults
|
||||
# --------------------
|
||||
def set_defaults(self, def_args):
|
||||
ma_obj = get_obj('Global Defaults','Global Defaults')
|
||||
for d in def_args.keys():
|
||||
ma_obj.doc.fields[d] = def_args[d]
|
||||
ma_obj.doc.save()
|
||||
ma_obj.on_update()
|
||||
|
||||
|
||||
# Set Control Panel Defaults
|
||||
# --------------------------
|
||||
def set_cp_defaults(self, industry, country, timezone, company_name):
|
||||
cp = Document('Control Panel','Control Panel')
|
||||
cp.company_name = company_name
|
||||
cp.industry = industry
|
||||
cp.time_zone = timezone
|
||||
cp.country = country
|
||||
cp.save()
|
||||
|
||||
# Create Profile
|
||||
# --------------
|
||||
def create_profile(self, user_email, user_fname, user_lname, pwd=None):
|
||||
pr = Document('Profile')
|
||||
pr.first_name = user_fname
|
||||
pr.last_name = user_lname
|
||||
pr.name = pr.email = user_email
|
||||
pr.enabled = 1
|
||||
pr.save(1)
|
||||
if pwd: webnotes.conn.sql("UPDATE `tabProfile` SET password=PASSWORD(%s) WHERE name=%s", (pwd, user_email))
|
||||
self.add_roles(pr)
|
||||
|
||||
def add_roles(self, pr):
|
||||
roles_list = ['Accounts Manager', 'Accounts User', 'Blogger', 'HR Manager', 'HR User', 'Maintenance User', 'Maintenance Manager', 'Material Manager', 'Material User', 'Material Master Manager', 'Production Manager', 'Production User', 'Projects User', 'Purchase Manager', 'Purchase User', 'Purchase Master Manager', 'Quality Manager', 'Sales Manager', 'Sales User', 'Sales Master Manager', 'Support Manager', 'Support Team', 'System Manager', 'Website Manager']
|
||||
for r in roles_list:
|
||||
d = addchild(pr, 'userroles', 'UserRole', 1)
|
||||
d.role = r
|
||||
d.save(1)
|
||||
|
||||
# Add roles to Administrator profile
|
||||
pr = Document('Profile','Administrator')
|
||||
for r in roles_list:
|
||||
d = addchild(pr,'userroles', 'UserRole', 1)
|
||||
d.role = r
|
||||
d.save(1)
|
||||
33
setup/doctype/setup_control/setup_control.txt
Normal file
33
setup/doctype/setup_control/setup_control.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
# DocType, Setup Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:25',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:25',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'issingle': 1,
|
||||
'istable': 0,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'version': 73
|
||||
},
|
||||
|
||||
# DocType, Setup Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Setup Control'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/sms_parameter/__init__.py
Executable file
1
setup/doctype/sms_parameter/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
57
setup/doctype/sms_parameter/sms_parameter.txt
Executable file
57
setup/doctype/sms_parameter/sms_parameter.txt
Executable file
@@ -0,0 +1,57 @@
|
||||
# DocType, SMS Parameter
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:25',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:25',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 4
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldtype': u'Data',
|
||||
'name': '__common__',
|
||||
'parent': u'SMS Parameter',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'width': u'150px'
|
||||
},
|
||||
|
||||
# DocType, SMS Parameter
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'SMS Parameter'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'parameter',
|
||||
'label': u'Parameter'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'value',
|
||||
'label': u'Value'
|
||||
}
|
||||
]
|
||||
1
setup/doctype/sms_settings/__init__.py
Executable file
1
setup/doctype/sms_settings/__init__.py
Executable file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
133
setup/doctype/sms_settings/sms_settings.txt
Executable file
133
setup/doctype/sms_settings/sms_settings.txt
Executable file
@@ -0,0 +1,133 @@
|
||||
# DocType, SMS Settings
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:25',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:25',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1306304974',
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 0,
|
||||
'issingle': 1,
|
||||
'module': u'Setup',
|
||||
'name': '__common__',
|
||||
'read_only': 0,
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 16
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'SMS Settings',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'SMS Settings',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'role': u'System Manager'
|
||||
},
|
||||
|
||||
# DocType, SMS Settings
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'SMS Settings'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Eg. smsgateway.com/api/send_sms.cgi',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sms_gateway_url',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'SMS Gateway URL',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Enter url parameter for message',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'message_parameter',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Message Parameter',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Enter url parameter for receiver nos',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'receiver_parameter',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Receiver Parameter',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'static_parameters',
|
||||
'fieldtype': u'Column Break',
|
||||
'label': u'Static Parameters',
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Enter static url parameters here (Eg. sender=ERPNext, username=ERPNext, password=1234 etc.)',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'static_parameter_details',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'SMS Parameters',
|
||||
'options': u'SMS Parameter'
|
||||
}
|
||||
]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user