From e60de1a33b4124a957eaf347c51f301a84466e71 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 22 Jun 2011 17:55:01 +0530 Subject: [PATCH 1/6] added repost funtion in stock_ledger --- material_management/doctype/stock_ledger/stock_ledger.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/material_management/doctype/stock_ledger/stock_ledger.py b/material_management/doctype/stock_ledger/stock_ledger.py index a52dae7590..e67afa623b 100644 --- a/material_management/doctype/stock_ledger/stock_ledger.py +++ b/material_management/doctype/stock_ledger/stock_ledger.py @@ -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() From 48ebb2ab4ae11418542bae067e20a8dd6ebd67cd Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 22 Jun 2011 18:16:30 +0530 Subject: [PATCH 2/6] bugfix for sales_person.py --- setup/doctype/sales_person/sales_person.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup/doctype/sales_person/sales_person.py b/setup/doctype/sales_person/sales_person.py index f085376ec1..04a40bd6cd 100644 --- a/setup/doctype/sales_person/sales_person.py +++ b/setup/doctype/sales_person/sales_person.py @@ -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.") From dc7cbc23af47dcba913aa5558c5effb1ba2de5f5 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 23 Jun 2011 22:31:59 +0530 Subject: [PATCH 3/6] setup fixes --- crm/doctype/quotation/quotation.js | 11 ++++++----- setup/doctype/setup_control/setup_control.py | 10 +++++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crm/doctype/quotation/quotation.js b/crm/doctype/quotation/quotation.js index bdf67813ae..f21df25c47 100644 --- a/crm/doctype/quotation/quotation.js +++ b/crm/doctype/quotation/quotation.js @@ -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){ diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py index 971286080d..02fd573c6b 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -142,23 +142,27 @@ class DocType: # 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) + 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() + d.save(1) + # 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() + d.save(1) # Update WN ERP Client Control # ----------------------------- From adce217e05003901c8329e87a15241900dad3bc2 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 23 Jun 2011 22:36:27 +0530 Subject: [PATCH 4/6] setup fixes --- setup/doctype/setup_control/setup_control.py | 296 +++++++++---------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py index 02fd573c6b..dee01b2f6b 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -18,164 +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 = '
'+cname+'
' - 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) + # 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 = '
'+cname+'
' + 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) - 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) + # 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() - # 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() \ No newline at end of file + # Sync DB + # ------- + def sync_db(arg=''): + import webnotes.model.db_schema + sql("delete from `tabDocType Update Register`") + webnotes.model.db_schema.sync_all() \ No newline at end of file From 3e03743250f3915619756054b5e75c5411b2d233 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 23 Jun 2011 22:47:04 +0530 Subject: [PATCH 5/6] setup fixes --- patches/patch.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/patches/patch.py b/patches/patch.py index 768f7cbc26..f129482565 100644 --- a/patches/patch.py +++ b/patches/patch.py @@ -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])) + From 1d15c557a9ee482bd1cc353a1a123899255879e0 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 24 Jun 2011 09:51:58 +0530 Subject: [PATCH 6/6] added onload_post_render --- crm/doctype/enquiry/enquiry.js | 9 +++++---- .../doctype/purchase_receipt/purchase_receipt.js | 10 ++++++---- srm/doctype/indent/indent.js | 5 ++++- srm/doctype/purchase_order/purchase_order.js | 10 ++++++---- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/crm/doctype/enquiry/enquiry.js b/crm/doctype/enquiry/enquiry.js index a8c8ea2585..2eddafa4cd 100644 --- a/crm/doctype/enquiry/enquiry.js +++ b/crm/doctype/enquiry/enquiry.js @@ -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 // =============================================================== diff --git a/material_management/doctype/purchase_receipt/purchase_receipt.js b/material_management/doctype/purchase_receipt/purchase_receipt.js index da06321ea9..e060e3c564 100644 --- a/material_management/doctype/purchase_receipt/purchase_receipt.js +++ b/material_management/doctype/purchase_receipt/purchase_receipt.js @@ -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) { diff --git a/srm/doctype/indent/indent.js b/srm/doctype/indent/indent.js index a2e1614cb6..8d7ffb150c 100644 --- a/srm/doctype/indent/indent.js +++ b/srm/doctype/indent/indent.js @@ -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) { diff --git a/srm/doctype/purchase_order/purchase_order.js b/srm/doctype/purchase_order/purchase_order.js index cbc0d3a1fd..57141269ec 100644 --- a/srm/doctype/purchase_order/purchase_order.js +++ b/srm/doctype/purchase_order/purchase_order.js @@ -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) {