From b695f732930edb8c341bd717321c4d8ff28e3367 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 22 May 2012 14:53:40 +0530 Subject: [PATCH 1/5] Maintain same rate throughout pur cycle: in global defaults, by default set true --- .../purchase_invoice/purchase_invoice.py | 12 ++++-------- .../may_2012/same_purchase_rate_patch.py | 7 +++++++ erpnext/patches/patch_list.py | 6 +++++- .../doctype/global_defaults/global_defaults.py | 3 ++- .../global_defaults/global_defaults.txt | 18 +++++++++++++----- 5 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 erpnext/patches/may_2012/same_purchase_rate_patch.py diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index b459b64d69..50fa82dec8 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -300,18 +300,14 @@ class DocType(TransactionBase): supplier = '' if d.purchase_order and not d.purchase_order in self.po_list: supplier = sql("select supplier from `tabPurchase Order` where name = '%s'" % d.purchase_order)[0][0] - doctype = 'purchase order' - doctype_no = cstr(d.purchase_order) if supplier and not cstr(self.doc.supplier) == cstr(supplier): - msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,doctype,doctype_no)) + msgprint("Supplier name %s do not match with supplier name of purhase order: %s." %(self.doc.supplier,cstr(d.purchase_order))) raise Exception , " Validation Error " if d.purchase_receipt and not d.purchase_receipt in self.pr_list: supplier = sql("select supplier from `tabPurchase Receipt` where name = '%s'" % d.purchase_receipt)[0][0] - doctype = 'purchase receipt' - doctype_no = cstr(d.purchase_receipt) if supplier and not cstr(self.doc.supplier) == cstr(supplier): - msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,doctype,doctype_no)) + msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,cstr(d.purchase_receipt))) raise Exception , " Validation Error " # Validate values with reference document @@ -325,7 +321,7 @@ class DocType(TransactionBase): def validate_po_pr(self, d): # check po / pr for qty and rates and currency and conversion rate - # always import_rate must be equal to import_rate of purchase order + # currency, import_rate must be equal to currency, import_rate of purchase order if d.purchase_order and not d.purchase_order in self.po_list: # currency currency = cstr(sql("select currency from `tabPurchase Order` where name = '%s'" % d.purchase_order)[0][0]) @@ -334,7 +330,7 @@ class DocType(TransactionBase): raise Exception # import_rate rate = flt(sql('select import_rate from `tabPurchase Order Item` where item_code=%s and parent=%s and name = %s', (d.item_code, d.purchase_order, d.po_detail))[0][0]) - if abs(rate - flt(d.import_rate)) > 1: + if abs(rate - flt(d.import_rate)) > 1 and cint(get_defaults('maintain_same_rate')): msgprint("Import Rate for %s in the Purchase Order is %s. Rate must be same as Purchase Order Rate" % (d.item_code,rate)) raise Exception diff --git a/erpnext/patches/may_2012/same_purchase_rate_patch.py b/erpnext/patches/may_2012/same_purchase_rate_patch.py new file mode 100644 index 0000000000..44c0b3f6e8 --- /dev/null +++ b/erpnext/patches/may_2012/same_purchase_rate_patch.py @@ -0,0 +1,7 @@ +def execute(): + import webnotes + gd = webnotes.model.code.get_obj('Global Defaults') + gd.doc.maintain_same_rate = 1 + gd.doc.save() + gd.on_update() + \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index d1df7de736..32149d5d92 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -372,5 +372,9 @@ patch_list = [ 'patch_file': 'clear_session_cache', 'description': 'clears session cache as shifting to json format' }, - + { + 'patch_module': 'patches.may_2012', + 'patch_file': 'same_purchase_rate_patch', + 'description': 'Main same rate throughout pur cycle: in global defaults, by default set true' + }, ] \ No newline at end of file diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.py b/erpnext/setup/doctype/global_defaults/global_defaults.py index 04276407c1..9d308852fd 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.py +++ b/erpnext/setup/doctype/global_defaults/global_defaults.py @@ -35,7 +35,8 @@ keydict = { 'date_format': 'date_format', 'currency_format':'default_currency_format', 'account_url':'account_url', - 'allow_negative_stock' : 'allow_negative_stock' + 'allow_negative_stock' : 'allow_negative_stock', + 'maintain_same_rate' : 'maintain_same_rate' } class DocType: diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.txt b/erpnext/setup/doctype/global_defaults/global_defaults.txt index 5355c1008f..d1175b7c19 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.txt +++ b/erpnext/setup/doctype/global_defaults/global_defaults.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-04-18 17:00:50', + 'creation': '2012-04-20 14:02:53', 'docstatus': 0, - 'modified': '2012-04-19 17:24:45', + 'modified': '2012-05-22 14:11:21', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -224,8 +224,8 @@ 'fieldtype': u'Select', 'label': u'Default Valuation Method', 'options': u'FIFO\nMoving Average' - }, - + }, + # DocField { 'colour': u'White:FFF', @@ -508,6 +508,14 @@ 'options': u'No\nYes' }, + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'maintain_same_rate', + 'fieldtype': u'Check', + 'label': u'Maintain same rate throughout purchase cycle' + }, + # DocField { 'doctype': u'DocField', @@ -543,4 +551,4 @@ 'fieldtype': u'Data', 'label': u'SMS Sender Name' } -] +] \ No newline at end of file From 78b62cd865b5c31a17c982b78dc91127ebf54525 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 22 May 2012 16:23:27 +0530 Subject: [PATCH 2/5] Maintain same rate throughout pur cycle: in global defaults, by default set true --- erpnext/patches/may_2012/same_purchase_rate_patch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/patches/may_2012/same_purchase_rate_patch.py b/erpnext/patches/may_2012/same_purchase_rate_patch.py index 44c0b3f6e8..6cca178c10 100644 --- a/erpnext/patches/may_2012/same_purchase_rate_patch.py +++ b/erpnext/patches/may_2012/same_purchase_rate_patch.py @@ -1,6 +1,7 @@ def execute(): import webnotes - gd = webnotes.model.code.get_obj('Global Defaults') + from webnotes.model.code import get_obj + gd = get_obj('Global Defaults') gd.doc.maintain_same_rate = 1 gd.doc.save() gd.on_update() From df9f8a363e83bbfb431748c66212760ee3480ade Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 22 May 2012 16:54:46 +0530 Subject: [PATCH 3/5] Balance on chart of accounts --- .../accounts_browser/accounts_browser.css | 9 + .../page/accounts_browser/accounts_browser.js | 400 +----------------- .../page/accounts_browser/accounts_browser.py | 45 +- 3 files changed, 53 insertions(+), 401 deletions(-) diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.css b/erpnext/accounts/page/accounts_browser/accounts_browser.css index bbbbb6b8aa..718da365da 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.css +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.css @@ -18,3 +18,12 @@ span.tree-node-toolbar { font-weight: bold; text-decoration: underline; } + +span.balance-area { + float: right; + height: 13px; +} + +span.balance-bold { + font-weight: bold; +} \ No newline at end of file diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js index 0561bd73a4..1011874074 100644 --- a/erpnext/accounts/page/accounts_browser/accounts_browser.js +++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js @@ -24,7 +24,7 @@ pscript['onload_Accounts Browser'] = function(wrapper){ wn.require('lib/js/wn/ui/tree.js'); wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area')); wrapper.appframe.add_button('New Company', function() { newdoc('Company'); }, 'icon-plus'); - wrapper.appframe.add_button('Refresh', function() { + wrapper.appframe.add_button('Refresh', function() { wrapper.$company_select.change(); }, 'icon-refresh'); @@ -80,7 +80,7 @@ erpnext.AccountsChart = Class.extend({ this.tree = new wn.ui.Tree({ parent: $(wrapper).find('.tree-area'), label: company, - args: {ctype: ctype}, + args: {ctype: ctype, comp: company}, method: 'accounts.page.accounts_browser.accounts_browser.get_children', click: function(link) { if(me.cur_toolbar) @@ -93,17 +93,25 @@ erpnext.AccountsChart = Class.extend({ me.cur_toolbar = link.toolbar; $(me.cur_toolbar).toggle(true); } + + // bold + $('.balance-bold').removeClass('balance-bold'); // deselect + $(link).parent().find('.balance-area:first').addClass('balance-bold'); // select + }, + onrender: function(treenode) { + var bal = treenode.data && treenode.data.balance.split(' ') || ['','']; + treenode.parent.append(''+ bal[0] + ' ' + + bal[1] + ''); } }); - this.tree.rootnode.$a.click(); + this.tree.rootnode.$a.click(); }, make_link_toolbar: function(link) { var data = $(link).data('node-data'); if(!data) return; link.toolbar = $('').insertAfter(link); - // edit $('Edit').appendTo(link.toolbar); @@ -236,386 +244,4 @@ erpnext.AccountsChart = Class.extend({ }); d.show(); } -}); - -/* -pscript.make_chart = function(b, wrapper) { - pscript.ctype = b; - $(wrapper).find('.tree-area').empty() - $(wrapper).find('.layout-sidesection').empty() - - //================== table body====================================== - var ac_main_grid = make_table($i('ab_body'),1,2,'100%',['60%','40%'],{border:"0px", padding:"4px",tableLayout: "fixed", borderCollapse: "collapse"}); - $y($td(ac_main_grid,0,0),{border: "1px solid #dddddd", padding: "8px"}); - pscript.account_tree = $a($td(ac_main_grid,0,0),'div', '',{minHeight:'400px'}); - $y($td(ac_main_grid,0,1),{border: "1px solid #DDD"}); - pscript.la = $a($td(ac_main_grid,0,1),'div'); - pscript.acc_period_bal = $a($td(ac_main_grid,0,1),'div'); - - //=====================footer area ================================== - if (pscript.ctype == 'Account') { - var footer = $a($i('ab_body'),'div','',{backgroundColor: "#FFD", padding: "8px", color: "#444", fontSize: "12px", marginTop: "14px"}); - - var help1 = $a(footer,'span'); - help1.innerHTML = "Note: To create accounts for Customers and Suppliers, please create Customer and Supplier" - + " Masters. This will ensure that the accounts are linked to your Selling and Buying Processes. The Account Heads for Customer and Supplier will automatically be created." - } - - // header and toolbar - // ------------------ - wrapper.appframe.$titlebar.find('.appframe-title').html('Chart of '+pscript.ctype+'s'); - - // select company - // -------------- - var tab = make_table(select_area, 1, 2, null, [], {verticalAlign:'middle', padding: '2px'}); - $td(tab,0,0).innerHTML = 'Select Company'.bold(); - var sel = $a($td(tab,0,1),'select','',{width:'160px'}); - - // set tree - var set_tree = function() { - if(pscript.ac_tree) { - pscript.ac_tree.body.innerHTML = ''; - } - pscript.make_ac_tree(); - var cn = sel_val(sel); - var n = pscript.ac_tree.addNode(null, cn, null,pscript.ac_tree.std_onclick, pscript.ac_tree.std_onexp); - n.rec = {}; - n.rec.name = 'Root Node'; - n.rec.account_name = cn; - n.rec.cost_center_name = cn; - pscript.set_ac_head('',n.rec); - $ds(pscript.ac_head_area); - } - - // select company - add_sel_options(sel, ['Loading...']); - var callback = function(r,rt) { - empty_select(sel); - add_sel_options(sel,r.message.cl,sys_defaults.company); - set_tree(); - sel.onchange = function() { set_tree(); } - } - $c_obj('GL Control', 'get_companies', '', callback); - - pscript.ab_company_sel = sel; - - pscript.make_ac_head(); - pscript.make_group_area(); - pscript.make_ledger_area(); - pscript.make_new_acc_dialog(); - pscript.make_new_cost_center_dialog(); - -} - -pscript.make_ac_tree = function() { - //var type= sel_val($i('ctype')) - var type= pscript.ctype; - var tree = new Tree(pscript.account_tree, '90%'); - pscript.ac_tree = tree; - - // on click - tree.std_onclick = function(node) { - - - pscript.cur_node = node; - - // show ledger - pscript.set_ac_head(node.parent_account, node.rec,type); - } - - // on expand - tree.std_onexp = function(node) { - if(node.expanded_once)return; - $ds(node.loading_div); - //set_ac_head - var callback = function(r,rt) { - - $dh(node.loading_div); - var n = tree.allnodes[r.message.parent_acc_name]; - - var cl = r.message.cl; - - if(type=='Account'){ - for(var i=0;i Date: Tue, 22 May 2012 17:25:39 +0530 Subject: [PATCH 4/5] sms fix --- .../selling/doctype/sms_center/sms_center.py | 1 - .../page/selling_home/selling_home.html | 7 ++- .../doctype/sms_control/sms_control.py | 55 +------------------ 3 files changed, 8 insertions(+), 55 deletions(-) diff --git a/erpnext/selling/doctype/sms_center/sms_center.py b/erpnext/selling/doctype/sms_center/sms_center.py index 0d54f72bd7..16c0923de2 100644 --- a/erpnext/selling/doctype/sms_center/sms_center.py +++ b/erpnext/selling/doctype/sms_center/sms_center.py @@ -47,7 +47,6 @@ class DocType: if self.doc.send_to == 'All Sales Partner Contact': where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_aprtner = '%s'" % self.doc.sales_partner or " and ifnull(is_sales_partner, 0) = 1" if self.doc.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']: - msgprint("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause) rec = sql("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause) elif self.doc.send_to == 'All Lead (Open)': rec = sql("select lead_name, mobile_no from tabLead where ifnull(mobile_no,'')!='' and docstatus != 2 and status = 'Open'") diff --git a/erpnext/selling/page/selling_home/selling_home.html b/erpnext/selling/page/selling_home/selling_home.html index 2b3414e615..05f985895c 100644 --- a/erpnext/selling/page/selling_home/selling_home.html +++ b/erpnext/selling/page/selling_home/selling_home.html @@ -78,6 +78,11 @@ title = "Sales campaigns" href="#!List/Campaign">Campaign +
@@ -93,7 +98,7 @@ title = "Analyze Sales and Purchase trends and slice them based on item, customer, groups etc" href="#!Report/Profile/Trend Analyzer">Trend Analyzer
-
+