Merge remote-tracking branch 'upstream/wsgi' into HEAD

Conflicts:
	public/js/complete_setup.js
	setup/doctype/setup_control/setup_control.py
This commit is contained in:
Pratik Vyas
2013-10-25 14:07:48 +05:30
313 changed files with 3813 additions and 3018 deletions

View File

@@ -9,7 +9,6 @@ from webnotes.model.bean import getlist
from webnotes import session, msgprint
from setup.utils import get_company_currency
sql = webnotes.conn.sql
from utilities.transaction_base import TransactionBase
@@ -28,10 +27,10 @@ class DocType(TransactionBase):
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))
app_dtl = webnotes.conn.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))
app_dtl = webnotes.conn.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])
@@ -58,18 +57,18 @@ class DocType(TransactionBase):
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))
itemwise_exists = webnotes.conn.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))
itemwise_exists = webnotes.conn.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))
appr = webnotes.conn.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))
appr = webnotes.conn.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)
@@ -112,7 +111,7 @@ class DocType(TransactionBase):
# ================
# 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))]
based_on = [x[0] for x in webnotes.conn.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)
@@ -124,7 +123,7 @@ class DocType(TransactionBase):
# Specific Role
# ===============
# Check for authorization set on particular roles
based_on = [x[0] for x in sql("""select based_on
based_on = [x[0] for x in webnotes.conn.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,'')='')
@@ -148,9 +147,9 @@ class DocType(TransactionBase):
# 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))
val = webnotes.conn.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))
val = webnotes.conn.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]
@@ -158,9 +157,9 @@ class DocType(TransactionBase):
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)
rule = webnotes.conn.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)
rule = webnotes.conn.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
@@ -175,9 +174,9 @@ class DocType(TransactionBase):
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)
rule = webnotes.conn.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)
rule = webnotes.conn.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:
@@ -185,7 +184,7 @@ class DocType(TransactionBase):
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'])]
user_lst = [z[0] for z in webnotes.conn.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)

View File

@@ -9,7 +9,6 @@ from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
from webnotes import msgprint
sql = webnotes.conn.sql
@@ -19,7 +18,7 @@ class DocType:
def check_duplicate_entry(self):
exists = sql("""select name, docstatus from `tabAuthorization Rule`
exists = webnotes.conn.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""",
@@ -39,12 +38,12 @@ class DocType:
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" % \
not webnotes.conn.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=1)
elif self.doc.based_on == 'Itemwise Discount' and \
not sql("select name from tabItem where name = '%s' and docstatus != 2" % \
not webnotes.conn.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=1)
elif (self.doc.based_on == 'Grand Total' or \
@@ -65,7 +64,7 @@ class DocType:
Applicable To (Role).", raise_exception=1)
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'" % \
webnotes.conn.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=1)

View File

@@ -61,8 +61,8 @@ def dropbox_callback(oauth_token=None, not_approved=False):
allowed = 0
message = "Dropbox Access not approved."
webnotes.message_title = "Dropbox Approval"
webnotes.message = "<h3>%s</h3><p>Please close this window.</p>" % message
webnotes.local.message_title = "Dropbox Approval"
webnotes.local.message = "<h3>%s</h3><p>Please close this window.</p>" % message
webnotes.conn.commit()
webnotes.response['type'] = 'page'

View File

@@ -114,9 +114,9 @@ def backup_to_gdrive():
def get_gdrive_flow():
from oauth2client.client import OAuth2WebServerFlow
import conf
from webnotes import conf
if not hasattr(conf, "gdrive_client_id"):
if not "gdrive_client_id" in conf:
webnotes.msgprint(_("Please set Google Drive access keys in") + " conf.py",
raise_exception=True)
@@ -170,4 +170,4 @@ def create_folder(name, service, folder_id):
return database['id']
if __name__=="__main__":
backup_to_gdrive()
backup_to_gdrive()

View File

@@ -61,7 +61,8 @@ cur_frm.cscript.has_special_chars = function(t) {
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>")
msgprint(("<font color=red>"+wn._("Special Characters")+" <b>! @ # $ % ^ * + = - [ ] ' ; , / { } | : < > ?</b> "+
wn._("are not allowed for ")+"</font>\n"+wn._("Company Name")+" <b> "+ doc.company_name +"</b>"))
doc.company_name = '';
refresh_field('company_name');
}
@@ -69,7 +70,8 @@ cur_frm.cscript.company_name = function(doc){
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>")
msgprint("<font color=red>"+wn._("Special Characters ")+"<b>! @ # $ % ^ * + = - [ ] ' ; , / { } | : < > ?</b>" +
wn._("are not allowed for")+ "</font>\nAbbr <b>" + doc.abbr +"</b>")
doc.abbr = '';
refresh_field('abbr');
}

View File

@@ -8,7 +8,6 @@ from webnotes import _, msgprint
from webnotes.utils import cstr
import webnotes.defaults
sql = webnotes.conn.sql
class DocType:
def __init__(self,d,dl):
@@ -329,4 +328,4 @@ def replace_abbr(company, old, new):
for dt in ["Account", "Cost Center", "Warehouse"]:
_rename_record(dt)
webnotes.conn.commit()
webnotes.conn.commit()

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-04-10 08:35:39",
"docstatus": 0,
"modified": "2013-08-28 19:15:04",
"modified": "2013-10-08 15:18:34",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -80,7 +80,7 @@
"fieldtype": "Select",
"label": "Domain",
"options": "Distribution\nManufacturing\nRetail\nServices",
"reqd": 1
"reqd": 0
},
{
"doctype": "DocField",

View File

@@ -9,7 +9,7 @@ cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root customer group
if(!doc.parent_customer_group) {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root customer group and cannot be edited.");
cur_frm.set_intro(wn._("This is a root customer group and cannot be edited."));
} else {
cur_frm.set_intro(null);
}

View File

@@ -5,7 +5,6 @@ from __future__ import unicode_literals
import webnotes
from webnotes import msgprint
sql = webnotes.conn.sql
from webnotes.utils.nestedset import DocTypeNestedSet
class DocType(DocTypeNestedSet):
@@ -15,7 +14,7 @@ class DocType(DocTypeNestedSet):
self.nsm_parent_field = 'parent_customer_group';
def validate(self):
if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2",
if webnotes.conn.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 -> Recycle Bin.""" %
@@ -33,7 +32,7 @@ class DocType(DocTypeNestedSet):
self.doc.name, raise_exception=1)
def on_trash(self):
cust = sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s",
cust = webnotes.conn.sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s",
self.doc.name)
cust = [d[0] for d in cust]
if cust:
@@ -42,7 +41,7 @@ class DocType(DocTypeNestedSet):
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 \
if webnotes.conn.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)

View File

@@ -3,10 +3,10 @@
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."
var save_msg = wn._("You must ")+ "<b>"+wn._("Save ")+"</b>"+wn._("the form before proceeding");
var err_msg = wn._("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() {
cur_frm.add_custom_button(wn._('View Now'), function() {
doc = locals[dt][dn];
if(doc.__unsaved != 1) {
return $c_obj(make_doclist(dt, dn), 'get_digest_msg', '', function(r, rt) {
@@ -16,7 +16,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
} else {
//console.log(arguments);
var d = new wn.ui.Dialog({
title: 'Email Digest: ' + dn,
title: wn._('Email Digest: ') + dn,
width: 800
});
@@ -29,7 +29,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
msgprint(save_msg);
}
}, 1);
cur_frm.add_custom_button('Send Now', function() {
cur_frm.add_custom_button(wn._('Send Now'), function() {
doc = locals[dt][dn];
if(doc.__unsaved != 1) {
return $c_obj(make_doclist(dt, dn), 'send', '', function(r, rt) {
@@ -38,7 +38,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
console.log(r.exc);
} else {
//console.log(arguments);
msgprint('Message Sent');
msgprint(wn._('Message Sent'));
}
});
} else {
@@ -56,7 +56,7 @@ cur_frm.cscript.addremove_recipients = function(doc, dt, dn) {
// Open a dialog and display checkboxes against email addresses
doc = locals[dt][dn];
var d = new wn.ui.Dialog({
title: 'Add/Remove Recipients',
title: wn._('Add/Remove Recipients'),
width: 400
});
var dialog_div = $a(d.body, 'div', 'dialog-div', '', '');

View File

@@ -457,8 +457,8 @@ def send():
from webnotes.utils import getdate
now_date = now_datetime().date()
import conf
if hasattr(conf, "expires_on") and now_date > getdate(conf.expires_on):
from webnotes import conf
if "expires_on" in conf and now_date > getdate(conf.expires_on):
# do not send email digests to expired accounts
return

View File

@@ -3,7 +3,6 @@
from __future__ import unicode_literals
import webnotes
sql = webnotes.conn.sql
from webnotes.utils import cint

View File

@@ -4,16 +4,22 @@
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.set_root_readonly(doc);
cur_frm.add_custom_button("Item Group Tree", function() {
cur_frm.add_custom_button(wn._("Item Group Tree"), function() {
wn.set_route("Sales Browser", "Item Group");
})
if(!doc.__islocal && doc.show_in_website) {
cur_frm.add_custom_button("View In Website", function() {
window.open(doc.page_name);
}, "icon-globe");
}
}
cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root item group
if(!doc.parent_item_group) {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root item group and cannot be edited.");
cur_frm.set_intro(wn._("This is a root item group and cannot be edited."));
} else {
cur_frm.set_intro(null);
}

View File

@@ -8,7 +8,7 @@
{% include "lib/website/doctype/website_slideshow/templates/includes/slideshow.html" %}
{% endif %}
{% if description %}<!-- description -->
<div>{{ description or ""}}</div>
<div itemprop="description">{{ description or ""}}</div>
{% else %}
<h3>{{ name }}</h3>
{% endif %}
@@ -38,5 +38,13 @@
<div class="alert alert-warning">No items listed.</div>
{% endif %}
</div>
<script>
$(function() {
if(window.logged_in && getCookie("system_user")==="yes") {
wn.require("lib/js/wn/website/editable.js");
wn.make_editable($('[itemprop="description"]'), "Item Group", "{{ name }}", "description");
}
})
</script>
{% endblock %}

View File

@@ -8,7 +8,6 @@ from webnotes.utils import cstr
from webnotes import msgprint
import webnotes.model.doctype
sql = webnotes.conn.sql
class DocType:
def __init__(self, d, dl):
@@ -23,7 +22,7 @@ class DocType:
where fieldname='naming_series'""")
)))),
"prefixes": "\n".join([''] + [i[0] for i in
sql("""select name from tabSeries""")])
webnotes.conn.sql("""select name from tabSeries""")])
}
def scrub_options_list(self, ol):
@@ -126,12 +125,43 @@ class DocType:
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))
webnotes.conn.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))
webnotes.conn.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")
def set_by_naming_series(doctype, fieldname, naming_series, hide_name_field=True):
from core.doctype.property_setter.property_setter import make_property_setter
if naming_series:
make_property_setter(doctype, "naming_series", "hidden", 0, "Check")
make_property_setter(doctype, "naming_series", "reqd", 1, "Check")
# set values for mandatory
webnotes.conn.sql("""update `tab{doctype}` set naming_series={s} where
ifnull(naming_series, '')=''""".format(doctype=doctype, s="%s"), get_default_naming_series(doctype))
if hide_name_field:
make_property_setter(doctype, fieldname, "reqd", 0, "Check")
make_property_setter(doctype, fieldname, "hidden", 1, "Check")
else:
make_property_setter(doctype, "naming_series", "reqd", 0, "Check")
make_property_setter(doctype, "naming_series", "hidden", 1, "Check")
if hide_name_field:
make_property_setter(doctype, fieldname, "hidden", 0, "Check")
make_property_setter(doctype, fieldname, "reqd", 1, "Check")
# set values for mandatory
webnotes.conn.sql("""update `tab{doctype}` set `{fieldname}`=`name` where
ifnull({fieldname}, '')=''""".format(doctype=doctype, fieldname=fieldname))
def get_default_naming_series(doctype):
from webnotes.model.doctype import get_property
naming_series = get_property(doctype, "options", "naming_series")
naming_series = naming_series.split("\n")
return naming_series[0] or naming_series[1]

View File

@@ -6,7 +6,6 @@ import webnotes
from webnotes import msgprint
sql = webnotes.conn.sql
class DocType:
def __init__(self,d,dl):
@@ -14,7 +13,7 @@ class DocType:
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'))
v = webnotes.conn.sql("select value from tabSingles where field=%s and doctype=%s", (fn, 'Notification Control'))
return v and v[0][0] or ''
def set_message(self, arg = ''):

View File

@@ -7,7 +7,6 @@ import webnotes
from webnotes.model import db_exists
from webnotes.model.bean import copy_doclist
sql = webnotes.conn.sql

View File

@@ -39,7 +39,7 @@ cur_frm.cscript.make_address = 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',
no_results_message: wn._('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'});
@@ -69,7 +69,7 @@ cur_frm.cscript.make_contact = 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',
no_results_message: wn._('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'});

View File

@@ -5,13 +5,16 @@ from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr, filter_strip_join
sql = webnotes.conn.sql
class DocType:
def __init__(self, doc, doclist=None):
self.doc = doc
self.doclist = doclist
def validate(self):
if self.doc.partner_website and not self.doc.partner_website.startswith("http"):
self.doc.partner_website = "http://" + self.doc.partner_website
def on_update(self):
if cint(self.doc.show_in_website):
from webnotes.webutils import update_page_name
@@ -24,7 +27,7 @@ class DocType:
def get_contacts(self,nm):
if nm:
contact_details =webnotes.conn.convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where sales_partner = '%s'"%nm))
contact_details =webnotes.conn.convert_to_lists(webnotes.conn.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 ''

View File

@@ -9,7 +9,7 @@ cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root
if(!doc.parent_sales_person) {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root sales person and cannot be edited.");
cur_frm.set_intro(wn._("This is a root sales person and cannot be edited."));
} else {
cur_frm.set_intro(null);
}

View File

@@ -1 +0,0 @@
Account setup utility on first login.

View File

@@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@@ -1,255 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cint, cstr, getdate, now, nowdate, get_defaults
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
def setup_account(self, args):
import webnotes, json
if isinstance(args, basestring):
args = json.loads(args)
webnotes.conn.begin()
self.update_profile_name(args)
add_all_roles_to(webnotes.session.user)
self.create_fiscal_year_and_company(args)
self.set_defaults(args)
create_territories()
self.create_price_lists(args)
self.create_feed_and_todo()
self.create_email_digest()
webnotes.clear_cache()
msgprint("Company setup is complete. This page will be refreshed in a moment.")
webnotes.conn.commit()
return {
'sys_defaults': get_defaults(),
'user_fullname': (args.get('first_name') or '') + (args.get('last_name')
and (" " + args.get('last_name')) or '')
}
def update_profile_name(self, args):
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)
def create_fiscal_year_and_company(self, args):
curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start'), True)
webnotes.bean([{
"doctype":"Fiscal Year",
'year': curr_fiscal_year,
'year_start_date': fy_start_date
}]).insert()
curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start'))
webnotes.bean([{
"doctype":"Fiscal Year",
'year': curr_fiscal_year,
'year_start_date': fy_start_date,
}]).insert()
# Company
webnotes.bean([{
"doctype":"Company",
'domain': args.get("industry"),
'company_name':args.get('company_name'),
'abbr':args.get('company_abbr'),
'default_currency':args.get('currency'),
}]).insert()
self.curr_fiscal_year = curr_fiscal_year
def create_price_lists(self, args):
for pl_type in ["Selling", "Buying"]:
webnotes.bean([
{
"doctype": "Price List",
"price_list_name": "Standard " + pl_type,
"buying_or_selling": pl_type,
"currency": args["currency"]
},
{
"doctype": "For Territory",
"parentfield": "valid_for_territories",
"territory": "All Territories"
}
]).insert()
def set_defaults(self, args):
# enable default currency
webnotes.conn.set_value("Currency", args.get("currency"), "enabled", 1)
global_defaults = webnotes.bean("Global Defaults", "Global Defaults")
global_defaults.doc.fields.update({
'current_fiscal_year': self.curr_fiscal_year,
'default_currency': args.get('currency'),
'default_company':args.get('company_name'),
'date_format': webnotes.conn.get_value("Country", args.get("country"), "date_format"),
"float_precision": 4
})
global_defaults.save()
accounts_settings = webnotes.bean("Accounts Settings")
accounts_settings.doc.auto_accounting_for_stock = 1
accounts_settings.save()
stock_settings = webnotes.bean("Stock Settings")
stock_settings.doc.item_naming_by = "Item Code"
stock_settings.doc.valuation_method = "FIFO"
stock_settings.doc.stock_uom = "Nos"
stock_settings.doc.auto_indent = 1
stock_settings.save()
selling_settings = webnotes.bean("Selling Settings")
selling_settings.doc.cust_master_name = "Customer Name"
selling_settings.doc.so_required = "No"
selling_settings.doc.dn_required = "No"
selling_settings.save()
buying_settings = webnotes.bean("Buying Settings")
buying_settings.doc.supp_master_name = "Supplier Name"
buying_settings.doc.po_required = "No"
buying_settings.doc.pr_required = "No"
buying_settings.doc.maintain_same_rate = 1
buying_settings.save()
notification_control = webnotes.bean("Notification Control")
notification_control.doc.quotation = 1
notification_control.doc.sales_invoice = 1
notification_control.doc.purchase_order = 1
notification_control.save()
hr_settings = webnotes.bean("HR Settings")
hr_settings.doc.emp_created_by = "Naming Series"
hr_settings.save()
# control panel
cp = webnotes.doc("Control Panel", "Control Panel")
for k in ['country', 'time_zone', 'company_name']:
cp.fields[k] = args[k]
cp.save()
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 = '<a href="#Setup">Complete ERPNext Setup</a>'
d.priority = 'High'
d.date = nowdate()
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)
from webnotes.profile import get_system_managers
system_managers = get_system_managers()
if not system_managers: return
from webnotes.model.doc import Document
for company in companies_list:
if company and company[0]:
edigest = webnotes.bean({
"doctype": "Email Digest",
"name": "Default Weekly Digest - " + company[0],
"company": company[0],
"frequency": "Weekly",
"recipient_list": "\n".join(system_managers)
})
if webnotes.conn.sql("""select name from `tabEmail Digest` where name=%s""", edigest.doc.name):
continue
for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}):
edigest.doc.fields[fieldname] = 1
edigest.insert()
# Get Fiscal year Details
# ------------------------
def get_fy_details(self, fy_start, last_year=False):
st = {'1st Jan':'01-01','1st Apr':'04-01','1st Jul':'07-01', '1st Oct': '10-01'}
if cint(getdate(nowdate()).month) < cint((st[fy_start].split('-'))[0]):
curr_year = getdate(nowdate()).year - 1
else:
curr_year = getdate(nowdate()).year
if last_year:
curr_year = curr_year - 1
stdt = cstr(curr_year)+'-'+cstr(st[fy_start])
if(fy_start == '1st Jan'):
fy = cstr(curr_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
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("""insert into __Auth (user, `password`)
values (%s, password(%s))
on duplicate key update `password`=password(%s)""",
(user_email, pwd, pwd))
add_all_roles_to(pr.name)
def add_all_roles_to(name):
profile = webnotes.doc("Profile", name)
for role in webnotes.conn.sql("""select name from tabRole"""):
if role[0] not in ["Administrator", "Guest", "All", "Customer", "Supplier", "Partner"]:
d = profile.addchild("user_roles", "UserRole")
d.role = role[0]
d.insert()
def create_territories():
"""create two default territories, one for home country and one named Rest of the World"""
from setup.utils import get_root_of
country = webnotes.conn.get_value("Control Panel", None, "country")
root_territory = get_root_of("Territory")
for name in (country, "Rest Of The World"):
if name and not webnotes.conn.exists("Territory", name):
webnotes.bean({
"doctype": "Territory",
"territory_name": name.replace("'", ""),
"parent_territory": root_territory,
"is_group": "No"
}).insert()

View File

@@ -1,24 +0,0 @@
[
{
"creation": "2012-03-27 14:36:25",
"docstatus": 0,
"modified": "2012-03-27 14:36:25",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "DocType",
"in_create": 1,
"issingle": 1,
"istable": 0,
"module": "Setup",
"name": "__common__",
"read_only": 1,
"section_style": "Simple",
"version": 73
},
{
"doctype": "DocType",
"name": "Setup Control"
}
]

View File

@@ -2,5 +2,5 @@
// License: GNU General Public License v3. See license.txt
cur_frm.cscript.refresh = function(doc) {
cur_frm.set_intro(doc.__islocal ? "" : "There is nothing to edit.")
cur_frm.set_intro(doc.__islocal ? "" : wn._("There is nothing to edit."))
}

View File

@@ -9,7 +9,7 @@ cur_frm.cscript.set_root_readonly = function(doc) {
// read-only for root territory
if(!doc.parent_territory) {
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.set_intro("This is a root territory and cannot be edited.");
cur_frm.set_intro(wn._("This is a root territory and cannot be edited."));
} else {
cur_frm.set_intro(null);
}

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:24",
"docstatus": 0,
"modified": "2013-07-25 16:18:17",
"modified": "2013-10-10 15:06:53",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -38,22 +38,6 @@
"doctype": "DocType",
"name": "UOM"
},
{
"doctype": "DocField",
"fieldname": "trash_reason",
"fieldtype": "Small Text",
"label": "Trash Reason",
"oldfieldname": "trash_reason",
"oldfieldtype": "Small Text",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "uom_details",
"fieldtype": "Section Break",
"label": "UOM Details",
"oldfieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "uom_name",

View File

@@ -5,12 +5,12 @@ wn.pages['Setup'].onload = function(wrapper) {
if(msg_dialog && msg_dialog.display) msg_dialog.hide();
wn.ui.make_app_page({
parent: wrapper,
title: 'Setup',
title: wn._('Setup'),
single_column: true
});
wrapper.appframe.add_module_icon("Setup");
wrapper.appframe.add_button("Refresh", function() {
wrapper.appframe.add_button(wn._("Refresh"), function() {
wn.pages.Setup.make(wrapper);
}, "icon-refresh");
@@ -110,7 +110,7 @@ wn.pages.Setup.make = function(wrapper) {
})
} else if(item.single) {
$('<a class="view-link"><i class="icon-edit"></i> Edit</a>')
$('<a class="view-link"><i class="icon-edit"></i>'+wn._('Edit')+'</a>')
.appendTo($links)
$links.find(".view-link")
@@ -119,11 +119,11 @@ wn.pages.Setup.make = function(wrapper) {
wn.set_route("Form", $(this).attr("data-doctype"));
})
} else if(item.type !== "Link"){
$('<a class="new-link"><i class="icon-plus"></i> New</a> \
$('<a class="new-link"><i class="icon-plus"></i>'+wn._('New')+'</a> \
<span class="text-muted">|</span> \
<a class="view-link"><i class="icon-list"></i> View</a> \
<a class="view-link"><i class="icon-list"></i>'+wn._('View')+'</a> \
<span class="text-muted">|</span> \
<a class="import-link"><i class="icon-upload"></i> Import</a>')
<a class="import-link"><i class="icon-upload"></i>'+wn._('Import')+'</a>')
.appendTo($links)
$links.find(".view-link")
@@ -180,11 +180,11 @@ wn.pages.Setup.make = function(wrapper) {
if(r.message) {
body.empty();
if(wn.boot.expires_on) {
$(body).prepend("<div class='text-muted' style='text-align:right'>Account expires on "
$(body).prepend("<div class='text-muted' style='text-align:right'>"+wn._("Account expires on")
+ wn.datetime.global_date_format(wn.boot.expires_on) + "</div>");
}
$completed = $('<h4>Setup Completed <span class="completed-percent"></span><h4>\
$completed = $('<h4>'+wn._("Setup Completed")+'<span class="completed-percent"></span><h4>\
<div class="progress"><div class="progress-bar"></div></div>')
.appendTo(body);

View File

@@ -226,8 +226,6 @@ items = [
"title": "System Administration",
"icon": "icon-cog"
},
{ "title": "Update ERPNext",
"route": "update-manager", "type": "Link", "icon": "icon-rss" },
{ "title": "Manage 3rd Party Backups",
"route": "Form/Backup Manager", "type": "Link", "icon": "icon-cloud" },
{ "title": "System Scheduler Errors",

View File

View File

@@ -0,0 +1,8 @@
#page-setup-wizard .panel {
-webkit-box-shadow: 0px 1px 8px rgba(0,0,0,0.6);
box-shadow: 0px 1px 8px rgba(0,0,0,0.6);
}
#page-setup-wizard .col-md-6 .control-input .btn {
width: 100%;
}

View File

@@ -0,0 +1,502 @@
wn.pages['setup-wizard'].onload = function(wrapper) {
if(sys_defaults.company) {
wn.set_route("desktop");
return;
}
$(".navbar:first").toggle(false);
$("body").css({"padding-top":"30px"});
erpnext.wiz = new wn.wiz.Wizard({
page_name: "setup-wizard",
parent: wrapper,
on_complete: function(wiz) {
var values = wiz.get_values();
wiz.show_working();
wn.call({
method: "setup.page.setup_wizard.setup_wizard.setup_account",
args: values,
callback: function(r) {
if(r.exc) {
var d = msgprint(wn._("There were errors."));
d.custom_onhide = function() {
wn.set_route(erpnext.wiz.page_name, "0");
}
} else {
wiz.show_complete();
setTimeout(function() {
if(user==="Administrator") {
msgprint(wn._("Login with your new User ID") + ":" + values.email);
setTimeout(function() {
wn.app.logout();
}, 2000);
} else {
window.location = "app.html";
}
}, 2000);
}
}
})
},
title: wn._("ERPNext Setup Guide"),
welcome_html: '<h1 class="text-muted text-center"><i class="icon-magic"></i></h1>\
<h2 class="text-center">'+wn._('ERPNext Setup')+'</h2>\
<p class="text-center">' +
wn._('Welcome to ERPNext. Over the next few minutes we will help you setup your ERPNext account. Try and fill in as much information as you have even if it takes a bit longer. It will save you a lot of time later. Good Luck!') +
'</p>',
working_html: '<h3 class="text-muted text-center"><i class="icon-refresh icon-spin"></i></h3>\
<h2 class="text-center">'+wn._('Setting up...')+'</h2>\
<p class="text-center">' +
wn._('Sit tight while your system is being setup. This may take a few moments.') +
'</p>',
complete_html: '<h1 class="text-muted text-center"><i class="icon-thumbs-up"></i></h1>\
<h2 class="text-center">'+wn._('Setup Complete!')+'</h2>\
<p class="text-center">' +
wn._('Your setup is complete. Refreshing...') +
'</p>',
slides: [
// User
{
title: wn._("The First User: You"),
icon: "icon-user",
fields: [
{"fieldname": "first_name", "label": wn._("First Name"), "fieldtype": "Data", reqd:1},
{"fieldname": "last_name", "label": wn._("Last Name"), "fieldtype": "Data", reqd:1},
{"fieldname": "email", "label": wn._("Email Id"), "fieldtype": "Data", reqd:1, "description":"Your Login Id"},
{"fieldname": "password", "label": wn._("Password"), "fieldtype": "Password", reqd:1},
{fieldtype:"Attach Image", fieldname:"attach_profile", label:"Attach Your Profile..."},
],
help: wn._('The first user will become the System Manager (you can change that later).'),
onload: function(slide) {
if(user!=="Administrator") {
slide.form.fields_dict.password.$wrapper.toggle(false);
slide.form.fields_dict.email.$wrapper.toggle(false);
slide.form.fields_dict.first_name.set_input(wn.boot.profile.first_name);
slide.form.fields_dict.last_name.set_input(wn.boot.profile.last_name);
delete slide.form.fields_dict.email;
delete slide.form.fields_dict.password;
}
}
},
// Organization
{
title: wn._("The Organization"),
icon: "icon-building",
fields: [
{fieldname:'company_name', label: wn._('Company Name'), fieldtype:'Data', reqd:1,
placeholder: 'e.g. "My Company LLC"'},
{fieldname:'company_abbr', label: wn._('Company Abbreviation'), fieldtype:'Data',
placeholder:'e.g. "MC"',reqd:1},
{fieldname:'fy_start', label:'Financial Year Start Date', fieldtype:'Select',
description:'Your financial year begins on', reqd:1,
options: ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct'] },
{fieldname:'company_tagline', label: wn._('What does it do?'), fieldtype:'Data',
placeholder:'e.g. "Build tools for builders"', reqd:1},
],
help: wn._('The name of your company for which you are setting up this system.'),
onload: function(slide) {
slide.get_input("company_name").on("change", function() {
var parts = slide.get_input("company_name").val().split(" ");
var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join("");
slide.get_input("company_abbr").val(abbr.toUpperCase());
}).val(wn.boot.control_panel.company_name || "").trigger("change");
}
},
// Country
{
title: wn._("Country, Timezone and Currency"),
icon: "icon-flag",
fields: [
{fieldname:'country', label: wn._('Country'), reqd:1,
options: "", fieldtype: 'Select'},
{fieldname:'currency', label: wn._('Default Currency'), reqd:1,
options: "", fieldtype: 'Select'},
{fieldname:'timezone', label: wn._('Time Zone'), reqd:1,
options: "", fieldtype: 'Select'},
],
help: wn._('Select your home country and check the timezone and currency.'),
onload: function(slide, form) {
wn.call({
method:"webnotes.country_info.get_country_timezone_info",
callback: function(data) {
erpnext.country_info = data.message.country_info;
erpnext.all_timezones = data.message.all_timezones;
slide.get_input("country").empty()
.add_options([""].concat(keys(erpnext.country_info).sort()));
slide.get_input("currency").empty()
.add_options(wn.utils.unique([""].concat($.map(erpnext.country_info,
function(opts, country) { return opts.currency; }))).sort());
slide.get_input("timezone").empty()
.add_options([""].concat(erpnext.all_timezones));
}
})
slide.get_input("country").on("change", function() {
var country = slide.get_input("country").val();
var $timezone = slide.get_input("timezone");
$timezone.empty();
// add country specific timezones first
if(country){
var timezone_list = erpnext.country_info[country].timezones || [];
$timezone.add_options(timezone_list.sort());
slide.get_input("currency").val(erpnext.country_info[country].currency);
}
// add all timezones at the end, so that user has the option to change it to any timezone
$timezone.add_options([""].concat(erpnext.all_timezones));
});
}
},
// Logo
{
icon: "icon-bookmark",
title: wn._("Logo and Letter Heads"),
help: wn._('Upload your letter head and logo - you can edit them later.'),
fields: [
{fieldtype:"Attach Image", fieldname:"attach_letterhead", label:"Attach Letterhead..."},
{fieldtype:"Attach Image", fieldname:"attach_logo", label:"Attach Logo..."},
],
},
// Taxes
{
icon: "icon-money",
"title": wn._("Add Taxes"),
"help": wn._("List your tax heads (e.g. VAT, Excise) (upto 3) and their standard rates. This will create a standard template, you can edit and add more later."),
"fields": [
{fieldtype:"Data", fieldname:"tax_1", label:"Tax 1", placeholder:"e.g. VAT"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"tax_rate_1", label:"Rate (%)", placeholder:"e.g. 5"},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"tax_2", label:"Tax 2", placeholder:"e.g. Customs Duty"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"tax_rate_2", label:"Rate (%)", placeholder:"e.g. 5"},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"tax_3", label:"Tax 3", placeholder:"e.g. Excise"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"tax_rate_3", label:"Rate (%)", placeholder:"e.g. 5"},
],
},
// Items to Sell
{
icon: "icon-barcode",
"title": wn._("Your Products or Services"),
"help": wn._("List your products or services that you sell to your customers. Make sure to check the Item Group, Unit of Measure and other properties when you start."),
"fields": [
{fieldtype:"Data", fieldname:"item_1", label:"Item 1", placeholder:"A Product or Service"},
{fieldtype:"Column Break"},
{fieldtype:"Attach", fieldname:"item_img_1", label:"Attach Image..."},
{fieldtype:"Section Break"},
{fieldtype:"Column Break"},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_group_1", options:["Products", "Services", "Raw Material", "Sub Assemblies"]},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_uom_1", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"item_2", label:"Item 2", placeholder:"A Product or Service"},
{fieldtype:"Column Break"},
{fieldtype:"Attach", fieldname:"item_img_2", label:"Attach Image..."},
{fieldtype:"Section Break"},
{fieldtype:"Column Break"},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_group_2", options:["Products", "Services", "Raw Material", "Sub Assemblies"]},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_uom_2", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"item_3", label:"Item 3", placeholder:"A Product or Service"},
{fieldtype:"Column Break"},
{fieldtype:"Attach", fieldname:"item_img_3", label:"Attach Image..."},
{fieldtype:"Section Break"},
{fieldtype:"Column Break"},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_group_3", options:["Products", "Services", "Raw Material", "Sub Assemblies"]},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_uom_3", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"item_4", label:"Item 4", placeholder:"A Product or Service"},
{fieldtype:"Column Break"},
{fieldtype:"Attach", fieldname:"item_img_4", label:"Attach Image..."},
{fieldtype:"Section Break"},
{fieldtype:"Column Break"},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_group_4", options:["Products", "Services", "Raw Material", "Sub Assemblies"]},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_uom_4", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"item_5", label:"Item 5", placeholder:"A Product or Service"},
{fieldtype:"Column Break"},
{fieldtype:"Attach", fieldname:"item_img_5", label:"Attach Image..."},
{fieldtype:"Section Break"},
{fieldtype:"Column Break"},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_group_5", options:["Products", "Services", "Raw Material", "Sub Assemblies"]},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_uom_5", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]},
],
},
// Items to Buy
{
icon: "icon-barcode",
"title": wn._("Products or Services You Buy"),
"help": wn._("List a few products or services you buy from your suppliers or vendors. If these are same as your products, then do not add them."),
"fields": [
{fieldtype:"Data", fieldname:"item_buy_1", label:"Item 1", placeholder:"A Product or Service"},
{fieldtype:"Section Break"},
{fieldtype:"Column Break"},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_buy_group_1", options:["Raw Material", "Consumable", "Sub Assemblies", "Services", "Products"]},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_buy_uom_1", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"item_buy_2", label:"Item 2", placeholder:"A Product or Service"},
{fieldtype:"Section Break"},
{fieldtype:"Column Break"},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_buy_group_2", options:["Raw Material", "Consumable", "Sub Assemblies", "Services", "Products"]},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_buy_uom_2", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"item_buy_3", label:"Item 3", placeholder:"A Product or Service"},
{fieldtype:"Section Break"},
{fieldtype:"Column Break"},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_buy_group_3", options:["Raw Material", "Consumable", "Sub Assemblies", "Services", "Products"]},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_buy_uom_3", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"item_buy_4", label:"Item 4", placeholder:"A Product or Service"},
{fieldtype:"Section Break"},
{fieldtype:"Column Break"},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_buy_group_4", options:["Raw Material", "Consumable", "Sub Assemblies", "Services", "Products"]},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_buy_uom_4", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"item_buy_5", label:"Item 5", placeholder:"A Product or Service"},
{fieldtype:"Section Break"},
{fieldtype:"Column Break"},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_buy_group_5", options:["Raw Material", "Consumable", "Sub Assemblies", "Services", "Products"]},
{fieldtype:"Column Break"},
{fieldtype:"Select", fieldname:"item_buy_uom_5", options:["Unit", "Nos", "Box", "Pair", "Kg", "Set", "Hour", "Minute"]},
],
},
// Customers
{
icon: "icon-group",
"title": wn._("Your Customers"),
"help": wn._("List a few of your customers. They could be organizations or individuals."),
"fields": [
{fieldtype:"Data", fieldname:"customer_1", label:"Customer 1", placeholder:"Customer Name"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"customer_contact_1", label:"", placeholder:"Contact Name"},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"customer_2", label:"Customer 2", placeholder:"Customer Name"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"customer_contact_2", label:"", placeholder:"Contact Name"},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"customer_3", label:"Customer 3", placeholder:"Customer Name"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"customer_contact_3", label:"", placeholder:"Contact Name"},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"customer_4", label:"Customer 4", placeholder:"Customer Name"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"customer_contact_4", label:"", placeholder:"Contact Name"},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"customer_5", label:"Customer 5", placeholder:"Customer Name"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"customer_contact_5", label:"", placeholder:"Contact Name"},
],
},
// Suppliers
{
icon: "icon-group",
"title": wn._("Your Suppliers"),
"help": wn._("List a few of your suppliers. They could be organizations or individuals."),
"fields": [
{fieldtype:"Data", fieldname:"supplier_1", label:"Supplier 1", placeholder:"Supplier Name"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"supplier_contact_1", label:"", placeholder:"Contact Name"},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"supplier_2", label:"Supplier 2", placeholder:"Supplier Name"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"supplier_contact_2", label:"", placeholder:"Contact Name"},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"supplier_3", label:"Supplier 3", placeholder:"Supplier Name"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"supplier_contact_3", label:"", placeholder:"Contact Name"},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"supplier_4", label:"Supplier 4", placeholder:"Supplier Name"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"supplier_contact_4", label:"", placeholder:"Contact Name"},
{fieldtype:"Section Break"},
{fieldtype:"Data", fieldname:"supplier_5", label:"Supplier 5", placeholder:"Supplier Name"},
{fieldtype:"Column Break"},
{fieldtype:"Data", fieldname:"supplier_contact_5", label:"", placeholder:"Contact Name"},
],
}
]
})
}
wn.pages['setup-wizard'].onshow = function(wrapper) {
if(wn.get_route()[1])
erpnext.wiz.show(wn.get_route()[1]);
}
wn.provide("wn.wiz");
wn.wiz.Wizard = Class.extend({
init: function(opts) {
$.extend(this, opts);
this.slides = this.slides;
this.slide_dict = {};
this.show_welcome();
},
get_message: function(html) {
return $(repl('<div class="panel panel-default" style="max-width: 400px; margin: auto;">\
<div class="panel-body" style="padding: 40px;">%(html)s</div>\
</div>', {html:html}))
},
show_welcome: function() {
if(this.$welcome)
return;
var me = this;
this.$welcome = this.get_message(this.welcome_html +
'<br><p class="text-center"><button class="btn btn-primary">'+wn._("Start")+'</button></p>')
.appendTo(this.parent);
this.$welcome.find(".btn").click(function() {
me.$welcome.toggle(false);
me.welcomed = true;
wn.set_route(me.page_name, "0");
})
this.current_slide = {"$wrapper": this.$welcome};
},
show_working: function() {
this.hide_current_slide();
wn.set_route(this.page_name);
this.current_slide = {"$wrapper": this.get_message(this.working_html).appendTo(this.parent)};
},
show_complete: function() {
this.hide_current_slide();
this.current_slide = {"$wrapper": this.get_message(this.complete_html).appendTo(this.parent)};
},
show: function(id) {
if(!this.welcomed) {
wn.set_route(this.page_name);
return;
}
id = cint(id);
if(this.current_slide && this.current_slide.id===id)
return;
if(!this.slide_dict[id]) {
this.slide_dict[id] = new wn.wiz.WizardSlide($.extend(this.slides[id], {wiz:this, id:id}));
this.slide_dict[id].make();
}
this.hide_current_slide();
this.current_slide = this.slide_dict[id];
this.current_slide.$wrapper.toggle(true);
},
hide_current_slide: function() {
if(this.current_slide) {
this.current_slide.$wrapper.toggle(false);
this.current_slide = null;
}
},
get_values: function() {
var values = {};
$.each(this.slide_dict, function(id, slide) {
$.extend(values, slide.values)
})
return values;
}
});
wn.wiz.WizardSlide = Class.extend({
init: function(opts) {
$.extend(this, opts);
},
make: function() {
var me = this;
this.$wrapper = $(repl('<div class="panel panel-default" style="margin: 0px 30px;">\
<div class="panel-heading"><div class="panel-title">%(main_title)s: Step %(step)s</div></div>\
<div class="panel-body">\
<div class="progress">\
<div class="progress-bar" style="width: %(width)s%"></div>\
</div>\
<div class="row">\
<div class="col-sm-6 form"></div>\
<div class="col-sm-6 help">\
<h3><i class="%(icon)s text-muted"></i> %(title)s</h3><br>\
<p class="text-muted">%(help)s</p>\
</div>\
</div>\
<hr>\
<div class="footer"></div>\
</div>\
</div>', {help:this.help, title:this.title, main_title:this.wiz.title, step: this.id + 1,
width: (flt(this.id + 1) / (this.wiz.slides.length+1)) * 100, icon:this.icon}))
.appendTo(this.wiz.parent);
this.body = this.$wrapper.find(".form")[0];
if(this.fields) {
this.form = new wn.ui.FieldGroup({
fields: this.fields,
body: this.body,
no_submit_on_enter: true
});
this.form.make();
} else {
$(this.body).html(this.html)
}
if(this.id > 0) {
this.$prev = $("<button class='btn btn-default'>Previous</button>")
.click(function() {
wn.set_route(me.wiz.page_name, me.id-1 + "");
})
.appendTo(this.$wrapper.find(".footer"))
.css({"margin-right": "5px"});
}
if(this.id+1 < this.wiz.slides.length) {
this.$next = $("<button class='btn btn-primary'>Next</button>")
.click(function() {
me.values = me.form.get_values();
if(me.values===null)
return;
wn.set_route(me.wiz.page_name, me.id+1 + "");
})
.appendTo(this.$wrapper.find(".footer"));
} else {
this.$complete = $("<button class='btn btn-primary'>Complete Setup</button>")
.click(function() {
me.values = me.form.get_values();
if(me.values===null)
return;
me.wiz.on_complete(me.wiz);
}).appendTo(this.$wrapper.find(".footer"));
}
if(this.onload) {
this.onload(this);
}
},
get_input: function(fn) {
return this.form.get_input(fn);
}
})

View File

@@ -0,0 +1,354 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes, json, base64
from webnotes.utils import cint, cstr, getdate, now, nowdate, get_defaults
from webnotes import _
from webnotes.utils.file_manager import save_file
@webnotes.whitelist()
def setup_account(args=None):
# if webnotes.conn.sql("select name from tabCompany"):
# webnotes.throw(_("Setup Already Complete!!"))
if not args:
args = webnotes.local.form_dict
if isinstance(args, basestring):
args = json.loads(args)
args = webnotes._dict(args)
update_profile_name(args)
create_fiscal_year_and_company(args)
set_defaults(args)
create_territories()
create_price_lists(args)
create_feed_and_todo()
create_email_digest()
create_letter_head(args)
create_taxes(args)
create_items(args)
create_customers(args)
create_suppliers(args)
webnotes.conn.set_value('Control Panel', None, 'home_page', 'desktop')
webnotes.clear_cache()
webnotes.conn.commit()
# suppress msgprints
webnotes.local.message_log = []
return "okay"
def update_profile_name(args):
if args.get("email"):
args['name'] = args.get("email")
webnotes.flags.mute_emails = True
webnotes.bean({
"doctype":"Profile",
"email": args.get("email"),
"first_name": args.get("first_name"),
"last_name": args.get("last_name")
}).insert()
webnotes.flags.mute_emails = False
from webnotes.auth import _update_password
_update_password(args.get("email"), args.get("password"))
else:
args['name'] = webnotes.session.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""", args)
if args.get("attach_profile"):
filename, filetype, content = args.get("attach_profile").split(",")
fileurl = save_file(filename, content, "Profile", args.get("name"), decode=True).file_name
webnotes.conn.set_value("Profile", args.get("name"), "user_image", fileurl)
add_all_roles_to(args.get("name"))
def create_fiscal_year_and_company(args):
curr_fiscal_year, fy_start_date, fy_abbr = get_fy_details(args.get('fy_start'), True)
webnotes.bean([{
"doctype":"Fiscal Year",
'year': curr_fiscal_year,
'year_start_date': fy_start_date
}]).insert()
curr_fiscal_year, fy_start_date, fy_abbr = get_fy_details(args.get('fy_start'))
webnotes.bean([{
"doctype":"Fiscal Year",
'year': curr_fiscal_year,
'year_start_date': fy_start_date,
}]).insert()
# Company
webnotes.bean([{
"doctype":"Company",
'domain': args.get("industry"),
'company_name':args.get('company_name'),
'abbr':args.get('company_abbr'),
'default_currency':args.get('currency'),
}]).insert()
args["curr_fiscal_year"] = curr_fiscal_year
def create_price_lists(args):
for pl_type in ["Selling", "Buying"]:
webnotes.bean([
{
"doctype": "Price List",
"price_list_name": "Standard " + pl_type,
"buying_or_selling": pl_type,
"currency": args["currency"]
},
{
"doctype": "For Territory",
"parentfield": "valid_for_territories",
"territory": "All Territories"
}
]).insert()
def set_defaults(args):
# enable default currency
webnotes.conn.set_value("Currency", args.get("currency"), "enabled", 1)
global_defaults = webnotes.bean("Global Defaults", "Global Defaults")
global_defaults.doc.fields.update({
'current_fiscal_year': args.curr_fiscal_year,
'default_currency': args.get('currency'),
'default_company':args.get('company_name'),
'date_format': webnotes.conn.get_value("Country", args.get("country"), "date_format"),
"float_precision": 4
})
global_defaults.save()
accounts_settings = webnotes.bean("Accounts Settings")
accounts_settings.doc.auto_accounting_for_stock = 1
accounts_settings.save()
stock_settings = webnotes.bean("Stock Settings")
stock_settings.doc.item_naming_by = "Item Code"
stock_settings.doc.valuation_method = "FIFO"
stock_settings.doc.stock_uom = "Nos"
stock_settings.doc.auto_indent = 1
stock_settings.save()
selling_settings = webnotes.bean("Selling Settings")
selling_settings.doc.cust_master_name = "Customer Name"
selling_settings.doc.so_required = "No"
selling_settings.doc.dn_required = "No"
selling_settings.save()
buying_settings = webnotes.bean("Buying Settings")
buying_settings.doc.supp_master_name = "Supplier Name"
buying_settings.doc.po_required = "No"
buying_settings.doc.pr_required = "No"
buying_settings.doc.maintain_same_rate = 1
buying_settings.save()
notification_control = webnotes.bean("Notification Control")
notification_control.doc.quotation = 1
notification_control.doc.sales_invoice = 1
notification_control.doc.purchase_order = 1
notification_control.save()
hr_settings = webnotes.bean("HR Settings")
hr_settings.doc.emp_created_by = "Naming Series"
hr_settings.save()
# control panel
cp = webnotes.doc("Control Panel", "Control Panel")
for k in ['country', 'timezone', 'company_name']:
cp.fields[k] = args[k]
cp.save()
def create_feed_and_todo():
"""update activty feed and create todo for creation of item, customer, vendor"""
import home
home.make_feed('Comment', 'ToDo', '', webnotes.session['user'],
'ERNext Setup Complete!', '#6B24B3')
def create_email_digest():
from webnotes.profile import get_system_managers
system_managers = get_system_managers()
if not system_managers:
return
for company in webnotes.conn.sql_list("select name FROM `tabCompany`"):
if not webnotes.conn.exists("Email Digest", "Default Weekly Digest - " + company):
edigest = webnotes.bean({
"doctype": "Email Digest",
"name": "Default Weekly Digest - " + company,
"company": company,
"frequency": "Weekly",
"recipient_list": "\n".join(system_managers)
})
for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}):
edigest.doc.fields[fieldname] = 1
edigest.insert()
def get_fy_details(fy_start, last_year=False):
st = {'1st Jan':'01-01','1st Apr':'04-01','1st Jul':'07-01', '1st Oct': '10-01'}
if cint(getdate(nowdate()).month) < cint((st[fy_start].split('-'))[0]):
curr_year = getdate(nowdate()).year - 1
else:
curr_year = getdate(nowdate()).year
if last_year:
curr_year = curr_year - 1
stdt = cstr(curr_year)+'-'+cstr(st[fy_start])
if(fy_start == '1st Jan'):
fy = cstr(curr_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
def create_taxes(args):
for i in xrange(1,6):
if args.get("tax_" + str(i)):
webnotes.bean({
"doctype":"Account",
"company": args.get("company_name"),
"parent_account": "Duties and Taxes - " + args.get("company_abbr"),
"account_name": args.get("tax_" + str(i)),
"group_or_ledger": "Ledger",
"is_pl_account": "No",
"account_type": "Tax",
"tax_rate": args.get("tax_rate_" + str(i))
}).insert()
def create_items(args):
for i in xrange(1,6):
item = args.get("item_" + str(i))
if item:
item_group = args.get("item_group_" + str(i))
webnotes.bean({
"doctype":"Item",
"item_code": item,
"item_name": item,
"description": item,
"is_sales_item": "Yes",
"is_stock_item": item_group!="Services" and "Yes" or "No",
"item_group": item_group,
"stock_uom": args.get("item_uom_" + str(i)),
"default_warehouse": item_group!="Service" and ("Finished Goods - " + args.get("company_abbr")) or ""
}).insert()
if args.get("item_img_" + str(i)):
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
fileurl = save_file(filename, content, "Item", item, decode=True).file_name
webnotes.conn.set_value("Item", item, "image", fileurl)
for i in xrange(1,6):
item = args.get("item_buy_" + str(i))
if item:
item_group = args.get("item_buy_group_" + str(i))
webnotes.bean({
"doctype":"Item",
"item_code": item,
"item_name": item,
"description": item,
"is_sales_item": "No",
"is_stock_item": item_group!="Services" and "Yes" or "No",
"item_group": item_group,
"stock_uom": args.get("item_buy_uom_" + str(i)),
"default_warehouse": item_group!="Service" and ("Stores - " + args.get("company_abbr")) or ""
}).insert()
if args.get("item_img_" + str(i)):
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
fileurl = save_file(filename, content, "Item", item, decode=True).file_name
webnotes.conn.set_value("Item", item, "image", fileurl)
def create_customers(args):
for i in xrange(1,6):
customer = args.get("customer_" + str(i))
if customer:
webnotes.bean({
"doctype":"Customer",
"customer_name": customer,
"customer_type": "Company",
"customer_group": "Commercial",
"territory": args.get("country"),
"company": args.get("company_name")
}).insert()
if args.get("customer_contact_" + str(i)):
contact = args.get("customer_contact_" + str(i)).split(" ")
webnotes.bean({
"doctype":"Contact",
"customer": customer,
"first_name":contact[0],
"last_name": len(contact) > 1 and contact[1] or ""
}).insert()
def create_suppliers(args):
for i in xrange(1,6):
supplier = args.get("supplier_" + str(i))
if supplier:
webnotes.bean({
"doctype":"Supplier",
"supplier_name": supplier,
"supplier_type": "Local",
"company": args.get("company_name")
}).insert()
if args.get("supplier_contact_" + str(i)):
contact = args.get("supplier_contact_" + str(i)).split(" ")
webnotes.bean({
"doctype":"Contact",
"supplier": supplier,
"first_name":contact[0],
"last_name": len(contact) > 1 and contact[1] or ""
}).insert()
def create_letter_head(args):
if args.get("attach_letterhead"):
lh = webnotes.bean({
"doctype":"Letter Head",
"letter_head_name": "Standard",
"is_default": 1
}).insert()
filename, filetype, content = args.get("attach_letterhead").split(",")
fileurl = save_file(filename, content, "Letter Head", "Standard", decode=True).file_name
webnotes.conn.set_value("Letter Head", "Standard", "content", "<img src='%s' style='max-width: 100%%;'>" % fileurl)
def add_all_roles_to(name):
profile = webnotes.doc("Profile", name)
for role in webnotes.conn.sql("""select name from tabRole"""):
if role[0] not in ["Administrator", "Guest", "All", "Customer", "Supplier", "Partner"]:
d = profile.addchild("user_roles", "UserRole")
d.role = role[0]
d.insert()
def create_territories():
"""create two default territories, one for home country and one named Rest of the World"""
from setup.utils import get_root_of
country = webnotes.conn.get_value("Control Panel", None, "country")
root_territory = get_root_of("Territory")
for name in (country, "Rest Of The World"):
if name and not webnotes.conn.exists("Territory", name):
webnotes.bean({
"doctype": "Territory",
"territory_name": name.replace("'", ""),
"parent_territory": root_territory,
"is_group": "No"
}).insert()

View File

@@ -0,0 +1,32 @@
[
{
"creation": "2013-10-04 13:49:33",
"docstatus": 0,
"modified": "2013-10-04 13:49:33",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Page",
"module": "Setup",
"name": "__common__",
"page_name": "setup-wizard",
"standard": "Yes",
"title": "Setup Wizard"
},
{
"doctype": "Page Role",
"name": "__common__",
"parent": "setup-wizard",
"parentfield": "roles",
"parenttype": "Page",
"role": "System Manager"
},
{
"doctype": "Page",
"name": "setup-wizard"
},
{
"doctype": "Page Role"
}
]

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import webnotes
from setup.page.setup_wizard.test_setup_data import args
from setup.page.setup_wizard.setup_wizard import setup_account
if __name__=="__main__":
webnotes.connect()
webnotes.local.form_dict = webnotes._dict(args)
setup_account()