From 4b41afdafb59686d92d17fe0fa3d6933dc5a3194 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 9 Oct 2012 15:19:59 +0200 Subject: [PATCH 1/3] begin commit fix in cleanup data --- utilities/cleanup_data.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/utilities/cleanup_data.py b/utilities/cleanup_data.py index 95e1b84066..6f790da309 100644 --- a/utilities/cleanup_data.py +++ b/utilities/cleanup_data.py @@ -34,8 +34,6 @@ def delete_transactions(): for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d): webnotes.conn.sql("delete from `tab%s`" % (t)) webnotes.conn.sql("delete from `tab%s`" % (d)) - webnotes.conn.sql("COMMIT") - webnotes.conn.sql("START TRANSACTION") print "Deleted " + d @@ -101,8 +99,6 @@ def delete_masters(): webnotes.conn.sql("delete from `tab%s`" % (t)) lst = '"'+'","'.join(masters[d])+ '"' webnotes.conn.sql("delete from `tab%s` where name not in (%s)" % (d, lst)) - webnotes.conn.sql("COMMIT") - webnotes.conn.sql("START TRANSACTION") print "Deleted " + d @@ -131,8 +127,6 @@ def delete_main_masters(): for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d): webnotes.conn.sql("delete from `tab%s`" % (t)) webnotes.conn.sql("delete from `tab%s`" % (d)) - webnotes.conn.sql("COMMIT") - webnotes.conn.sql("START TRANSACTION") print "Deleted " + d @@ -171,6 +165,7 @@ def reset_global_defaults(): def run(): webnotes.connect() + webnotes.conn.begin() # Confirmation from user confirm = '' @@ -192,14 +187,17 @@ def run(): delete_transactions() if cleanup_type == '1': + print "Reset Transaction Series" reset_transaction_series() else: delete_masters() + print "Reset All Series" reset_all_series() delete_main_masters() reset_global_defaults() print "System cleaned up succesfully" + webnotes.conn.commit() webnotes.conn.close() From a02a14f442f741ddc2bbeaac5b8cba1c38e3703f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 10 Dec 2012 15:15:52 +0530 Subject: [PATCH 2/3] employee query in expense claim --- hr/doctype/expense_claim/expense_claim.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hr/doctype/expense_claim/expense_claim.js b/hr/doctype/expense_claim/expense_claim.js index 4c9a5c504c..b06398e179 100644 --- a/hr/doctype/expense_claim/expense_claim.js +++ b/hr/doctype/expense_claim/expense_claim.js @@ -33,7 +33,9 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){ callback: function(r) { cur_frm.set_df_property("exp_approver", "options", r.message); } - }); + }); + + cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query; } cur_frm.cscript.clear_sanctioned = function(doc) { From 50a19b578c0b271d47b5a0f51cc922e6cd4a8199 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 10 Dec 2012 18:06:14 +0530 Subject: [PATCH 3/3] fix in fiscal year validation --- selling/doctype/sales_common/sales_common.py | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py index 8a1bce892e..e672abf0eb 100644 --- a/selling/doctype/sales_common/sales_common.py +++ b/selling/doctype/sales_common/sales_common.py @@ -17,12 +17,12 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import add_days, cint, cstr, default_fields, flt, getdate, now, nowdate +from webnotes.utils import add_days, cint, cstr, default_fields, flt, getdate, now, nowdate, formatdate from webnotes.model import db_exists from webnotes.model.doc import addchild from webnotes.model.wrapper import getlist, copy_doclist from webnotes.model.code import get_obj -from webnotes import form, msgprint +from webnotes import form, msgprint, _ get_value = webnotes.conn.get_value @@ -604,14 +604,15 @@ class DocType(TransactionBase): exact_outstanding = flt(tot_outstanding) + flt(grand_total) get_obj('Account',acc_head[0][0]).check_credit_limit(acc_head[0][0], obj.doc.company, exact_outstanding) - def validate_fiscal_year(self,fiscal_year,transaction_date,dn): - fy=webnotes.conn.sql("select year_start_date from `tabFiscal Year` where name='%s'"%fiscal_year) - ysd=fy and fy[0][0] or "" - yed=add_days(str(ysd),365) - if str(transaction_date) < str(ysd) or str(transaction_date) > str(yed): - msgprint("%s not within the fiscal year"%(dn)) - raise Exception - + def validate_fiscal_year(self, fiscal_year, transaction_date, label): + from accounts.utils import get_fiscal_year + if get_fiscal_year(transaction_date)[0] != fiscal_year: + msgprint(("%(label)s '%(posting_date)s': " + _("not within Fiscal Year") + \ + ": '%(fiscal_year)s'") % { + "label": label, + "posting_date": formatdate(transaction_date), + "fiscal_year": fiscal_year + }, raise_exception=1) # get against document date self.prevdoc_date_field #-----------------------------