Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index 5220c0f..46e336f 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -147,7 +147,6 @@
});
}
}
-
},
debit_to: function() {
diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt
index 516d192..b168ba6 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.txt
+++ b/accounts/doctype/sales_invoice/sales_invoice.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:05",
"docstatus": 0,
- "modified": "2013-10-03 18:54:31",
+ "modified": "2013-10-11 13:12:38",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -225,7 +225,6 @@
"reqd": 1
},
{
- "default": "1.00",
"description": "Rate at which Customer Currency is converted to customer's base currency",
"doctype": "DocField",
"fieldname": "conversion_rate",
diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py
index 927b249..3af9c7a 100644
--- a/controllers/accounts_controller.py
+++ b/controllers/accounts_controller.py
@@ -52,7 +52,7 @@
msgprint(_("Account for this ") + fieldname + _(" has been freezed. ") +
self.doc.doctype + _(" can not be made."), raise_exception=1)
- def set_price_list_currency(self, buying_or_selling):
+ def set_price_list_currency(self, buying_or_selling, for_validate=False):
if self.meta.get_field("currency"):
company_currency = get_company_currency(self.doc.company)
@@ -60,14 +60,13 @@
fieldname = "selling_price_list" if buying_or_selling.lower() == "selling" \
else "buying_price_list"
if self.meta.get_field(fieldname) and self.doc.fields.get(fieldname):
- if not self.doc.price_list_currency:
- self.doc.price_list_currency = webnotes.conn.get_value("Price List",
- self.doc.fields.get(fieldname), "currency")
+ self.doc.price_list_currency = webnotes.conn.get_value("Price List",
+ self.doc.fields.get(fieldname), "currency")
if self.doc.price_list_currency == company_currency:
self.doc.plc_conversion_rate = 1.0
- elif not self.doc.plc_conversion_rate:
+ elif not self.doc.plc_conversion_rate or not for_validate:
self.doc.plc_conversion_rate = self.get_exchange_rate(
self.doc.price_list_currency, company_currency)
@@ -77,7 +76,7 @@
self.doc.conversion_rate = self.doc.plc_conversion_rate
elif self.doc.currency == company_currency:
self.doc.conversion_rate = 1.0
- elif not self.doc.conversion_rate:
+ elif not self.doc.conversion_rate or not for_validate:
self.doc.conversion_rate = self.get_exchange_rate(self.doc.currency,
company_currency)
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index 25d76aa..1115b49 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -30,7 +30,7 @@
super(BuyingController, self).set_missing_values(for_validate)
self.set_supplier_from_item_default()
- self.set_price_list_currency("Buying")
+ self.set_price_list_currency("Buying", for_validate)
# set contact and address details for supplier, if they are not mentioned
if self.doc.supplier and not (self.doc.contact_person and self.doc.supplier_address):
diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py
index 37674ee..845ba85 100644
--- a/controllers/selling_controller.py
+++ b/controllers/selling_controller.py
@@ -20,7 +20,7 @@
# set contact and address details for customer, if they are not mentioned
self.set_missing_lead_customer_details()
- self.set_price_list_and_item_details()
+ self.set_price_list_and_item_details(for_validate)
if self.doc.fields.get("__islocal"):
self.set_taxes("other_charges", "charge")
@@ -38,8 +38,8 @@
if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname):
self.doc.fields[fieldname] = val
- def set_price_list_and_item_details(self):
- self.set_price_list_currency("Selling")
+ def set_price_list_and_item_details(self, for_validate=False):
+ self.set_price_list_currency("Selling", for_validate)
self.set_missing_item_details(get_item_details)
def get_other_charges(self):
diff --git a/public/js/transaction.js b/public/js/transaction.js
index e12d108..79ea536 100644
--- a/public/js/transaction.js
+++ b/public/js/transaction.js
@@ -21,8 +21,6 @@
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 @@
},
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();
+ }
+ });
}
},
@@ -131,10 +130,18 @@
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");
}
},
@@ -146,15 +153,13 @@
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();
@@ -168,7 +173,7 @@
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();
},
@@ -233,29 +238,6 @@
this.calculate_taxes_and_totals();
},
- // serial_no: function(doc, cdt, cdn) {
- // var me = this;
- // var item = wn.model.get_doc(cdt, cdn);
- // if (!item.item_code) {
- // wn.call({
- // method: 'accounts.doctype.sales_invoice.pos.get_item_from_serial_no',
- // args: {serial_no: this.serial_no.$input.val()},
- // callback: function(r) {
- // if (r.message) {
- // var item_code = r.message[0].item_code;
- // var child = wn.model.add_child(me.frm.doc, this.frm.doctype + " Item",
- // this.frm.cscript.fname);
- // child.item_code = item_code;
- // me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name);
- // }
- // else
- // msgprint(wn._("Invalid Serial No."));
- // me.refresh();
- // }
- // });
- // }
- // },
-
row_id: function(doc, cdt, cdn) {
var tax = wn.model.get_doc(cdt, cdn);
try {
@@ -486,12 +468,8 @@
}
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) {
+ if(!this.frm.doc.conversion_rate) {
wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) +
" 1 " + this.frm.doc.currency + " = [?] " + company_currency);
}
diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt
index 3f97c98..62c36b4 100644
--- a/selling/doctype/quotation/quotation.txt
+++ b/selling/doctype/quotation/quotation.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:08",
"docstatus": 0,
- "modified": "2013-09-10 10:46:33",
+ "modified": "2013-10-11 13:21:07",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -257,7 +257,6 @@
"width": "100px"
},
{
- "default": "1.00",
"description": "Rate at which customer's currency is converted to company's base currency",
"doctype": "DocField",
"fieldname": "conversion_rate",
diff --git a/selling/doctype/sales_order/sales_order.txt b/selling/doctype/sales_order/sales_order.txt
index 94e6388..46a06b5 100644
--- a/selling/doctype/sales_order/sales_order.txt
+++ b/selling/doctype/sales_order/sales_order.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-06-18 12:39:59",
"docstatus": 0,
- "modified": "2013-08-09 14:46:17",
+ "modified": "2013-10-11 13:18:47",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -272,7 +272,6 @@
"width": "100px"
},
{
- "default": "1.00",
"description": "Rate at which customer's currency is converted to company's base currency",
"doctype": "DocField",
"fieldname": "conversion_rate",
diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt
index f1493bb..6834365 100644
--- a/stock/doctype/delivery_note/delivery_note.txt
+++ b/stock/doctype/delivery_note/delivery_note.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:09",
"docstatus": 0,
- "modified": "2013-08-09 14:46:32",
+ "modified": "2013-10-11 13:19:40",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -230,7 +230,7 @@
"depends_on": "eval:doc.po_no",
"doctype": "DocField",
"fieldname": "po_date",
- "fieldtype": "Data",
+ "fieldtype": "Date",
"hidden": 1,
"label": "Customer's Purchase Order Date",
"no_copy": 0,
@@ -263,7 +263,6 @@
"reqd": 1
},
{
- "default": "1.00",
"description": "Rate at which customer's currency is converted to company's base currency",
"doctype": "DocField",
"fieldname": "conversion_rate",
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.txt b/stock/doctype/purchase_receipt/purchase_receipt.txt
index 1184643..f228a14 100755
--- a/stock/doctype/purchase_receipt/purchase_receipt.txt
+++ b/stock/doctype/purchase_receipt/purchase_receipt.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-21 16:16:39",
"docstatus": 0,
- "modified": "2013-08-09 14:47:05",
+ "modified": "2013-10-11 13:20:13",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -215,7 +215,6 @@
"reqd": 1
},
{
- "default": "1.00",
"description": "Rate at which supplier's currency is converted to company's base currency",
"doctype": "DocField",
"fieldname": "conversion_rate",
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index 36231bf..0f4d6bc 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -144,7 +144,6 @@
def get_customer_address(self, args):
args = load_json(args)
- webnotes.errprint(args)
ret = {
'customer_address' : args["address"],
'address_display' : get_address_display(args["address"]),
@@ -432,14 +431,7 @@
company_currency = webnotes.conn.get_value("Company", company, "default_currency")
- # parenthesis for 'OR' are necessary as we want it to evaluate as
- # mandatory valid condition and (1st optional valid condition
- # or 2nd optional valid condition)
- valid_conversion_rate = (conversion_rate and
- ((currency == company_currency and conversion_rate == 1.00)
- or (currency != company_currency and conversion_rate != 1.00)))
-
- if not valid_conversion_rate:
+ if not conversion_rate:
msgprint(_('Please enter valid ') + conversion_rate_label + (': ')
+ ("1 %s = [?] %s" % (currency, company_currency)),
raise_exception=True)