Fixes in Setup Wizard and Attachments
This commit is contained in:
parent
3f51705ba4
commit
07339fc69e
@ -10,28 +10,28 @@ erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({
|
|||||||
this.frm.set_value("att_fr_date", get_today());
|
this.frm.set_value("att_fr_date", get_today());
|
||||||
this.frm.set_value("att_to_date", get_today());
|
this.frm.set_value("att_to_date", get_today());
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
this.show_upload();
|
this.show_upload();
|
||||||
},
|
},
|
||||||
|
|
||||||
get_template:function() {
|
get_template:function() {
|
||||||
if(!this.frm.doc.att_fr_date || !this.frm.doc.att_to_date) {
|
if(!this.frm.doc.att_fr_date || !this.frm.doc.att_to_date) {
|
||||||
msgprint(__("Attendance From Date and Attendance To Date is mandatory"));
|
msgprint(__("Attendance From Date and Attendance To Date is mandatory"));
|
||||||
return;
|
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=%(cmd)s&from_date=%(from_date)s&to_date=%(to_date)s', {
|
||||||
cmd: "erpnext.hr.doctype.upload_attendance.upload_attendance.get_template",
|
cmd: "erpnext.hr.doctype.upload_attendance.upload_attendance.get_template",
|
||||||
from_date: this.frm.doc.att_fr_date,
|
from_date: this.frm.doc.att_fr_date,
|
||||||
to_date: this.frm.doc.att_to_date,
|
to_date: this.frm.doc.att_to_date,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
show_upload: function() {
|
show_upload: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty();
|
var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty();
|
||||||
|
|
||||||
// upload
|
// upload
|
||||||
frappe.upload.make({
|
frappe.upload.make({
|
||||||
parent: $wrapper,
|
parent: $wrapper,
|
||||||
@ -39,7 +39,7 @@ erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({
|
|||||||
method: 'erpnext.hr.doctype.upload_attendance.upload_attendance.upload'
|
method: 'erpnext.hr.doctype.upload_attendance.upload_attendance.upload'
|
||||||
},
|
},
|
||||||
sample_url: "e.g. http://example.com/somefile.csv",
|
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();
|
var $log_wrapper = $(cur_frm.fields_dict.import_log.wrapper).empty();
|
||||||
|
|
||||||
if(!r.messages) r.messages = [];
|
if(!r.messages) r.messages = [];
|
||||||
@ -62,7 +62,7 @@ erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({
|
|||||||
r.messages = ["<h4 style='color:green'>"+__("Import Successful!")+"</h4>"].
|
r.messages = ["<h4 style='color:green'>"+__("Import Successful!")+"</h4>"].
|
||||||
concat(r.message.messages)
|
concat(r.message.messages)
|
||||||
}
|
}
|
||||||
|
|
||||||
$.each(r.messages, function(i, v) {
|
$.each(r.messages, function(i, v) {
|
||||||
var $p = $('<p>').html(v).appendTo($log_wrapper);
|
var $p = $('<p>').html(v).appendTo($log_wrapper);
|
||||||
if(v.substr(0,5)=='Error') {
|
if(v.substr(0,5)=='Error') {
|
||||||
@ -77,11 +77,11 @@ erpnext.hr.AttendanceControlPanel = frappe.ui.form.Controller.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// rename button
|
// rename button
|
||||||
$wrapper.find('form input[type="submit"]')
|
$wrapper.find('form input[type="submit"]')
|
||||||
.attr('value', 'Upload and Import')
|
.attr('value', 'Upload and Import')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
cur_frm.cscript = new erpnext.hr.AttendanceControlPanel({frm: cur_frm});
|
cur_frm.cscript = new erpnext.hr.AttendanceControlPanel({frm: cur_frm});
|
||||||
|
@ -106,6 +106,13 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
|
|||||||
slide.form.fields_dict.first_name.set_input(frappe.boot.user.first_name);
|
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);
|
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.email;
|
||||||
delete slide.form.fields_dict.password;
|
delete slide.form.fields_dict.password;
|
||||||
}
|
}
|
||||||
@ -226,7 +233,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
|
|||||||
slide.fields = slide.fields.concat([
|
slide.fields = slide.fields.concat([
|
||||||
{fieldtype:"Data", fieldname:"tax_"+ i, label:__("Tax") + " " + i, placeholder:__("e.g. VAT")},
|
{fieldtype:"Data", fieldname:"tax_"+ i, label:__("Tax") + " " + i, placeholder:__("e.g. VAT")},
|
||||||
{fieldtype:"Column Break"},
|
{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"},
|
{fieldtype:"Section Break"},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, json
|
import frappe, json
|
||||||
|
|
||||||
from frappe.utils import cstr, getdate
|
from frappe.utils import cstr, flt, getdate
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils.file_manager import save_file
|
from frappe.utils.file_manager import save_file
|
||||||
from frappe.translate import set_default_language, get_dict, get_lang_dict
|
from frappe.translate import set_default_language, get_dict, get_lang_dict
|
||||||
@ -15,8 +15,8 @@ import install_fixtures
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def setup_account(args=None):
|
def setup_account(args=None):
|
||||||
# if frappe.db.sql("select name from tabCompany"):
|
if frappe.db.sql("select name from tabCompany"):
|
||||||
# frappe.throw(_("Setup Already Complete!!"))
|
frappe.throw(_("Setup Already Complete!!"))
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
args = frappe.local.form_dict
|
args = frappe.local.form_dict
|
||||||
@ -67,7 +67,7 @@ def setup_account(args=None):
|
|||||||
|
|
||||||
frappe.db.set_default('desktop:home_page', 'desktop')
|
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.clear_cache()
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
@ -259,6 +259,9 @@ def get_fy_details(fy_start_date, fy_end_date):
|
|||||||
def create_taxes(args):
|
def create_taxes(args):
|
||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
if args.get("tax_" + str(i)):
|
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({
|
frappe.get_doc({
|
||||||
"doctype":"Account",
|
"doctype":"Account",
|
||||||
"company": args.get("company_name"),
|
"company": args.get("company_name"),
|
||||||
@ -267,7 +270,7 @@ def create_taxes(args):
|
|||||||
"group_or_ledger": "Ledger",
|
"group_or_ledger": "Ledger",
|
||||||
"report_type": "Balance Sheet",
|
"report_type": "Balance Sheet",
|
||||||
"account_type": "Tax",
|
"account_type": "Tax",
|
||||||
"tax_rate": args.get("tax_rate_" + str(i))
|
"tax_rate": flt(tax_rate) if tax_rate else None
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
def create_items(args):
|
def create_items(args):
|
||||||
@ -290,7 +293,7 @@ def create_items(args):
|
|||||||
|
|
||||||
if args.get("item_img_" + str(i)):
|
if args.get("item_img_" + str(i)):
|
||||||
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
|
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)
|
frappe.db.set_value("Item", item, "image", fileurl)
|
||||||
|
|
||||||
for i in xrange(1,6):
|
for i in xrange(1,6):
|
||||||
@ -311,7 +314,7 @@ def create_items(args):
|
|||||||
|
|
||||||
if args.get("item_img_" + str(i)):
|
if args.get("item_img_" + str(i)):
|
||||||
filename, filetype, content = args.get("item_img_" + str(i)).split(",")
|
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)
|
frappe.db.set_value("Item", item, "image", fileurl)
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,15 +204,6 @@ class Item(WebsiteGenerator):
|
|||||||
def get_tax_rate(self, tax_type):
|
def get_tax_rate(self, tax_type):
|
||||||
return { "tax_rate": frappe.db.get_value("Account", tax_type, "tax_rate") }
|
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):
|
def on_trash(self):
|
||||||
super(Item, self).on_trash()
|
super(Item, self).on_trash()
|
||||||
frappe.db.sql("""delete from tabBin where item_code=%s""", self.item_code)
|
frappe.db.sql("""delete from tabBin where item_code=%s""", self.item_code)
|
||||||
|
@ -7,16 +7,16 @@ frappe.provide("erpnext.stock");
|
|||||||
erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||||
onload: function() {
|
onload: function() {
|
||||||
this.set_default_expense_account();
|
this.set_default_expense_account();
|
||||||
},
|
},
|
||||||
|
|
||||||
set_default_expense_account: function() {
|
set_default_expense_account: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
if (sys_defaults.auto_accounting_for_stock && !this.frm.doc.expense_account) {
|
if (sys_defaults.auto_accounting_for_stock && !this.frm.doc.expense_account) {
|
||||||
return this.frm.call({
|
return this.frm.call({
|
||||||
method: "erpnext.accounts.utils.get_company_default",
|
method: "erpnext.accounts.utils.get_company_default",
|
||||||
args: {
|
args: {
|
||||||
"fieldname": "stock_adjustment_account",
|
"fieldname": "stock_adjustment_account",
|
||||||
"company": this.frm.doc.company
|
"company": this.frm.doc.company
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
@ -25,13 +25,13 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setup: function() {
|
setup: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
if (sys_defaults.auto_accounting_for_stock) {
|
if (sys_defaults.auto_accounting_for_stock) {
|
||||||
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
|
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
|
||||||
this.frm.add_fetch("company", "cost_center", "cost_center");
|
this.frm.add_fetch("company", "cost_center", "cost_center");
|
||||||
|
|
||||||
this.frm.fields_dict["expense_account"].get_query = function() {
|
this.frm.fields_dict["expense_account"].get_query = function() {
|
||||||
return {
|
return {
|
||||||
"filters": {
|
"filters": {
|
||||||
@ -50,7 +50,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
if(this.frm.doc.docstatus===0) {
|
if(this.frm.doc.docstatus===0) {
|
||||||
this.show_download_template();
|
this.show_download_template();
|
||||||
@ -70,7 +70,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
|||||||
this.show_reconciliation_data();
|
this.show_reconciliation_data();
|
||||||
this.show_download_reconciliation_data();
|
this.show_download_reconciliation_data();
|
||||||
},
|
},
|
||||||
|
|
||||||
show_download_template: function() {
|
show_download_template: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.frm.add_custom_button(__("Download Template"), function() {
|
this.frm.add_custom_button(__("Download Template"), function() {
|
||||||
@ -90,11 +90,11 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
|||||||
return false;
|
return false;
|
||||||
}, "icon-download");
|
}, "icon-download");
|
||||||
},
|
},
|
||||||
|
|
||||||
show_upload: function() {
|
show_upload: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty();
|
var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty();
|
||||||
|
|
||||||
// upload
|
// upload
|
||||||
frappe.upload.make({
|
frappe.upload.make({
|
||||||
parent: $wrapper,
|
parent: $wrapper,
|
||||||
@ -102,7 +102,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
|||||||
method: 'erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.upload'
|
method: 'erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.upload'
|
||||||
},
|
},
|
||||||
sample_url: "e.g. http://example.com/somefile.csv",
|
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.frm.set_value("reconciliation_json", JSON.stringify(r.message));
|
||||||
me.show_reconciliation_data();
|
me.show_reconciliation_data();
|
||||||
me.frm.save();
|
me.frm.save();
|
||||||
@ -114,7 +114,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
|||||||
.attr('value', 'Upload')
|
.attr('value', 'Upload')
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
show_download_reconciliation_data: function() {
|
show_download_reconciliation_data: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
if(this.frm.doc.reconciliation_json) {
|
if(this.frm.doc.reconciliation_json) {
|
||||||
@ -125,7 +125,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
|||||||
}, "icon-download");
|
}, "icon-download");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
show_reconciliation_data: function() {
|
show_reconciliation_data: function() {
|
||||||
var $wrapper = $(cur_frm.fields_dict.reconciliation_html.wrapper).empty();
|
var $wrapper = $(cur_frm.fields_dict.reconciliation_html.wrapper).empty();
|
||||||
if(this.frm.doc.reconciliation_json) {
|
if(this.frm.doc.reconciliation_json) {
|
||||||
@ -133,11 +133,11 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
|||||||
|
|
||||||
var _make = function(data, header) {
|
var _make = function(data, header) {
|
||||||
var result = "";
|
var result = "";
|
||||||
|
|
||||||
var _render = header
|
var _render = header
|
||||||
? function(col) { return "<th>" + col + "</th>"; }
|
? function(col) { return "<th>" + col + "</th>"; }
|
||||||
: function(col) { return "<td>" + col + "</td>"; };
|
: function(col) { return "<td>" + col + "</td>"; };
|
||||||
|
|
||||||
$.each(data, function(i, row) {
|
$.each(data, function(i, row) {
|
||||||
result += "<tr>"
|
result += "<tr>"
|
||||||
+ $.map(row, _render).join("")
|
+ $.map(row, _render).join("")
|
||||||
@ -145,7 +145,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
var $reconciliation_table = $("<div style='overflow-x: auto;'>\
|
var $reconciliation_table = $("<div style='overflow-x: auto;'>\
|
||||||
<table class='table table-striped table-bordered'>\
|
<table class='table table-striped table-bordered'>\
|
||||||
<thead>" + _make([reconciliation_data[0]], true) + "</thead>\
|
<thead>" + _make([reconciliation_data[0]], true) + "</thead>\
|
||||||
|
@ -8,7 +8,7 @@ cur_frm.cscript.refresh = function(doc) {
|
|||||||
cur_frm.set_df_property("select_doctype", "options", r.message);
|
cur_frm.set_df_property("select_doctype", "options", r.message);
|
||||||
cur_frm.cscript.setup_upload();
|
cur_frm.cscript.setup_upload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.select_doctype = function() {
|
cur_frm.cscript.select_doctype = function() {
|
||||||
@ -31,14 +31,14 @@ cur_frm.cscript.setup_upload = function() {
|
|||||||
select_doctype: cur_frm.doc.select_doctype
|
select_doctype: cur_frm.doc.select_doctype
|
||||||
},
|
},
|
||||||
sample_url: "e.g. http://example.com/somefile.csv",
|
sample_url: "e.g. http://example.com/somefile.csv",
|
||||||
callback: function(fid, filename, r) {
|
callback: function(attachment, r) {
|
||||||
$log.empty().html("<hr>");
|
$log.empty().html("<hr>");
|
||||||
$.each(r.message, function(i, v) {
|
$.each(r.message, function(i, v) {
|
||||||
$("<div>" + v + "</div>").appendTo($log);
|
$("<div>" + v + "</div>").appendTo($log);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// rename button
|
// rename button
|
||||||
$wrapper.find('form input[type="submit"]')
|
$wrapper.find('form input[type="submit"]')
|
||||||
.click(function() {
|
.click(function() {
|
||||||
@ -46,5 +46,5 @@ cur_frm.cscript.setup_upload = function() {
|
|||||||
})
|
})
|
||||||
.addClass("btn-info")
|
.addClass("btn-info")
|
||||||
.attr('value', 'Upload and Rename')
|
.attr('value', 'Upload and Rename')
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user