[fix] validate 'cannot change fiscal year dates' only if not new

This commit is contained in:
Anand Doshi 2016-01-04 12:20:25 +05:30
parent 7ae53657f9
commit c1e1026486

View File

@ -20,11 +20,12 @@ class FiscalYear(Document):
msgprint(_("{0} is now the default Fiscal Year. Please refresh your browser for the change to take effect.").format(self.name)) msgprint(_("{0} is now the default Fiscal Year. Please refresh your browser for the change to take effect.").format(self.name))
def validate(self): def validate(self):
self.validate_dates()
if not self.is_new():
year_start_end_dates = frappe.db.sql("""select year_start_date, year_end_date year_start_end_dates = frappe.db.sql("""select year_start_date, year_end_date
from `tabFiscal Year` where name=%s""", (self.name)) from `tabFiscal Year` where name=%s""", (self.name))
self.validate_dates()
if year_start_end_dates: if year_start_end_dates:
if getdate(self.year_start_date) != year_start_end_dates[0][0] or getdate(self.year_end_date) != year_start_end_dates[0][1]: if getdate(self.year_start_date) != year_start_end_dates[0][0] or getdate(self.year_end_date) != year_start_end_dates[0][1]:
frappe.throw(_("Cannot change Fiscal Year Start Date and Fiscal Year End Date once the Fiscal Year is saved.")) frappe.throw(_("Cannot change Fiscal Year Start Date and Fiscal Year End Date once the Fiscal Year is saved."))