From 486718250e09994983e12123be65c9f70e5fbbc1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 22 Jun 2012 14:14:04 +0530 Subject: [PATCH] listview of purchase invoice and deletion of supplier --- erpnext/accounts/doctype/purchase_invoice/listview.js | 9 ++++++++- erpnext/buying/doctype/supplier/supplier.py | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/listview.js b/erpnext/accounts/doctype/purchase_invoice/listview.js index 54913a5c2b..c0c6625cf8 100644 --- a/erpnext/accounts/doctype/purchase_invoice/listview.js +++ b/erpnext/accounts/doctype/purchase_invoice/listview.js @@ -4,6 +4,7 @@ wn.doclistviews['Purchase Invoice'] = wn.views.ListView.extend({ this._super(d); this.fields = this.fields.concat([ '`tabPurchase Invoice`.supplier_name', + '`tabPurchase Invoice`.credit_to', '`tabPurchase Invoice`.currency', 'IFNULL(`tabPurchase Invoice`.grand_total_import, 0) as grand_total_import', 'IFNULL(`tabPurchase Invoice`.grand_total, 0) as grand_total', @@ -24,7 +25,13 @@ wn.doclistviews['Purchase Invoice'] = wn.views.ListView.extend({ {width: '5%', content: 'avatar'}, {width: '3%', content: 'docstatus'}, {width: '15%', content: 'name'}, - {width: '34%', content: 'supplier_name+tags', css: {color: '#222'}}, + { + width: '34%', + content: function(parent, data) { + $(parent).html(data.supplier_name?data.supplier_name:data.credit_to) + }, + css: {color: '#222'} + }, { width: '18%', content: function(parent, data) { diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index 67a2aae44f..20de364c0f 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -163,10 +163,21 @@ class DocType: delete from `tabCommunication` where supplier = %s and customer is null""", self.doc.name) + def delete_supplier_account(self): + """delete supplier's ledger if exist and check balance before deletion""" + acc = sql("select name from `tabAccount` where master_type = 'Supplier' \ + and master_name = %s and docstatus < 2", self.doc.name) + if acc: + from webnotes.model import delete_doc + delete_doc('Account', acc[0][0]) + + def on_trash(self): self.delete_supplier_address() self.delete_supplier_contact() self.delete_supplier_communication() + self.delete_supplier_account() + # on rename # ---------