mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-30 10:24:48 +00:00
[fix] [minor] add time zone and country to global defaults
This commit is contained in:
@@ -8,15 +8,11 @@ def execute():
|
|||||||
webnotes.reload_doc("setup", "doctype", "global_defaults")
|
webnotes.reload_doc("setup", "doctype", "global_defaults")
|
||||||
|
|
||||||
country = webnotes.conn.sql("""select value from `tabSingles` where
|
country = webnotes.conn.sql("""select value from `tabSingles` where
|
||||||
field ='country' and doctype='Control Panel'""")
|
field='country' and doctype='Control Panel'""")
|
||||||
time_zone = webnotes.conn.sql("""select value from `tabSingles` where
|
time_zone = webnotes.conn.sql("""select value from `tabSingles` where
|
||||||
field ='timezone' and doctype='Control Panel'""")
|
field='timezone' and doctype='Control Panel'""")
|
||||||
|
|
||||||
cp_bean = webnotes.bean("Control Panel")
|
|
||||||
cp_bean.time_zone = time_zone
|
|
||||||
cp_bean.save()
|
|
||||||
|
|
||||||
gb_bean = webnotes.bean("Global Defaults")
|
gb_bean = webnotes.bean("Global Defaults")
|
||||||
gb_bean.country = country
|
gb_bean.doc.country = country and country[0][0] or None
|
||||||
gb_bean.time_zone = time_zone
|
gb_bean.doc.time_zone = time_zone and time_zone[0][0] or None
|
||||||
gb_bean.save()
|
gb_bean.save()
|
||||||
@@ -227,4 +227,5 @@ patch_list = [
|
|||||||
"patches.october_2013.p03_remove_sales_and_purchase_return_tool",
|
"patches.october_2013.p03_remove_sales_and_purchase_return_tool",
|
||||||
"patches.october_2013.p04_update_report_permission",
|
"patches.october_2013.p04_update_report_permission",
|
||||||
"patches.october_2013.p05_delete_gl_entries_for_cancelled_vouchers",
|
"patches.october_2013.p05_delete_gl_entries_for_cancelled_vouchers",
|
||||||
|
"patches.october_2013.p06_update_control_panel_and_global_defaults",
|
||||||
]
|
]
|
||||||
@@ -2,24 +2,27 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
$.extend(cur_frm.cscript, {
|
$.extend(cur_frm.cscript, {
|
||||||
validate: function(doc, cdt, cdn) {
|
onload: function(doc) {
|
||||||
return $c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){
|
|
||||||
sys_defaults = r.message;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
refresh: function() {
|
|
||||||
var me = this;
|
var me = this;
|
||||||
|
this.time_zone = doc.time_zone;
|
||||||
|
|
||||||
wn.call({
|
wn.call({
|
||||||
method:"webnotes.country_info.get_country_timezone_info",
|
method:"webnotes.country_info.get_country_timezone_info",
|
||||||
callback: function(data) {
|
callback: function(data) {
|
||||||
erpnext.country_info = data.message.country_info;
|
erpnext.country_info = data.message.country_info;
|
||||||
erpnext.all_timezones = data.message.all_timezones;
|
erpnext.all_timezones = data.message.all_timezones;
|
||||||
// me.set_timezone_options();
|
me.set_timezone_options();
|
||||||
|
cur_frm.set_value("time_zone", me.time_zone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
validate: function(doc, cdt, cdn) {
|
||||||
|
return $c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){
|
||||||
|
sys_defaults = r.message;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
country: function() {
|
country: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var timezones = [];
|
var timezones = [];
|
||||||
@@ -37,8 +40,7 @@ $.extend(cur_frm.cscript, {
|
|||||||
var remaining_timezones = $.map(erpnext.all_timezones, function(v)
|
var remaining_timezones = $.map(erpnext.all_timezones, function(v)
|
||||||
{ return filtered_options.indexOf(v)===-1 ? v : null; });
|
{ return filtered_options.indexOf(v)===-1 ? v : null; });
|
||||||
|
|
||||||
this.frm.fields_dict.time_zone.df.options =
|
this.frm.set_df_property("time_zone", "options",
|
||||||
(filtered_options.concat([""]).concat(remaining_timezones)).join("\n");
|
(filtered_options.concat([""]).concat(remaining_timezones)).join("\n"));
|
||||||
refresh_field("time_zone");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -61,8 +61,10 @@ class DocType:
|
|||||||
|
|
||||||
def update_control_panel(self):
|
def update_control_panel(self):
|
||||||
cp_bean = webnotes.bean("Control Panel")
|
cp_bean = webnotes.bean("Control Panel")
|
||||||
cp_bean.country = self.doc.country
|
if self.doc.country:
|
||||||
cp_bean.time_zone = self.doc.time_zone
|
cp_bean.doc.country = self.doc.country
|
||||||
|
if self.doc.time_zone:
|
||||||
|
cp_bean.doc.time_zone = self.doc.time_zone
|
||||||
cp_bean.save()
|
cp_bean.save()
|
||||||
|
|
||||||
def get_defaults(self):
|
def get_defaults(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user