Merge pull request #4036 from rmehta/no-party-currency
[fix] no default party currency
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index 383b4b6..a98130b 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -350,6 +350,9 @@
account: function(frm, dt, dn) {
var d = locals[dt][dn];
if(d.account) {
+ if(!frm.doc.company) frappe.throw(__("Please select Company first"));
+ if(!frm.doc.posting_date) frappe.throw(__("Please select Posting Date first"));
+
return frappe.call({
method: "erpnext.accounts.doctype.journal_entry.journal_entry.get_account_balance_and_party_type",
args: {
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index cb12969..6857c61 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -386,6 +386,7 @@
# If any row without amount, set the diff on that row
if diff:
+ blank_row = None
for d in self.get('accounts'):
if not d.credit_in_account_currency and not d.debit_in_account_currency and diff != 0:
blank_row = d
@@ -551,7 +552,7 @@
"""Returns new Journal Entry document as dict for given Purchase Invoice"""
pi = frappe.get_doc("Purchase Invoice", purchase_invoice)
- exchange_rate = get_exchange_rate(pi.debit_to, pi.party_account_currency, pi.company,
+ exchange_rate = get_exchange_rate(pi.credit_to, pi.party_account_currency, pi.company,
pi.doctype, pi.name)
jv = get_payment_entry(pi)
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index ceb9930..f66b425 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -219,14 +219,13 @@
if not account_currency:
account_currency = frappe.db.get_value("Account", gl_dict.account, "account_currency")
- self.validate_account_currency(gl_dict.account, account_currency)
- gl_dict = self.set_balance_in_account_currency(gl_dict, account_currency)
+ if self.doctype != "Journal Entry":
+ self.validate_account_currency(gl_dict.account, account_currency)
+ self.set_balance_in_account_currency(gl_dict, account_currency)
return gl_dict
def validate_account_currency(self, account, account_currency=None):
- if self.doctype == "Journal Entry":
- return
valid_currency = [self.company_currency]
if self.get("currency") and self.currency != self.company_currency:
valid_currency.append(self.currency)
@@ -236,8 +235,7 @@
.format(account, _(" or ").join(valid_currency)))
def set_balance_in_account_currency(self, gl_dict, account_currency=None):
- if (not self.get("conversion_rate") and self.doctype!="Journal Entry"
- and account_currency!=self.company_currency):
+ if (not self.get("conversion_rate") and account_currency!=self.company_currency):
frappe.throw(_("Account: {0} with currency: {1} can not be selected")
.format(gl_dict.account, account_currency))
@@ -253,8 +251,6 @@
gl_dict.credit_in_account_currency = gl_dict.credit if account_currency==self.company_currency \
else flt(gl_dict.credit / (self.get("conversion_rate")), 2)
- return gl_dict
-
def clear_unallocated_advances(self, childtype, parentfield):
self.set(parentfield, self.get(parentfield, {"allocated_amount": ["not in", [0, None, ""]]}))
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 98c6f45..e20aab0 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -208,3 +208,4 @@
erpnext.patches.v6_0.fix_planned_qty
erpnext.patches.v6_0.multi_currency
erpnext.patches.v6_2.remove_newsletter_duplicates
+erpnext.patches.v6_2.fix_missing_default_taxes_and_lead
diff --git a/erpnext/patches/v6_2/fix_missing_default_taxes_and_lead.py b/erpnext/patches/v6_2/fix_missing_default_taxes_and_lead.py
new file mode 100644
index 0000000..9c16f63
--- /dev/null
+++ b/erpnext/patches/v6_2/fix_missing_default_taxes_and_lead.py
@@ -0,0 +1,25 @@
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ # remove missing default taxes
+ for customer in frappe.db.sql_list("""select name from `tabCustomer`
+ where ifnull(default_taxes_and_charges, '')!='' and not exists (
+ select name from `tabSales Taxes and Charges Template` where name=`tabCustomer`.default_taxes_and_charges
+ )"""):
+ c = frappe.get_doc("Customer", customer)
+ c.default_taxes_and_charges = None
+ c.save()
+
+ for supplier in frappe.db.sql_list("""select name from `tabSupplier`
+ where ifnull(default_taxes_and_charges, '')!='' and not exists (
+ select name from `tabPurchase Taxes and Charges Template` where name=`tabSupplier`.default_taxes_and_charges
+ )"""):
+ c = frappe.get_doc("Supplier", supplier)
+ c.default_taxes_and_charges = None
+ c.save()
+
+ # remove missing lead
+ for customer in frappe.db.sql_list("""select name from `tabCustomer`
+ where ifnull(lead_name, '')!='' and not exists (select name from `tabLead` where name=`tabCustomer`.lead_name)"""):
+ frappe.db.set_value("Customer", customer, "lead_name", None)
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 7fe1459..b060fba 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -26,15 +26,13 @@
if cust_master_name == 'Customer Name':
self.name = self.customer_name
else:
- self.name = make_autoname(self.naming_series+'.#####')
+ if not self.naming_series:
+ frappe.throw(_("Series is mandatory"), frappe.MandatoryError)
- def validate_mandatory(self):
- if frappe.defaults.get_global_default('cust_master_name') == 'Naming Series' and not self.naming_series:
- frappe.throw(_("Series is mandatory"), frappe.MandatoryError)
+ self.name = make_autoname(self.naming_series+'.#####')
def validate(self):
self.flags.is_new_doc = self.is_new()
- self.validate_mandatory()
validate_accounting_currency(self)
validate_party_account(self)