Merge branch 'wsgi' of https://github.com/webnotes/erpnext into i18n

Conflicts:
	accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js
	accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js
	public/js/complete_setup.js
	selling/doctype/opportunity/opportunity.js
	selling/doctype/quotation/quotation.js
This commit is contained in:
Bárbara Perretti
2013-10-16 15:09:18 -03:00
250 changed files with 5061 additions and 2506 deletions

View File

@@ -1,126 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
// License: GNU General Public License v3. See license.txt
// complete my company registration
// --------------------------------
wn.provide('erpnext.complete_setup');
$.extend(erpnext.complete_setup, {
show: function() {
d = erpnext.complete_setup.prepare_dialog();
d.show();
},
prepare_dialog: function() {
var d = new wn.ui.Dialog({
title: "Setup",
fields: [
{fieldname:'first_name', label:wn._('Your First Name'), fieldtype:'Data', reqd: 1},
{fieldname:'last_name', label: wn._('Your Last Name'), fieldtype:'Data'},
{fieldname:'company_name', label:wn._('Company Name'), fieldtype:'Data', reqd:1,
description: wn._('e.g. "My Company LLC"')},
{fieldname:'company_abbr', label:wn._('Company Abbreviation'), fieldtype:'Data',
description:wn._('e.g. "MC"'),reqd:1},
{fieldname:'fy_start', label:wn._('Financial Year Start Date'), fieldtype:'Select',
description:wn._('Your financial year begins on"'), reqd:1,
options: erpnext.complete_setup.fy_start_list.join('\n')},
{fieldname:'country', label: wn._('Country'), reqd:1,
options: "", fieldtype: 'Select'},
{fieldname:'currency', label: wn._('Default Currency'), reqd:1,
options: "", fieldtype: 'Select'},
{fieldname:'timezone', label: wn._('Time Zone'), reqd:1,
options: "", fieldtype: 'Select'},
{fieldname:'industry', label: wn._('Industry'), reqd:1,
options: erpnext.complete_setup.domains.join('\n'), fieldtype: 'Select'},
{fieldname:'update', label:wn._('Setup'),fieldtype:'Button'},
],
});
if(user != 'Administrator'){
d.$wrapper.find('.close').toggle(false); // Hide close image
$('header').toggle(false); // hide toolbar
}
wn.call({
method:"webnotes.country_info.get_country_timezone_info",
callback: function(data) {
erpnext.country_info = data.message.country_info;
erpnext.all_timezones = data.message.all_timezones;
d.get_input("country").empty()
.add_options([""].concat(keys(erpnext.country_info).sort()));
d.get_input("currency").empty()
.add_options(wn.utils.unique([""].concat($.map(erpnext.country_info,
function(opts, country) { return opts.currency; }))).sort());
d.get_input("timezone").empty()
.add_options([""].concat(erpnext.all_timezones));
}
})
// on clicking update
d.fields_dict.update.input.onclick = function() {
var data = d.get_values();
if(!data) return;
$(this).set_working();
return $c_obj('Setup Control','setup_account',data,function(r, rt){
$(this).done_working();
if(!r.exc) {
sys_defaults = r.message;
user_fullname = r.message.user_fullname;
wn.boot.user_info[user].fullname = user_fullname;
d.hide();
$('header').toggle(true);
wn.container.wntoolbar.set_user_name();
setTimeout(function() { window.location.reload(); }, 3000);
}
});
};
d.fields_dict.company_name.input.onchange = function() {
var parts = d.get_input("company_name").val().split(" ");
var abbr = $.map(parts, function(p) { return p ? p.substr(0,1) : null }).join("");
d.get_input("company_abbr").val(abbr.toUpperCase());
}
d.fields_dict.country.input.onchange = function() {
var country = d.fields_dict.country.input.value;
var $timezone = $(d.fields_dict.timezone.input);
$timezone.empty();
// add country specific timezones first
if(country){
var timezone_list = erpnext.country_info[country].timezones || [];
$timezone.add_options(timezone_list.sort());
d.get_input("currency").val(erpnext.country_info[country].currency);
}
// add all timezones at the end, so that user has the option to change it to any timezone
$timezone.add_options([""].concat(erpnext.all_timezones));
};
// company name already set
if(wn.control_panel.company_name) {
var inp = d.fields_dict.company_name.input;
inp.value = wn.control_panel.company_name;
inp.disabled = true;
d.fields_dict.company_name.$input.trigger("change");
}
// set first name, last name
if(user_fullname) {
u = user_fullname.split(' ');
if(u[0]) {
d.fields_dict.first_name.input.value = u[0];
}
if(u[1]) {
d.fields_dict.last_name.input.value = u[1];
}
}
return d;
},
fy_start_list: ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct'],
domains: ['', "Manufacturing", "Retail", "Distribution", "Services", "Other"],
});

View File

@@ -0,0 +1,18 @@
// get tax rate
cur_frm.cscript.account_head = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(!d.charge_type && d.account_head){
msgprint("Please select Charge Type first");
wn.model.set_value(cdt, cdn, "account_head", "");
} else if(d.account_head && d.charge_type!=="Actual") {
wn.call({
type:"GET",
method: "controllers.accounts_controller.get_tax_rate",
args: {"account_head":d.account_head},
callback: function(r) {
wn.model.set_value(cdt, cdn, "rate", r.message || 0);
}
})
}
}

View File

@@ -29,4 +29,21 @@ span, div, td, input, textarea, button, select {
width: 32px;
height: 32px;
margin: -10px auto;
}
/* pos */
.pos-item {
height: 200px;
overflow: hidden;
cursor: pointer;
padding-left: 5px !important;
padding-right: 5px !important;
}
.pos-bill {
padding: 20px 5px;
font-family: Monospace;
border: 1px solid #eee;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
}

View File

@@ -9,25 +9,10 @@ erpnext.startup.start = function() {
console.log(wn._('Starting up...'));
$('#startup_div').html('Starting up...').toggle(true);
if(user != 'Guest'){
// setup toolbar
erpnext.toolbar.setup();
// complete registration
if(in_list(user_roles,'System Manager') && (wn.boot.setup_complete==='No')) {
wn.require("app/js/complete_setup.js");
erpnext.complete_setup.show();
} else if(!wn.boot.customer_count) {
if(wn.get_route()[0]!=="Setup") {
msgprint("<a class='btn btn-success' href='#Setup'>"
+ wn._("Proceed to Setup") + "</a>\
<br><br><p class='text-muted'>"+
wn._("This message goes away after you create your first customer.")+
"</p>", wn._("Welcome"));
}
} else if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) {
erpnext.startup.show_expiry_banner();
}
erpnext.toolbar.setup();
if(wn.boot.expires_on && in_list(user_roles, 'System Manager')) {
erpnext.startup.show_expiry_banner();
}
}

View File

@@ -28,7 +28,7 @@ erpnext.StockGridReport = wn.views.TreeGridReport.extend({
var value_diff = (rate * add_qty);
if(add_qty)
wh.fifo_stack.push([add_qty, sl.incoming_rate, sl.posting_date]);
wh.fifo_stack.push([add_qty, sl.incoming_rate, sl.posting_date]);
} else {
// outgoing
if(sl.serial_no) {
@@ -98,7 +98,7 @@ erpnext.StockGridReport = wn.views.TreeGridReport.extend({
$.each(sl.serial_no.trim().split("\n"), function(i, sr) {
if(sr) {
value_diff += flt(me.serialized_buying_rates[sr.trim()]);
value_diff += flt(me.serialized_buying_rates[sr.trim().toLowerCase()]);
}
});
@@ -111,8 +111,9 @@ erpnext.StockGridReport = wn.views.TreeGridReport.extend({
$.each(wn.report_dump.data["Stock Ledger Entry"], function(i, sle) {
if(sle.qty > 0 && sle.serial_no) {
$.each(sle.serial_no.trim().split("\n"), function(i, sr) {
if(sr && sle.incoming_rate !== undefined) {
serialized_buying_rates[sr.trim()] = flt(sle.incoming_rate);
if(sr && sle.incoming_rate !== undefined
&& !serialized_buying_rates[sr.trim().toLowerCase()]) {
serialized_buying_rates[sr.trim().toLowerCase()] = flt(sle.incoming_rate);
}
});
}

View File

@@ -21,8 +21,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
company: wn.defaults.get_default("company"),
fiscal_year: wn.defaults.get_default("fiscal_year"),
is_subcontracted: "No",
conversion_rate: 1.0,
plc_conversion_rate: 1.0
}, function(fieldname, value) {
if(me.frm.fields_dict[fieldname] && !me.frm.doc[fieldname])
me.frm.set_value(fieldname, value);
@@ -41,18 +39,19 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
},
onload_post_render: function() {
if(this.frm.doc.__islocal && this.frm.doc.company && !this.frm.doc.customer) {
var me = this;
return this.frm.call({
doc: this.frm.doc,
method: "onload_post_render",
freeze: true,
callback: function(r) {
// remove this call when using client side mapper
me.set_default_values();
me.set_dynamic_labels();
}
});
if(this.frm.doc.__islocal && this.frm.doc.company &&
!this.frm.doc.customer && !this.frm.doc.is_pos) {
var me = this;
return this.frm.call({
doc: this.frm.doc,
method: "onload_post_render",
freeze: true,
callback: function(r) {
// remove this call when using client side mapper
me.set_default_values();
me.set_dynamic_labels();
}
});
}
},
@@ -62,6 +61,56 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
erpnext.hide_company();
this.show_item_wise_taxes();
this.set_dynamic_labels();
// Show POS button only if it is enabled from features setup
if(cint(sys_defaults.fs_pos_view)===1 && this.frm.doctype!="Material Request")
this.pos_btn();
},
pos_btn: function() {
if(this.$pos_btn)
this.$pos_btn.remove();
if(!this.pos_active) {
var btn_label = wn._("POS View"),
icon = "icon-desktop";
} else {
var btn_label = wn._(this.frm.doctype) + wn._(" View"),
icon = "icon-file-text";
}
var me = this;
this.$pos_btn = this.frm.add_custom_button(btn_label, function() {
me.toggle_pos();
me.pos_btn();
}, icon);
},
toggle_pos: function(show) {
// Check whether it is Selling or Buying cycle
var price_list = wn.meta.has_field(cur_frm.doc.doctype, "selling_price_list") ?
this.frm.doc.selling_price_list : this.frm.doc.buying_price_list;
if (!price_list)
msgprint(wn._("Please select Price List"))
else {
if((show===true && this.pos_active) || (show===false && !this.pos_active)) return;
// make pos
if(!this.frm.pos) {
this.frm.layout.add_view("pos");
this.frm.pos = new erpnext.POS(this.frm.layout.views.pos, this.frm);
}
// toggle view
this.frm.layout.set_view(this.pos_active ? "" : "pos");
this.pos_active = !this.pos_active;
// refresh
if(this.pos_active)
this.frm.pos.refresh();
this.frm.refresh();
}
},
validate: function() {
@@ -81,10 +130,18 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
company: function() {
if(this.frm.doc.company && this.frm.fields_dict.currency) {
if(!this.frm.doc.currency) {
this.frm.set_value("currency", this.get_company_currency());
var company_currency = this.get_company_currency();
if (!this.frm.doc.currency) {
this.frm.set_value("currency", company_currency);
}
if (this.frm.doc.currency == company_currency) {
this.frm.set_value("conversion_rate", 1.0);
}
if (this.frm.doc.price_list_currency == company_currency) {
this.frm.set_value('plc_conversion_rate', 1.0);
}
this.frm.script_manager.trigger("currency");
}
},
@@ -96,15 +153,13 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
currency: function() {
var me = this;
this.set_dynamic_labels();
var company_currency = this.get_company_currency();
if(this.frm.doc.currency !== company_currency) {
this.get_exchange_rate(this.frm.doc.currency, company_currency,
function(exchange_rate) {
if(exchange_rate) {
me.frm.set_value("conversion_rate", exchange_rate);
me.conversion_rate();
}
me.frm.set_value("conversion_rate", exchange_rate);
me.conversion_rate();
});
} else {
this.conversion_rate();
@@ -118,7 +173,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
this.frm.doc.plc_conversion_rate !== this.frm.doc.conversion_rate) {
this.frm.set_value("plc_conversion_rate", this.frm.doc.conversion_rate);
}
this.calculate_taxes_and_totals();
},
@@ -182,7 +237,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
tax_rate: function(doc, cdt, cdn) {
this.calculate_taxes_and_totals();
},
row_id: function(doc, cdt, cdn) {
var tax = wn.model.get_doc(cdt, cdn);
try {
@@ -413,15 +468,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
}
var company_currency = this.get_company_currency();
var valid_conversion_rate = this.frm.doc.conversion_rate ?
((this.frm.doc.currency == company_currency && this.frm.doc.conversion_rate == 1.0) ||
(this.frm.doc.currency != company_currency && this.frm.doc.conversion_rate != 1.0)) :
false;
// if(!valid_conversion_rate) {
// wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) +
// " 1 " + this.frm.doc.currency + " = [?] " + company_currency);
// }
if(!this.frm.doc.conversion_rate) {
wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) +
" 1 " + this.frm.doc.currency + " = [?] " + company_currency);
}
},
calculate_taxes_and_totals: function() {

View File

@@ -20,7 +20,7 @@ $.extend(erpnext, {
hide_company: function() {
if(cur_frm.fields_dict.company) {
var companies = Object.keys(locals[":Company"]);
var companies = Object.keys(locals[":Company"] || {});
if(companies.length === 1) {
if(!cur_frm.doc.company) cur_frm.set_value("company", companies[0]);
cur_frm.toggle_display("company", false);