Fixes in Setup Wizard and Attachments
diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.js b/erpnext/hr/doctype/upload_attendance/upload_attendance.js
index 7606289..d74fb8d 100644
--- a/erpnext/hr/doctype/upload_attendance/upload_attendance.js
+++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.js
@@ -10,28 +10,28 @@
this.frm.set_value("att_fr_date", get_today());
this.frm.set_value("att_to_date", get_today());
},
-
+
refresh: function() {
this.show_upload();
},
-
+
get_template:function() {
if(!this.frm.doc.att_fr_date || !this.frm.doc.att_to_date) {
msgprint(__("Attendance From Date and Attendance To Date is mandatory"));
return;
}
- window.location.href = repl(frappe.request.url +
+ window.location.href = repl(frappe.request.url +
'?cmd=%(cmd)s&from_date=%(from_date)s&to_date=%(to_date)s', {
cmd: "erpnext.hr.doctype.upload_attendance.upload_attendance.get_template",
from_date: this.frm.doc.att_fr_date,
to_date: this.frm.doc.att_to_date,
});
},
-
+
show_upload: function() {
var me = this;
var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty();
-
+
// upload
frappe.upload.make({
parent: $wrapper,
@@ -39,7 +39,7 @@
method: 'erpnext.hr.doctype.upload_attendance.upload_attendance.upload'
},
sample_url: "e.g. http://example.com/somefile.csv",
- callback: function(fid, filename, r) {
+ callback: function(attachment, r) {
var $log_wrapper = $(cur_frm.fields_dict.import_log.wrapper).empty();
if(!r.messages) r.messages = [];
@@ -62,7 +62,7 @@
r.messages = ["<h4 style='color:green'>"+__("Import Successful!")+"</h4>"].
concat(r.message.messages)
}
-
+
$.each(r.messages, function(i, v) {
var $p = $('<p>').html(v).appendTo($log_wrapper);
if(v.substr(0,5)=='Error') {
@@ -77,11 +77,11 @@
});
}
});
-
+
// rename button
$wrapper.find('form input[type="submit"]')
.attr('value', 'Upload and Import')
}
})
-cur_frm.cscript = new erpnext.hr.AttendanceControlPanel({frm: cur_frm});
\ No newline at end of file
+cur_frm.cscript = new erpnext.hr.AttendanceControlPanel({frm: cur_frm});
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.js b/erpnext/setup/page/setup_wizard/setup_wizard.js
index bd7a3bf..629a412 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.js
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.js
@@ -106,6 +106,13 @@
slide.form.fields_dict.first_name.set_input(frappe.boot.user.first_name);
slide.form.fields_dict.last_name.set_input(frappe.boot.user.last_name);
+ var user_image = frappe.get_cookie("user_image");
+ if(user_image) {
+ var $attach_user = slide.form.fields_dict.attach_user.$wrapper;
+ $attach_user.find(".missing-image").toggle(false);
+ $attach_user.find("img").attr("src", user_image).toggle(true);
+ }
+
delete slide.form.fields_dict.email;
delete slide.form.fields_dict.password;
}
@@ -226,7 +233,7 @@
slide.fields = slide.fields.concat([
{fieldtype:"Data", fieldname:"tax_"+ i, label:__("Tax") + " " + i, placeholder:__("e.g. VAT")},
{fieldtype:"Column Break"},
- {fieldtype:"Data", fieldname:"tax_rate_i", label:__("Rate (%)"), placeholder:__("e.g. 5")},
+ {fieldtype:"Data", fieldname:"tax_rate_" + i, label:__("Rate (%)"), placeholder:__("e.g. 5")},
{fieldtype:"Section Break"},
]);
}
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py
index 718019a..3dd93bc 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe, json
-from frappe.utils import cstr, getdate
+from frappe.utils import cstr, flt, getdate
from frappe import _
from frappe.utils.file_manager import save_file
from frappe.translate import set_default_language, get_dict, get_lang_dict
@@ -15,8 +15,8 @@
@frappe.whitelist()
def setup_account(args=None):
- # if frappe.db.sql("select name from tabCompany"):
- # frappe.throw(_("Setup Already Complete!!"))
+ if frappe.db.sql("select name from tabCompany"):
+ frappe.throw(_("Setup Already Complete!!"))
if not args:
args = frappe.local.form_dict
@@ -67,7 +67,7 @@
frappe.db.set_default('desktop:home_page', 'desktop')
- website_maker(args.company_name, args.company_tagline, args.email)
+ website_maker(args.company_name, args.company_tagline, args.name)
frappe.clear_cache()
frappe.db.commit()
@@ -259,6 +259,9 @@
def create_taxes(args):
for i in xrange(1,6):
if args.get("tax_" + str(i)):
+ # replace % in case someone also enters the % symbol
+ tax_rate = (args.get("tax_rate_" + str(i)) or "").replace("%", "")
+
frappe.get_doc({
"doctype":"Account",
"company": args.get("company_name"),
@@ -267,7 +270,7 @@
"group_or_ledger": "Ledger",
"report_type": "Balance Sheet",
"account_type": "Tax",
- "tax_rate": args.get("tax_rate_" + str(i))
+ "tax_rate": flt(tax_rate) if tax_rate else None
}).insert()
def create_items(args):
@@ -290,7 +293,7 @@
if args.get("item_img_" + str(i)):
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
- fileurl = save_file(filename, content, "Item", item, decode=True).file_name
+ fileurl = save_file(filename, content, "Item", item, decode=True).file_url
frappe.db.set_value("Item", item, "image", fileurl)
for i in xrange(1,6):
@@ -311,7 +314,7 @@
if args.get("item_img_" + str(i)):
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
- fileurl = save_file(filename, content, "Item", item, decode=True).file_name
+ fileurl = save_file(filename, content, "Item", item, decode=True).file_url
frappe.db.set_value("Item", item, "image", fileurl)
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 26d827f..a894ac1 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -204,15 +204,6 @@
def get_tax_rate(self, tax_type):
return { "tax_rate": frappe.db.get_value("Account", tax_type, "tax_rate") }
- def get_file_details(self, arg = ''):
- file = frappe.db.sql("select file_group, description from tabFile where name = %s", eval(arg)['file_name'], as_dict = 1)
-
- ret = {
- 'file_group' : file and file[0]['file_group'] or '',
- 'description' : file and file[0]['description'] or ''
- }
- return ret
-
def on_trash(self):
super(Item, self).on_trash()
frappe.db.sql("""delete from tabBin where item_code=%s""", self.item_code)
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
index aff3b2e..bafa429 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.js
@@ -7,16 +7,16 @@
erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
onload: function() {
this.set_default_expense_account();
- },
-
+ },
+
set_default_expense_account: function() {
var me = this;
-
+
if (sys_defaults.auto_accounting_for_stock && !this.frm.doc.expense_account) {
return this.frm.call({
method: "erpnext.accounts.utils.get_company_default",
args: {
- "fieldname": "stock_adjustment_account",
+ "fieldname": "stock_adjustment_account",
"company": this.frm.doc.company
},
callback: function(r) {
@@ -25,13 +25,13 @@
});
}
},
-
+
setup: function() {
var me = this;
if (sys_defaults.auto_accounting_for_stock) {
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
this.frm.add_fetch("company", "cost_center", "cost_center");
-
+
this.frm.fields_dict["expense_account"].get_query = function() {
return {
"filters": {
@@ -50,7 +50,7 @@
}
}
},
-
+
refresh: function() {
if(this.frm.doc.docstatus===0) {
this.show_download_template();
@@ -70,7 +70,7 @@
this.show_reconciliation_data();
this.show_download_reconciliation_data();
},
-
+
show_download_template: function() {
var me = this;
this.frm.add_custom_button(__("Download Template"), function() {
@@ -90,11 +90,11 @@
return false;
}, "icon-download");
},
-
+
show_upload: function() {
var me = this;
var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty();
-
+
// upload
frappe.upload.make({
parent: $wrapper,
@@ -102,7 +102,7 @@
method: 'erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.upload'
},
sample_url: "e.g. http://example.com/somefile.csv",
- callback: function(fid, filename, r) {
+ callback: function(attachment, r) {
me.frm.set_value("reconciliation_json", JSON.stringify(r.message));
me.show_reconciliation_data();
me.frm.save();
@@ -114,7 +114,7 @@
.attr('value', 'Upload')
},
-
+
show_download_reconciliation_data: function() {
var me = this;
if(this.frm.doc.reconciliation_json) {
@@ -125,7 +125,7 @@
}, "icon-download");
}
},
-
+
show_reconciliation_data: function() {
var $wrapper = $(cur_frm.fields_dict.reconciliation_html.wrapper).empty();
if(this.frm.doc.reconciliation_json) {
@@ -133,11 +133,11 @@
var _make = function(data, header) {
var result = "";
-
+
var _render = header
? function(col) { return "<th>" + col + "</th>"; }
: function(col) { return "<td>" + col + "</td>"; };
-
+
$.each(data, function(i, row) {
result += "<tr>"
+ $.map(row, _render).join("")
@@ -145,7 +145,7 @@
});
return result;
};
-
+
var $reconciliation_table = $("<div style='overflow-x: auto;'>\
<table class='table table-striped table-bordered'>\
<thead>" + _make([reconciliation_data[0]], true) + "</thead>\
diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.js b/erpnext/utilities/doctype/rename_tool/rename_tool.js
index 42ae340..54fddf0 100644
--- a/erpnext/utilities/doctype/rename_tool/rename_tool.js
+++ b/erpnext/utilities/doctype/rename_tool/rename_tool.js
@@ -8,7 +8,7 @@
cur_frm.set_df_property("select_doctype", "options", r.message);
cur_frm.cscript.setup_upload();
}
- });
+ });
}
cur_frm.cscript.select_doctype = function() {
@@ -31,14 +31,14 @@
select_doctype: cur_frm.doc.select_doctype
},
sample_url: "e.g. http://example.com/somefile.csv",
- callback: function(fid, filename, r) {
+ callback: function(attachment, r) {
$log.empty().html("<hr>");
$.each(r.message, function(i, v) {
$("<div>" + v + "</div>").appendTo($log);
});
}
});
-
+
// rename button
$wrapper.find('form input[type="submit"]')
.click(function() {
@@ -46,5 +46,5 @@
})
.addClass("btn-info")
.attr('value', 'Upload and Rename')
-
-}
\ No newline at end of file
+
+}