diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 466b2f9b21e..79ca322cacb 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -83,7 +83,7 @@ class DocType: # Account name must be unique def validate_duplicate_account(self): - if (self.doc.__islocal or (not self.doc.name)) and sql("select name from tabAccount where account_name=%s and company=%s", (self.doc.account_name, self.doc.company)): + if (self.doc.fields.get('__islocal') or (not self.doc.name)) and sql("select name from tabAccount where account_name=%s and company=%s", (self.doc.account_name, self.doc.company)): msgprint("Account Name already exists, please rename", raise_exception=1) # validate root details diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index 03acc0af65d..4bf5e976e93 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -63,6 +63,13 @@ class DocType: vouchers = [] for d in getlist(self.doclist, 'entries'): if d.clearance_date: + if getdate(d.clearance_date) < getdate(d.cheque_date): + msgprint("Clearance Date can not be before Cheque Date (Row #%s)" % + d.idx, raise_exception=1) + if getdate(d.clearance_date) < getdate(d.posting_date): + msgprint("Clearance Date can not be before Posting Date (Row #%s)" % + d.idx, raise_exception=1) + sql("update `tabJournal Voucher` set clearance_date = %s, modified = %s where name=%s", (d.clearance_date, nowdate(), d.voucher_id)) vouchers.append(d.voucher_id) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js index f9dd4cde9ea..7bb25581f33 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js @@ -16,9 +16,8 @@ wn.doclistviews['Purchase Invoice'] = wn.views.ListView.extend({ prepare_data: function(data) { this._super(data); - data.paid = flt( - ((data.grand_total - data.outstanding_amount) / data.grand_total) * 100, - 2); + data.paid = data.docstatus == 1 ? + flt(((data.grand_total - data.outstanding_amount) / data.grand_total) * 100, 2) : 0; }, columns: [ diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js index 1c3b2d38ce9..cbe1741ae3e 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js @@ -14,7 +14,8 @@ wn.doclistviews['Sales Invoice'] = wn.views.ListView.extend({ }, prepare_data: function(data) { this._super(data); - data.paid = flt((data.grand_total - data.outstanding_amount) / data.grand_total * 100, 2); + data.paid = (data.docstatus == 1) ? + flt((data.grand_total - data.outstanding_amount) / data.grand_total * 100, 2) : 0; }, columns: [ {width: '3%', content: 'check'}, diff --git a/erpnext/patches/september_2012/add_stock_ledger_entry_index.py b/erpnext/patches/september_2012/add_stock_ledger_entry_index.py index bac9a086df7..7153a7c3305 100644 --- a/erpnext/patches/september_2012/add_stock_ledger_entry_index.py +++ b/erpnext/patches/september_2012/add_stock_ledger_entry_index.py @@ -3,7 +3,8 @@ import webnotes def execute(): webnotes.conn.commit() try: - webnotes.conn.sql("""alter table `tabStock Ledger Entry` add index posting_sort_index(posting_date, posting_time, name)""")webnotes.conn.commit() + webnotes.conn.sql("""alter table `tabStock Ledger Entry` add index posting_sort_index(posting_date, posting_time, name)""") + webnotes.conn.commit() except Exception, e: if e.args[0]!=1061: raise e webnotes.conn.begin() diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 38c689e0bce..4386f2e60a0 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -37,6 +37,11 @@ convert_to_lists = webnotes.conn.convert_to_lists class DocType: def __init__(self,d,dl): self.doc, self.doclist = d,dl + + def validate(self): + if self.doc.fields.get('__islocal') and len(self.doc.abbr) > 5: + webnotes.msgprint("Abbreviation cannot have more than 5 characters", + raise_exception=1) # Create default accounts # --------------------------------------------------- diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 0a255d1291b..96c03399f16 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -18,6 +18,10 @@ cur_frm.cscript.refresh = function(doc) { // make sensitive fields(has_serial_no, is_stock_item, valuation_method) // read only if any stock ledger entry exists + if (!doc.__islocal) { + set_field_permlevel("item_code", 1); + } + if ((!doc.__islocal) && (doc.is_stock_item == 'Yes')) { var callback = function(r, rt) { if (r.message == 'exists') permlevel = 1; diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.py b/erpnext/support/doctype/maintenance_visit/maintenance_visit.py index 5175ca90a69..89fc2f0a4dc 100644 --- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.py +++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.py @@ -136,6 +136,7 @@ class DocType(TransactionBase): def check_if_last_visit(self): """check if last maintenance visit against same sales order/ customer issue""" + check_for_docname = check_for_doctype = None for d in getlist(self.doclist, 'maintenance_visit_details'): if d.prevdoc_docname: check_for_docname = d.prevdoc_docname