diff --git a/accounts/doctype/fiscal_year/fiscal_year.js b/accounts/doctype/fiscal_year/fiscal_year.js index 5cd672bab6..6bf712937a 100644 --- a/accounts/doctype/fiscal_year/fiscal_year.js +++ b/accounts/doctype/fiscal_year/fiscal_year.js @@ -21,16 +21,8 @@ $.extend(cur_frm.cscript, { year_start_date: function(doc, dt, dn) { var me = this; - wn.call({ - method: 'controllers.trends.get_period_date_ranges', - args: { - period: "Yearly", - year_start_date: this.frm.doc.year_start_date - }, - callback: function(r) { - if (!r.exc) - me.frm.set_value("year_end_date", r.message[0][1]) - } - }); + year_end_date = + wn.datetime.add_days(wn.datetime.add_months(this.frm.doc.year_start_date, 12), -1); + this.frm.set_value("year_end_date", year_end_date); }, }); \ No newline at end of file diff --git a/accounts/doctype/fiscal_year/fiscal_year.py b/accounts/doctype/fiscal_year/fiscal_year.py index 891c0a57c3..d1f121765b 100644 --- a/accounts/doctype/fiscal_year/fiscal_year.py +++ b/accounts/doctype/fiscal_year/fiscal_year.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import webnotes from webnotes import msgprint, _ +from webnotes.utils import getdate class DocType: def __init__(self, d, dl): @@ -19,9 +20,16 @@ class DocType: msgprint(self.doc.name + _(""" is now the default Fiscal Year. \ Please refresh your browser for the change to take effect.""")) - def on_update(self): - from webnotes.utils import getdate + def validate(self): + year_start_end_dates = webnotes.conn.sql("""select year_start_date, year_end_date + from `tabFiscal Year` where name=%s""", (self.doc.name)) + if year_start_end_dates: + if getdate(self.doc.year_start_date) != year_start_end_dates[0][0] or getdate(self.doc.year_end_date) != year_start_end_dates[0][1]: + webnotes.throw(_("Cannot change Year Start Date and Year End Date \ + once the Fiscal Year is saved.")) + + def on_update(self): # validate year start date and year end date if getdate(self.doc.year_start_date) > getdate(self.doc.year_end_date): webnotes.throw(_("Year Start Date should not be greater than Year End Date")) diff --git a/patches/1311/p06_fix_report_columns.py b/patches/1311/p06_fix_report_columns.py new file mode 100644 index 0000000000..3516b38406 --- /dev/null +++ b/patches/1311/p06_fix_report_columns.py @@ -0,0 +1,35 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cstr +import json + +def execute(): + doctypes_child_tables_map = {} + + # Get all saved report columns + columns = webnotes.conn.sql("""select defvalue, defkey from `tabDefaultValue` where + defkey like '_list_settings:%'""") + + # Make map of doctype and child tables + for value, key in columns: + doctype = key.split(':')[-1] + child_tables = webnotes.conn.sql_list("""select options from `tabDocField` + where parent=%s and fieldtype='Table'""", doctype) + doctypes_child_tables_map.setdefault(doctype, child_tables + [doctype]) + + # If defvalue contains child doctypes then only append the column + for value, key in columns: + new_columns = [] + column_doctype = key.split(':')[-1] + for child_doctype in doctypes_child_tables_map.get(column_doctype): + for field, field_doctype in json.loads(value): + if field_doctype == child_doctype: + new_columns.append([field, field_doctype]) + + if new_columns: + defkey = "_list_settings:" + column_doctype + webnotes.conn.sql("""update `tabDefaultValue` set defvalue=%s + where defkey=%s""" % ('%s', '%s'), (json.dumps(new_columns), defkey)) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index d09cec1f40..7175b632a5 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -253,4 +253,5 @@ patch_list = [ "patches.1311.p04_update_year_end_date_of_fiscal_year", "patches.1311.p04_update_comments", "patches.1311.p05_website_brand_html", + "patches.1311.p06_fix_report_columns", ] \ No newline at end of file diff --git a/setup/doctype/backup_manager/backup_dropbox.py b/setup/doctype/backup_manager/backup_dropbox.py index f33cc88912..bbd33b5e4b 100644 --- a/setup/doctype/backup_manager/backup_dropbox.py +++ b/setup/doctype/backup_manager/backup_dropbox.py @@ -13,7 +13,7 @@ from __future__ import unicode_literals import os import webnotes -from webnotes.utils import get_request_site_address, get_base_path, cstr +from webnotes.utils import get_request_site_address, cstr from webnotes import _ from backup_manager import ignore_list @@ -75,6 +75,7 @@ def backup_to_dropbox(): from dropbox import client, session from conf import dropbox_access_key, dropbox_secret_key from webnotes.utils.backups import new_backup + from webnotes.utils import get_files_path, get_backups_path if not webnotes.conn: webnotes.connect() @@ -87,8 +88,7 @@ def backup_to_dropbox(): # upload database backup = new_backup() - filename = os.path.join(get_base_path(), "public", "backups", - os.path.basename(backup.backup_path_db)) + filename = os.path.join(get_backups_path(), os.path.basename(backup.backup_path_db)) upload_file_to_dropbox(filename, "/database", dropbox_client) webnotes.conn.close() @@ -97,7 +97,7 @@ def backup_to_dropbox(): # upload files to files folder did_not_upload = [] error_log = [] - path = os.path.join(get_base_path(), "public", "files") + path = get_files_path() for filename in os.listdir(path): filename = cstr(filename) if filename in ignore_list: diff --git a/setup/page/setup_wizard/setup_wizard.js b/setup/page/setup_wizard/setup_wizard.js index 9f775e0d6b..7b4253d510 100644 --- a/setup/page/setup_wizard/setup_wizard.js +++ b/setup/page/setup_wizard/setup_wizard.js @@ -102,6 +102,12 @@ wn.pages['setup-wizard'].onload = function(wrapper) { var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join(""); slide.get_input("company_abbr").val(abbr.toUpperCase()); }).val(wn.boot.control_panel.company_name || "").trigger("change"); + + slide.get_input("fy_start_date").on("change", function() { + var year_end_date = + wn.datetime.add_days(wn.datetime.add_months(slide.get_input("fy_start_date").val(), 12), -1); + slide.get_input("fy_end_date").val(year_end_date); + }); } }, diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js index 69f9d67206..7376f3c60f 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -129,7 +129,9 @@ cur_frm.cscript['Make Packing Slip'] = function() { var set_print_hide= function(doc, cdt, cdn){ var dn_fields = wn.meta.docfield_map['Delivery Note']; var dn_item_fields = wn.meta.docfield_map['Delivery Note Item']; - + var dn_fields_copy = dn_fields; + var dn_item_fields_copy = dn_item_fields; + if (doc.print_without_amount) { dn_fields['currency'].print_hide = 1; dn_item_fields['export_rate'].print_hide = 1; @@ -137,9 +139,12 @@ var set_print_hide= function(doc, cdt, cdn){ dn_item_fields['ref_rate'].print_hide = 1; dn_item_fields['export_amount'].print_hide = 1; } else { - dn_fields['currency'].print_hide = 0; - dn_item_fields['export_rate'].print_hide = 0; - dn_item_fields['export_amount'].print_hide = 0; + if (dn_fields_copy['currency'].print_hide != 1) + dn_fields['currency'].print_hide = 0; + if (dn_item_fields_copy['export_rate'].print_hide != 1) + dn_item_fields['export_rate'].print_hide = 0; + if (dn_item_fields_copy['export_amount'].print_hide != 1) + dn_item_fields['export_amount'].print_hide = 0; } }