Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
211b04a011
@ -42,15 +42,16 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
hide_field(['customer', 'customer_address', 'contact_person', 'customer_name', 'contact_display', 'customer_group']);
|
||||
}
|
||||
}
|
||||
|
||||
if(doc.enquiry_from == 'Lead' && doc.lead) {
|
||||
cur_frm.cscript.lead(doc,cdt,cdn);
|
||||
}
|
||||
|
||||
// setup fetch
|
||||
cur_frm.cscript.set_fetch();
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
||||
if(doc.enquiry_from == 'Lead' && doc.lead) {
|
||||
cur_frm.cscript.lead(doc,cdt,cdn);
|
||||
}
|
||||
}
|
||||
|
||||
// fetch
|
||||
// ===============================================================
|
||||
|
@ -21,11 +21,6 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
//if(!doc.price_list_name && sys_defaults.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
|
||||
if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
|
||||
if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
|
||||
|
||||
// load default charges
|
||||
if(doc.__islocal && !getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length) cur_frm.cscript.load_taxes(doc, cdt, cdn);
|
||||
|
||||
if(doc.__islocal==1){ cur_frm.cscript.price_list_name(doc, cdt, cdn);}
|
||||
|
||||
if(doc.quotation_to) {
|
||||
if(doc.quotation_to == 'Customer') {
|
||||
@ -37,6 +32,12 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
// load default charges
|
||||
if(doc.__islocal && !getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length)
|
||||
cur_frm.cscript.load_taxes(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
// hide - unhide fields based on lead or customer..
|
||||
// =======================================================================================================================
|
||||
cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
|
||||
|
@ -13,10 +13,6 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
if (!doc.posting_date) doc.posting_date = dateutil.obj_to_str(new Date());
|
||||
if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date());
|
||||
if (!doc.status) doc.status = 'Draft';
|
||||
|
||||
if(doc.__islocal){
|
||||
cur_frm.cscript.get_default_schedule_date(doc);
|
||||
}
|
||||
|
||||
if(doc.__islocal){
|
||||
hide_field(['supplier_name','supplier_address','contact_person','address_display','contact_display','contact_mobile','contact_email']);
|
||||
@ -26,6 +22,12 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
|
||||
if(doc.__islocal){
|
||||
cur_frm.cscript.get_default_schedule_date(doc);
|
||||
}
|
||||
}
|
||||
|
||||
//========================== Refresh ===============================================================
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
|
@ -235,3 +235,10 @@ class DocType:
|
||||
sle_obj.validate()
|
||||
sle.save(new = 1)
|
||||
return sle.name
|
||||
|
||||
def repost(self):
|
||||
"""
|
||||
Repost everything!
|
||||
"""
|
||||
for wh in sql("select name from tabWarehouse"):
|
||||
get_obj('Warehouse', wh[0]).repost_stock()
|
||||
|
@ -1,6 +1,6 @@
|
||||
# REMEMBER to update this
|
||||
# ========================
|
||||
last_patch = 293
|
||||
last_patch = 294
|
||||
|
||||
#-------------------------------------------
|
||||
|
||||
@ -1167,3 +1167,10 @@ def execute(patch_no):
|
||||
elif patch_no == 293:
|
||||
sql("delete from tabDocField where parent='Account' and fieldname='address'")
|
||||
reload_doc('accounts', 'doctype', 'account')
|
||||
elif patch_no == 294:
|
||||
# new account profile fix
|
||||
ul = sql("select name from tabProfile where ifnull(name,'') not in ('Administrator', 'Guest', '')")
|
||||
# if one user and one user has no roles
|
||||
if len(ul)==1 and not sql("select parent from tabUserRole where role='System Manager' and parent=%s", ul[0][0]):
|
||||
get_obj('Setup Control').add_roles(Document('Profile', ul[0][0]))
|
||||
|
||||
|
@ -6,6 +6,7 @@ from webnotes.model.doclist import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
@ -36,7 +37,7 @@ class DocType:
|
||||
|
||||
|
||||
def validate(self):
|
||||
|
||||
from webnotes.utils import flt
|
||||
for d in getlist(self.doclist, 'target_details'):
|
||||
if not flt(d.target_qty) and not flt(d.target_amount):
|
||||
msgprint("Either target qty or target amount is mandatory.")
|
||||
|
@ -18,160 +18,164 @@ convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
#Default Naming Series
|
||||
#---------------------------------------------------
|
||||
def naming_series(self):
|
||||
ns = [['TDS Payment', 'TDSP'], ['Payable Voucher', 'BILL'], ['Journal Voucher', 'JV'], ['Receivable Voucher', 'INV'], ['Lead', 'Lead'], ['Indent', 'IDT'], ['Enquiry', 'Enquiry'], ['Purchase Order', 'PO'], ['Quotation', 'QTN'], ['Purchase Receipt', 'GRN'], ['Stock Entry', 'STE'], ['Sales Order', 'SO'], ['Delivery Note', 'DN'], ['Employee', 'EMP/']]
|
||||
for r in ns:
|
||||
rec = Document('Naming Series')
|
||||
rec.select_doc_for_series = r[0]
|
||||
rec.new_series = r[1]
|
||||
rec_obj = get_obj(doc=rec)
|
||||
rec_obj.add_series()
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
#Default Naming Series
|
||||
#---------------------------------------------------
|
||||
def naming_series(self):
|
||||
ns = [['TDS Payment', 'TDSP'], ['Payable Voucher', 'BILL'], ['Journal Voucher', 'JV'], ['Receivable Voucher', 'INV'], ['Lead', 'Lead'], ['Indent', 'IDT'], ['Enquiry', 'Enquiry'], ['Purchase Order', 'PO'], ['Quotation', 'QTN'], ['Purchase Receipt', 'GRN'], ['Stock Entry', 'STE'], ['Sales Order', 'SO'], ['Delivery Note', 'DN'], ['Employee', 'EMP/']]
|
||||
for r in ns:
|
||||
rec = Document('Naming Series')
|
||||
rec.select_doc_for_series = r[0]
|
||||
rec.new_series = r[1]
|
||||
rec_obj = get_obj(doc=rec)
|
||||
rec_obj.add_series()
|
||||
|
||||
# set account details
|
||||
#-----------------------
|
||||
def set_account_details(self, args):
|
||||
args = eval(args)
|
||||
|
||||
self.set_cp_defaults(args['company_name'], args['industry'], args['time_zone'], args['country'], args['account_name'])
|
||||
self.create_profile(args['user'], args['first_name'], args['last_name'])
|
||||
self.update_client_control()
|
||||
|
||||
|
||||
# Account Setup
|
||||
# ---------------
|
||||
def setup_account(self, args):
|
||||
company_name, comp_abbr, fy_start, currency = eval(args)
|
||||
curr_fiscal_year,fy_start_date = self.get_fy_details(fy_start)
|
||||
self.currency = currency
|
||||
|
||||
# Fiscal Year
|
||||
master_dict = {'Fiscal Year':{'year':curr_fiscal_year,
|
||||
'year_start_date':fy_start_date}}
|
||||
self.create_records(master_dict)
|
||||
|
||||
# Company
|
||||
master_dict = {'Company':{'company_name':company_name,
|
||||
'abbr':comp_abbr
|
||||
}}
|
||||
self.create_records(master_dict)
|
||||
|
||||
def_args = {'current_fiscal_year':curr_fiscal_year,
|
||||
'default_currency': currency,
|
||||
'default_company':company_name,
|
||||
'default_valuation_method':'FIFO',
|
||||
'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'}
|
||||
# set account details
|
||||
#-----------------------
|
||||
def set_account_details(self, args):
|
||||
args = eval(args)
|
||||
|
||||
self.set_cp_defaults(args['company_name'], args['industry'], args['time_zone'], args['country'], args['account_name'])
|
||||
self.create_profile(args['user'], args['first_name'], args['last_name'])
|
||||
self.update_client_control()
|
||||
|
||||
|
||||
# Account Setup
|
||||
# ---------------
|
||||
def setup_account(self, args):
|
||||
company_name, comp_abbr, fy_start, currency = eval(args)
|
||||
curr_fiscal_year,fy_start_date = self.get_fy_details(fy_start)
|
||||
self.currency = currency
|
||||
|
||||
# Fiscal Year
|
||||
master_dict = {'Fiscal Year':{'year':curr_fiscal_year,
|
||||
'year_start_date':fy_start_date}}
|
||||
self.create_records(master_dict)
|
||||
|
||||
# Company
|
||||
master_dict = {'Company':{'company_name':company_name,
|
||||
'abbr':comp_abbr
|
||||
}}
|
||||
self.create_records(master_dict)
|
||||
|
||||
def_args = {'current_fiscal_year':curr_fiscal_year,
|
||||
'default_currency': currency,
|
||||
'default_company':company_name,
|
||||
'default_valuation_method':'FIFO',
|
||||
'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'}
|
||||
|
||||
# Set
|
||||
self.set_defaults(def_args)
|
||||
# Set
|
||||
self.set_defaults(def_args)
|
||||
|
||||
# Set Registration Complete
|
||||
set_default('registration_complete','1')
|
||||
# Set Registration Complete
|
||||
set_default('registration_complete','1')
|
||||
|
||||
import webnotes.utils
|
||||
return webnotes.utils.get_defaults()
|
||||
import webnotes.utils
|
||||
return webnotes.utils.get_defaults()
|
||||
|
||||
|
||||
# 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)
|
||||
else:
|
||||
fy = cstr(curr_year) + '-' + cstr(curr_year+1)
|
||||
return fy,stdt
|
||||
|
||||
# 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)
|
||||
else:
|
||||
fy = cstr(curr_year) + '-' + cstr(curr_year+1)
|
||||
return fy,stdt
|
||||
|
||||
|
||||
# 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()
|
||||
# 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('Manage Account','Manage Account')
|
||||
for d in def_args.keys():
|
||||
ma_obj.doc.fields[d] = def_args[d]
|
||||
ma_obj.doc.save()
|
||||
ma_obj.update_cp()
|
||||
# Set System Defaults
|
||||
# --------------------
|
||||
def set_defaults(self, def_args):
|
||||
ma_obj = get_obj('Manage Account','Manage Account')
|
||||
for d in def_args.keys():
|
||||
ma_obj.doc.fields[d] = def_args[d]
|
||||
ma_obj.doc.save()
|
||||
ma_obj.update_cp()
|
||||
|
||||
|
||||
# Set Control Panel Defaults
|
||||
# --------------------------
|
||||
def set_cp_defaults(self, cname, industry, timezone, country, acc_name):
|
||||
cp = Document('Control Panel','Control Panel')
|
||||
cp.account_id = acc_name
|
||||
cp.company_name = cname
|
||||
cp.industry = industry
|
||||
cp.time_zone = timezone
|
||||
cp.country = country
|
||||
cp.client_name = '<div style="padding:4px; font-size:20px;">'+cname+'</div>'
|
||||
cp.save()
|
||||
|
||||
# Create Profile
|
||||
# --------------
|
||||
def create_profile(self, user_email, user_fname, user_lname):
|
||||
roles_list = ['System Manager','Sales Manager','Sales User','Purchase Manager','Purchase User','Material Manager','Material User','Accounts Manager','Accounts User','HR Manager','HR User','Production Manager','Production User','Sales Master Manager','Purchase Master Manager','Material Master Manager','Quality Manager','Maintenance User','Maintenance Manager']
|
||||
pr = Document('Profile')
|
||||
pr.first_name = user_fname
|
||||
pr.last_name = user_lname
|
||||
pr.email = user_email
|
||||
pr.enabled = 1
|
||||
pr.save(1)
|
||||
for r in roles_list:
|
||||
d = addchild(pr, 'userroles', 'UserRole', 1)
|
||||
d.role = r
|
||||
d.save()
|
||||
# Add roles to Administrator profile
|
||||
pr_obj = get_obj('Profile','Administrator')
|
||||
for r in roles_list:
|
||||
d = addchild(pr_obj.doc,'userroles', 'UserRole', 1)
|
||||
d.role = r
|
||||
d.save()
|
||||
|
||||
# Update WN ERP Client Control
|
||||
# -----------------------------
|
||||
def update_client_control(self):
|
||||
cl = Document('WN ERP Client Control','WN ERP Client Control')
|
||||
cl.account_start_date = nowdate()
|
||||
cl.total_users = 1
|
||||
cl.is_trial_account = 1
|
||||
cl.save()
|
||||
# Set Control Panel Defaults
|
||||
# --------------------------
|
||||
def set_cp_defaults(self, cname, industry, timezone, country, acc_name):
|
||||
cp = Document('Control Panel','Control Panel')
|
||||
cp.account_id = acc_name
|
||||
cp.company_name = cname
|
||||
cp.industry = industry
|
||||
cp.time_zone = timezone
|
||||
cp.country = country
|
||||
cp.client_name = '<div style="padding:4px; font-size:20px;">'+cname+'</div>'
|
||||
cp.save()
|
||||
|
||||
# Create Profile
|
||||
# --------------
|
||||
def create_profile(self, user_email, user_fname, user_lname):
|
||||
pr = Document('Profile')
|
||||
pr.first_name = user_fname
|
||||
pr.last_name = user_lname
|
||||
pr.email = user_email
|
||||
pr.enabled = 1
|
||||
pr.save(1)
|
||||
self.add_roles(pr)
|
||||
|
||||
def add_roles(self, pr):
|
||||
roles_list = ['System Manager','Sales Manager','Sales User','Purchase Manager','Purchase User','Material Manager','Material User','Accounts Manager','Accounts User','HR Manager','HR User','Production Manager','Production User','Sales Master Manager','Purchase Master Manager','Material Master Manager','Quality Manager','Maintenance User','Maintenance Manager']
|
||||
for r in roles_list:
|
||||
d = addchild(pr, 'userroles', 'UserRole', 1)
|
||||
d.role = r
|
||||
d.save(1)
|
||||
|
||||
# Sync DB
|
||||
# -------
|
||||
def sync_db(arg=''):
|
||||
import webnotes.model.db_schema
|
||||
sql("delete from `tabDocType Update Register`")
|
||||
webnotes.model.db_schema.sync_all()
|
||||
# Add roles to Administrator profile
|
||||
pr_obj = get_obj('Profile','Administrator')
|
||||
for r in roles_list:
|
||||
d = addchild(pr_obj.doc,'userroles', 'UserRole', 1)
|
||||
d.role = r
|
||||
d.save(1)
|
||||
|
||||
# Update WN ERP Client Control
|
||||
# -----------------------------
|
||||
def update_client_control(self):
|
||||
cl = Document('WN ERP Client Control','WN ERP Client Control')
|
||||
cl.account_start_date = nowdate()
|
||||
cl.total_users = 1
|
||||
cl.is_trial_account = 1
|
||||
cl.save()
|
||||
|
||||
# Sync DB
|
||||
# -------
|
||||
def sync_db(arg=''):
|
||||
import webnotes.model.db_schema
|
||||
sql("delete from `tabDocType Update Register`")
|
||||
webnotes.model.db_schema.sync_all()
|
@ -9,10 +9,13 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date())
|
||||
if (!doc.status) doc.status = 'Draft';
|
||||
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
||||
// second call
|
||||
if(doc.__islocal){
|
||||
cur_frm.cscript.get_item_defaults(doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.get_item_defaults = function(doc) {
|
||||
|
@ -15,16 +15,18 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
if(!doc.currency) doc.currency = sys_defaults.currency;
|
||||
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
|
||||
if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
|
||||
|
||||
if(doc.__islocal){
|
||||
cur_frm.cscript.get_default_schedule_date(doc);
|
||||
}
|
||||
|
||||
if(doc.__islocal){
|
||||
hide_field(['supplier_name','supplier_address','contact_person','address_display','contact_display','contact_mobile','contact_email']);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
||||
if(doc.__islocal){
|
||||
cur_frm.cscript.get_default_schedule_date(doc);
|
||||
}
|
||||
}
|
||||
|
||||
// ================================== Refresh ==========================================
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user